### Get Interface API Example (Go) Source: https://api.labelstud.io/api-reference/api-reference/interfaces/get Retrieve interface information with a Go HTTP client. This example shows how to set the Authorization header and read the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "http://localhost:8000/api/interfaces/id/" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Token ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Key Indicator Request Example Source: https://api.labelstud.io/api-reference/api-reference/prompts/indicators/get This example demonstrates how to retrieve a specific key indicator using its ID and indicator key. Ensure you include the Authorization header with your token. ```bash curl -X GET "http://localhost:8000/api/inference-runs/{id}/indicators/{indicator_key}" \ -H "Authorization: Token [your-token]" ``` -------------------------------- ### Create Project Request Example Source: https://api.labelstud.io/api-reference/api-reference/projects/create This example demonstrates how to make a POST request to create a project. Ensure you include the 'Content-Type: application/json' header and the necessary authorization token. ```bash curl http://localhost:8000/api/projects/ \ -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Token [your-token]" \ -d @create-project.json ``` -------------------------------- ### Get Organization Member using PHP Guzzle Source: https://api.labelstud.io/api-reference/api-reference/organizations/members/get Fetch organization member details via an HTTP GET request using the Guzzle HTTP client in PHP. This example requires the Guzzle library to be installed via Composer. ```php request('GET', 'http://localhost:8000/api/organizations/1/memberships/1/', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ``` -------------------------------- ### Get Finished Tasks Stats with PHP Source: https://api.labelstud.io/api-reference/api-reference/projects/stats/finished-tasks Fetch finished tasks statistics using Guzzle HTTP client in PHP. This example shows how to make a GET request with the authorization header. Make sure Guzzle is installed via Composer and replace '' with your token. ```php request('GET', 'http://localhost:8000/api/projects/1/stats/finished', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ``` -------------------------------- ### Fetch Compatible Projects (Go) Source: https://api.labelstud.io/api-reference/api-reference/prompts/compatible-projects This Go example demonstrates how to make an HTTP GET request to the compatible projects API, including the necessary Authorization header. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "http://localhost:8000/api/prompts/compatible-projects" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Token ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get User Review Score - PHP Guzzle Source: https://api.labelstud.io/api-reference/api-reference/projects/stats/user-review-score Fetch user review score using PHP with the Guzzle HTTP client. This example requires the GuzzleHttp library to be installed via Composer. ```php request('GET', 'http://localhost:8000/api/projects/1/user-stats/1/review_score', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ``` -------------------------------- ### Create Project from Template (Go) Source: https://api.labelstud.io/api-reference/api-reference/project-templates/create-project-from-template Use Go's net/http package to create a project from a template. This example demonstrates setting headers and reading the response. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "http://localhost:8000/api/project-templates/1/create-project" payload := strings.NewReader("{\n \"title\": \"string\",\n \"workspace_id\": 1\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Token ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Model Version Prediction Agreement (PHP) Source: https://api.labelstud.io/api-reference/api-reference/projects/stats/model-version-prediction-agreement Call the prediction agreement API using Guzzle HTTP client in PHP. This example includes setting up the client, making a GET request with the appropriate headers, and echoing the response body. Ensure Guzzle is installed via Composer. ```php request('GET', 'http://localhost:8000/api/projects/1/model-stats/model_version/prediction', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ``` -------------------------------- ### Create a Project using Label Studio SDK CLI Source: https://api.labelstud.io/api-reference/introduction/getting-started Create a new project via the CLI, providing parameters like title and label configuration. Use key=value pairs for generic parameters. ```bash export LABEL_STUDIO_API_KEY="YOUR_API_KEY" export LABEL_STUDIO_URL="YOUR_BASE_URL" # List projects label-studio-sdk projects list # Create a project (generic key=value params) label-studio-sdk projects create \ --param title="CLI Example" \ --param 'label_config=' ``` -------------------------------- ### List Prompts using Label Studio SDK (Python) Source: https://api.labelstud.io/api-reference/api-reference/prompts/list Demonstrates how to list prompts using the Python SDK. Initialize the client with your API key. ```python from label_studio_sdk import LabelStudio client = LabelStudio( api_key="YOUR_API_KEY_HERE", ) client.prompts.list() ``` -------------------------------- ### Get S3 Storage Configuration using PHP Source: https://api.labelstud.io/api-reference/api-reference/import-storage/s-3-s/get Fetch S3 storage configuration using Guzzle HTTP client in PHP. This example demonstrates making a GET request and setting the `Authorization` header. Ensure you have installed Guzzle via Composer and replaced `` with your actual API key. ```php request('GET', 'http://localhost:8000/api/storages/s3s/1', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ``` -------------------------------- ### List Views via HTTP Request (PHP) Source: https://api.labelstud.io/api-reference/api-reference/views/list This PHP example uses GuzzleHttp to send a GET request to the API endpoint for listing views. Ensure the GuzzleHttp library is installed via Composer. ```php request('GET', 'http://localhost:8000/api/dm/views/', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ``` -------------------------------- ### Get Project Details with Go Source: https://api.labelstud.io/api-reference/api-reference/projects/get Fetch project details using Go's standard HTTP client. This example shows how to make a GET request and read the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "http://localhost:8000/api/projects/1/" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Token ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Current User with PHP Guzzle Source: https://api.labelstud.io/api-reference/api-reference/users/get-current-user This PHP example utilizes the Guzzle HTTP client to retrieve current user information. Ensure you have Guzzle installed via Composer and replace the placeholder API key. ```php request('GET', 'http://localhost:8000/api/current-user', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ``` -------------------------------- ### Connect to Label Studio API with Python SDK Source: https://api.labelstud.io/api-reference/introduction/getting-started Import the SDK, define your Label Studio URL and API key, and then instantiate the client to connect to the API. This example also shows a basic request to verify the connection. ```python # Define the URL where Label Studio is accessible LABEL_STUDIO_URL = 'YOUR_BASE_URL' # API key is available at the Account & Settings page in Label Studio UI LABEL_STUDIO_API_KEY = 'YOUR_API_KEY' # Import the SDK and the client module from label_studio_sdk import LabelStudio # Connect to the Label Studio API client = LabelStudio(base_url=LABEL_STUDIO_URL, api_key=LABEL_STUDIO_API_KEY) # A basic request to verify connection is working me = client.users.whoami() print("username:", me.username) print("email:", me.email) ``` -------------------------------- ### Remove Project using PHP GuzzleHttp Source: https://api.labelstud.io/api-reference/api-reference/workspaces/projects/remove Use the GuzzleHttp client in PHP to send a DELETE request. This example requires the GuzzleHttp library to be installed via Composer and shows how to set headers and get the response body. ```php request('DELETE', 'http://localhost:8000/api/workspaces/1/projects/', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ``` -------------------------------- ### Create Project using JavaScript (Fetch API) Source: https://api.labelstud.io/api-reference/api-reference/projects/create This example demonstrates creating a project using the Fetch API in JavaScript. Remember to replace '' with your actual token. ```javascript const url = 'http://localhost:8000/api/projects/'; const options = { method: 'POST', headers: {Authorization: 'Token ', 'Content-Type': 'application/json'}, body: '{}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Create Project using Go Source: https://api.labelstud.io/api-reference/api-reference/projects/create Create a project using Go's standard HTTP client. Ensure the Authorization header includes your API token. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "http://localhost:8000/api/projects/" payload := strings.NewReader("{}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Token ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Interface API Example (Swift) Source: https://api.labelstud.io/api-reference/api-reference/interfaces/get Fetch interface details using Swift's URLSession. This example shows how to construct a GET request with the Authorization header. ```swift import Foundation let headers = ["Authorization": "Token "] let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8000/api/interfaces/id/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Create Task Request Example Source: https://api.labelstud.io/api-reference/api-reference/tasks/create This example demonstrates how to send a POST request to create a new task. Ensure you include the 'Content-Type: application/json' header and the task data in the request body. ```bash curl -X POST http://localhost:8000/api/tasks/ Content-Type: application/json { "data": { "image": "http://localhost:8000/data/upload/project1/image1.jpg" } } ``` -------------------------------- ### Get Interface API Example (Java) Source: https://api.labelstud.io/api-reference/api-reference/interfaces/get Retrieve interface details using the Unirest library in Java. This example shows how to configure the GET request with the necessary Authorization header. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("http://localhost:8000/api/interfaces/id/") .header("Authorization", "Token ") .asString(); ``` -------------------------------- ### SDK CLI - List Projects Source: https://api.labelstud.io/api-reference/introduction/getting-started This example shows how to use the Label Studio SDK CLI to list all available projects. Ensure you have set the `LABEL_STUDIO_URL` and `LABEL_STUDIO_API_KEY` environment variables. ```APIDOC ## SDK CLI - List Projects ### Description This command uses the Label Studio SDK's command-line interface to list all projects accessible via the API. It requires the `LABEL_STUDIO_URL` and `LABEL_STUDIO_API_KEY` to be set as environment variables. ### Method ```bash export LABEL_STUDIO_API_KEY="YOUR_API_KEY" export LABEL_STUDIO_URL="YOUR_BASE_URL" # List Projects label-studio-sdk projects list ``` ``` -------------------------------- ### Get Interface API Example (JavaScript) Source: https://api.labelstud.io/api-reference/api-reference/interfaces/get Fetch interface details using a direct HTTP GET request. This example uses the fetch API and requires your API key for authorization. ```javascript const url = 'http://localhost:8000/api/interfaces/id/'; const options = {method: 'GET', headers: {Authorization: 'Token '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Get Prediction by ID (Swift) Source: https://api.labelstud.io/api-reference/api-reference/predictions/get Fetch prediction information using an HTTP GET request in Swift. This example uses URLSession. ```swift import Foundation let headers = ["Authorization": "Token "] let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8000/api/predictions/1/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Go HTTP Example Source: https://api.labelstud.io/api-reference/api-reference/project-templates/create-project-from-template This Go code snippet shows how to make an HTTP POST request to create a project from a template, including setting authorization headers and the JSON payload. ```APIDOC ## create_project_from_template (Go HTTP Request) ### Description Utilizes Go's standard `net/http` package to send a POST request for creating a project from a template. ### Method POST ### Endpoint `http://localhost:8000/api/project-templates/1/create-project` ### Headers - **Authorization**: `Token ` - **Content-Type**: `application/json` ### Request Body ```json { "title": "string", "workspace_id": 1 } ``` ``` -------------------------------- ### Get Prediction by ID (Ruby) Source: https://api.labelstud.io/api-reference/api-reference/predictions/get Make an HTTP GET request to retrieve a prediction in Ruby. This example uses the Net::HTTP library. ```ruby require 'uri' require 'net/http' url = URI("http://localhost:8000/api/predictions/1/") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Get.new(url) request["Authorization"] = 'Token ' response = http.request(request) puts response.read_body ``` -------------------------------- ### API Key Authentication Example Source: https://api.labelstud.io/api-reference/api-reference/activity-logs/list Demonstrates how to authenticate API requests using a token. The token should be passed in the Authorization header. ```bash curl https://label-studio-host/api/projects -H "Authorization: Token [your-token]" ``` -------------------------------- ### List Tasks with Go Source: https://api.labelstud.io/api-reference/api-reference/tasks/list Example of listing tasks using Go's standard net/http package. Remember to replace '' with your actual API key. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "http://localhost:8000/api/tasks/" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Token ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Prediction by ID (JavaScript) Source: https://api.labelstud.io/api-reference/api-reference/predictions/get Fetch a prediction using a direct HTTP GET request in JavaScript. This example uses the fetch API. ```javascript const url = 'http://localhost:8000/api/predictions/1/'; const options = {method: 'GET', headers: {Authorization: 'Token '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Create Project from Template in Java Source: https://api.labelstud.io/api-reference/api-reference/project-templates/create-project-from-template This Java example demonstrates how to create a project from a template using the Unirest library. Remember to substitute `` with your valid API token. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("http://localhost:8000/api/project-templates/1/create-project") .header("Authorization", "Token ") .header("Content-Type", "application/json") .body("{\n \"title\": \"string\",\n \"workspace_id\": 1\n}") .asString(); ``` -------------------------------- ### Get State History (JavaScript Fetch API) Source: https://api.labelstud.io/api-reference/api-reference/states/state-history Make a GET request using the Fetch API in JavaScript to get the state history. This example shows how to set the URL, headers, and handle the response. ```javascript const url = 'http://localhost:8000/api/fsm/entities/entity_name/1/history'; const options = {method: 'GET', headers: {Authorization: 'Token '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Get Project Details (C#) Source: https://api.labelstud.io/api-reference/api-reference/projects/get Utilize the RestSharp library to perform a GET request to the projects API. This example demonstrates setting the Authorization header. ```csharp using RestSharp; var client = new RestClient("http://localhost:8000/api/projects/1/"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Token "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### List Files in Project (Go) Source: https://api.labelstud.io/api-reference/api-reference/files/list Retrieve a list of files for a project using Go's standard HTTP client. This example demonstrates setting the Authorization header and reading the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "http://localhost:8000/api/projects/1/file-uploads" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Token ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Task Details (Swift) Source: https://api.labelstud.io/api-reference/api-reference/tasks/get This Swift example uses URLSession to make a GET request for task details. The API key should be included in the Authorization header. ```swift import Foundation let headers = ["Authorization": "Token "] let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8000/api/tasks/id/")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Go HTTP Client Example Source: https://api.labelstud.io/api-reference/api-reference/projects/metrics/custom/check-function Demonstrates how to use Go's standard HTTP client to interact with the check_function API. Replace '' with your token. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "http://localhost:8000/api/projects/1/check-function" payload := strings.NewReader("{\n \"code\": \"string\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Token ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Refined Prompt - PHP Source: https://api.labelstud.io/api-reference/api-reference/prompts/versions/get-refined-prompt This PHP example uses Guzzle HTTP client to make a GET request. The API key should be passed in the Authorization header. ```php request('GET', 'http://localhost:8000/api/prompts/1/versions/1/refine', [ 'headers' => [ 'Authorization' => 'Token ', ], ]); echo $response->getBody(); ``` -------------------------------- ### Add Project using JavaScript Source: https://api.labelstud.io/api-reference/api-reference/workspaces/projects/add This example demonstrates how to add a project to a workspace using JavaScript's fetch API. Replace placeholders with your actual API key and URL. ```javascript const url = 'http://localhost:8000/api/workspaces/1/projects/'; const options = { method: 'POST', headers: {Authorization: 'Token ', 'Content-Type': 'application/json'}, body: '{"project":1}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### List Projects in Java Source: https://api.labelstud.io/api-reference/api-reference/projects/list An example using the Unirest library in Java to make a GET request. Replace `` with your authentication token. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("http://localhost:8000/api/projects/") .header("Authorization", "Token ") .asString(); ``` -------------------------------- ### Get SCIM Settings (C#) Source: https://api.labelstud.io/api-reference/api-reference/sso/scim/get Retrieve SCIM settings using the RestSharp library in C#. This example shows how to configure the GET request with the Authorization header. ```csharp using RestSharp; var client = new RestClient("http://localhost:8000/api/scim/settings"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Token "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get SCIM Settings (Java) Source: https://api.labelstud.io/api-reference/api-reference/sso/scim/get Retrieve SCIM settings using the Unirest library in Java. This example shows how to set the Authorization header for the GET request. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("http://localhost:8000/api/scim/settings") .header("Authorization", "Token ") .asString(); ``` -------------------------------- ### Sync Local Storage (Go) Source: https://api.labelstud.io/api-reference/api-reference/import-storage/local/sync Initiate a local storage synchronization via an HTTP POST request. This Go example demonstrates setting the authorization header and reading the response. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "http://localhost:8000/api/storages/localfiles/1/sync" req, _ := http.NewRequest("POST", url, nil) req.Header.Add("Authorization", "Token ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Prediction by ID (Go) Source: https://api.labelstud.io/api-reference/api-reference/predictions/get Retrieve prediction data using an HTTP GET request in Go. This example demonstrates basic http client usage. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "http://localhost:8000/api/predictions/1/" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Token ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### List Projects via HTTP GET Request (Go) Source: https://api.labelstud.io/api-reference/api-reference/workspaces/projects/list This Go program demonstrates how to fetch a list of projects from a workspace using an HTTP GET request. It includes reading the response body and printing it. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "http://localhost:8000/api/workspaces/1/projects/" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Token ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Workspace Details (Java Unirest) Source: https://api.labelstud.io/api-reference/api-reference/workspaces/get Example of fetching workspace data using the Java Unirest library. Demonstrates setting the Authorization header for the GET request. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("http://localhost:8000/api/workspaces/1/") .header("Authorization", "Token ") .asString(); ``` -------------------------------- ### Authenticate and List Project Members Source: https://api.labelstud.io/api-reference/api-reference/projects/members/paginated/list This example shows how to authenticate with the API using a token and retrieve a paginated list of project members. Ensure your token is correctly formatted and included in the Authorization header. ```bash curl \ https://label-studio-host/api/projects \ -H "Authorization: Token [your-token]" ``` -------------------------------- ### Get API Version (Java Unirest) Source: https://api.labelstud.io/api-reference/api-reference/versions/get This Java example uses the Unirest library to make a GET request for the API version. Replace '' with your authentication token. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("http://localhost:8000/api/version/") .header("Authorization", "Token ") .asString(); ``` -------------------------------- ### Example API Request with Authorization Source: https://api.labelstud.io/api-reference/api-reference/users/list Demonstrates how to make a GET request to list users, including the required Authorization header. The token can be found on the User Account page. ```bash curl http://localhost:8000/api/users/ ``` -------------------------------- ### API Token Authentication Example Source: https://api.labelstud.io/api-reference/api-reference/import-storage/azure-spi/sync Demonstrates how to authenticate API requests using a token. The token must be passed as an 'Authorization' header. ```bash curl https://label-studio-host/api/projects -H "Authorization: Token [your-token]" ``` -------------------------------- ### Get Task Details (JavaScript) Source: https://api.labelstud.io/api-reference/api-reference/tasks/get Fetch task details using a GET request in JavaScript. This example uses the fetch API and requires your API key for authentication. ```javascript const url = 'http://localhost:8000/api/tasks/id/'; const options = {method: 'GET', headers: {Authorization: 'Token '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Example API Request with Authorization Header Source: https://api.labelstud.io/api-reference/api-reference/organizations/members/list Demonstrates how to make a request to the API, including the required Authorization header with a user token. ```bash curl https://label-studio-host/api/projects -H "Authorization: Token [your-token]" ``` -------------------------------- ### Get Session Policy with C# (RestSharp) Source: https://api.labelstud.io/api-reference/api-reference/session-policy/get Use the RestSharp library in C# to retrieve the session policy. This example shows how to configure the client and execute a GET request. ```csharp using RestSharp; var client = new RestClient("http://localhost:8000/api/session-policy/"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Token "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Get Prompt Subsets with C# (RestSharp) Source: https://api.labelstud.io/api-reference/api-reference/prompts/subsets This C# example uses the RestSharp library to make a GET request for prompt subsets, including setting the Authorization header. ```csharp using RestSharp; var client = new RestClient("http://localhost:8000/api/projects/1/subsets"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Token "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Create Project using Java (Unirest) Source: https://api.labelstud.io/api-reference/api-reference/projects/create Example of creating a project using the Unirest library in Java. Ensure the Authorization header contains your API token. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("http://localhost:8000/api/projects/") .header("Authorization", "Token ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` -------------------------------- ### Python SDK Connection Example Source: https://api.labelstud.io/api-reference/introduction/getting-started This snippet shows how to import the Label Studio SDK, define your Label Studio URL and API key, and connect to the API. It also includes a basic request to verify the connection by fetching the current user's information. ```APIDOC ## Python SDK Connection Example ### Description This example demonstrates how to establish a connection to the Label Studio API using the Python SDK. It covers setting up the necessary credentials (URL and API key) and performing a simple API call to confirm the connection is active. ### Method ```python # Define the URL where Label Studio is accessible LABEL_STUDIO_URL = 'YOUR_BASE_URL' # API key is available at the Account & Settings page in Label Studio UI LABEL_STUDIO_API_KEY = 'YOUR_API_KEY' # Import the SDK and the client module from label_studio_sdk import LabelStudio # Connect to the Label Studio API client = LabelStudio(base_url=LABEL_STUDIO_URL, api_key=LABEL_STUDIO_API_KEY) # A basic request to verify connection is working me = client.users.whoami() print("username:", me.username) print("email:", me.email) ``` ### Environment Variables Alternatively, you can set `LABEL_STUDIO_URL` and `LABEL_STUDIO_API_KEY` as environment variables: ```bash export LABEL_STUDIO_API_KEY="YOUR_API_KEY" export LABEL_STUDIO_URL="YOUR_BASE_URL" ``` ``` -------------------------------- ### Get Project Roles (Java Unirest) Source: https://api.labelstud.io/api-reference/api-reference/projects/roles/get Use the Unirest library in Java to make a GET request for project roles. This example shows how to set the Authorization header. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("http://localhost:8000/api/projects/1/roles") .header("Authorization", "Token ") .asString(); ``` -------------------------------- ### Get Project Details with Java (Unirest) Source: https://api.labelstud.io/api-reference/api-reference/projects/get Fetch project details using the Unirest library in Java. This example shows a simple GET request with an authorization header. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("http://localhost:8000/api/projects/1/") .header("Authorization", "Token ") .asString(); ```