API V1 · Context Images
Create context image
curl --request POST \ --url https://api.lingohub.com/v1/WORKSPACE_URL/projects/PROJECT_URL/contextImages \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: multipart/form-data' \ --form file=@translations.jsonimport requests
url = "https://api.lingohub.com/v1/WORKSPACE_URL/projects/PROJECT_URL/contextImages"
files = { "file": "open('translations.json', 'rb')" }headers = {"Authorization": "Bearer YOUR_API_KEY"}
response = requests.post(url, files=files, headers=headers)
print(response.json())const url = 'https://api.lingohub.com/v1/WORKSPACE_URL/projects/PROJECT_URL/contextImages';const form = new FormData();form.append('file', 'translations.json');
const options = {method: 'POST', headers: {Authorization: 'Bearer YOUR_API_KEY'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://api.lingohub.com/v1/WORKSPACE_URL/projects/PROJECT_URL/contextImages"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"translations.json\"\r\nContent-Type: application/json\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"translations.json\"\r\nContent-Type: application/json\r\n\r\n\r\n-----011000010111000001101001--\r\n");Request request = new Request.Builder() .url("https://api.lingohub.com/v1/WORKSPACE_URL/projects/PROJECT_URL/contextImages") .post(body) .addHeader("Authorization", "Bearer YOUR_API_KEY") .build();
Response response = client.newCall(request).execute();<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.lingohub.com/v1/WORKSPACE_URL/projects/PROJECT_URL/contextImages', [ 'multipart' => [ [ 'name' => 'file', 'filename' => 'translations.json', 'contents' => null, 'headers' => [ 'Content-Type' => 'application/json' ] ] ] 'headers' => [ 'Authorization' => 'Bearer YOUR_API_KEY', ],]);
echo $response->getBody();require 'uri'require 'net/http'
url = URI("https://api.lingohub.com/v1/WORKSPACE_URL/projects/PROJECT_URL/contextImages")
http = Net::HTTP.new(url.host, url.port)http.use_ssl = true
request = Net::HTTP::Post.new(url)request["Authorization"] = 'Bearer YOUR_API_KEY'request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"translations.json\"\r\nContent-Type: application/json\r\n\r\n\r\n-----011000010111000001101001--\r\n"
response = http.request(request)puts response.read_bodyusing System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://api.lingohub.com/v1/WORKSPACE_URL/projects/PROJECT_URL/contextImages"), Headers = { { "Authorization", "Bearer YOUR_API_KEY" }, }, Content = new MultipartFormDataContent { new StringContent("") { Headers = { ContentType = new MediaTypeHeaderValue("application/json"), ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "file", FileName = "translations.json", } } }, },};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}Creates and optionally connects context images to text segments.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”WorkspaceUrl
ProjectUrl
Request Body
Section titled “Request Body”object
Defines how to create and connect the context image
object
Determines how the context image will be connected to text segments:
- KEY_BASED: Explicitly connect to segments identified by their file path and key
- TEXT_BASED: Connect to segments by matching the exact text content
- IMAGE_BASED: Use OCR text detection to automatically find and connect matching text on the image
Optional description providing context about what the image shows
Example
Screenshot of the settings page showing the language dropdownThe ISO 639-1 language code (with optional regional variant) of the text segments this image relates to
Example
deWhen true, automatically accepts and connects OCR-detected text suggestions. Only applicable when connectType is IMAGE_BASED. When false, suggestions are created but require manual review.
List of text segments to connect with their corresponding highlight box positions on the image. Required with at least one entry for KEY_BASED and TEXT_BASED connection types. Can be omitted or null for IMAGE_BASED when auto-connecting via OCR.
Represents a single text segment connection to a context image with its location on the image
object
The file path and key identifying the source text segment. Required for KEY_BASED connections. For TEXT_BASED connections, use the ‘text’ field instead.
Identifies a text segment by its source file location and unique key
object
The relative file path from the project root to the resource file containing the text. Example: ‘res/values/strings.xml’ or ‘i18n/en.json’
Example
resources/translations.jsonThe unique key identifier for the text within the resource file
Example
home.welcome_messageThe actual text content of the segment to match. Used for TEXT_BASED connections or as a reference for KEY_BASED connections. This text helps translators understand the context of the segment.
Example
Hello, welcome to our application!The rectangular region on the image that highlights where the text appears. Used to visually indicate which part of the image the text relates to. Coordinates are in pixels, with (0,0) being the top-left corner of the image.
Defines a rectangular highlight box on the context image. Used to visually indicate where specific text appears on the image. All coordinates are in pixels relative to the top-left corner (0,0) of the image.
object
The horizontal pixel coordinate of the left edge of the highlight box
Example
150The vertical pixel coordinate of the top edge of the highlight box
Example
200The width in pixels of the highlight box
Example
120The height in pixels of the highlight box
Example
40Responses
Section titled “Responses”OK
Response object containing details of a context image including its connection status and metadata
object
The unique identifier of the context image in the format ‘ci_<encrypted_id>’
Example
ci_18USq6822XIv-19847171The original filename of the uploaded context image
Optional user-provided description of the context image
Example
Screenshot of the main dashboard showing the navigation menuThe full URL to view the context image via Cloudflare Images CDN
The title of the project this context image belongs to
The ISO 639-1 language code (with optional regional variant) this context image is associated with
Example
enThe count of text segments that are definitively connected to this context image
The count of text segment connection suggestions pending review
The source channel through which the context image was uploaded
The current upload processing status of the image
The current status of the OCR text detection process
The timestamp when the context image was originally uploaded
The timestamp when the context image was last updated