Get Translation Task Status
Monitor the progress of your translation tasks with real-time status updates, enabling you to track completion and retrieve translated content when ready.
This endpoint serves as your window into the translation process, allowing you to monitor the status of tasks you’ve submitted through the /translate
endpoint. By providing the unique task_id
you received when initiating a translation, you can check whether your translation is still being processed, has completed successfully, or encountered an issue. When translation is complete, this endpoint also delivers your translated text.
Understanding the Translation Lifecycle
When you submit a translation request, it goes through several stages before completion. This endpoint keeps you informed about which stage your task has reached:
Status Types
The status
field in the response will contain one of these values:
-
PENDING
: Your translation is currently in the processing queue or actively being translated. This indicates that everything is working as expected, but the translation is not yet complete. Continue polling at reasonable intervals. -
SUCCESS
: The translation process has completed successfully. When you receive this status, yourrun_id
is returned which the identifier that you would use to fetch your translations by using the/translation-result/{run_id}
-
ERROR
: Something went wrong during the translation process. This could be due to invalid input parameters, server issues, or problems with the translation engine. The response may include additional details about the nature of the error. -
TIMEOUT
: The translation task exceeded the maximum allowed processing time. This typically happens with extremely large translation requests or during periods of high system load. Consider breaking your request into smaller batches. -
PAYMENT_REQUIRED
: Your account does not have sufficient credits or permissions to complete this translation. Please check your subscription status or contact support for assistance.
Recommended Polling Strategy
Asynchronous operations like translation require a thoughtful approach to status checking:
- Start with short intervals: Initially check every 1-2 seconds for very short translations
- Use exponential backoff: Gradually increase the time between checks (e.g., doubling the wait time after each check)
- Set a maximum interval: Don’t let the wait time grow beyond 10-15 seconds
- Implement a timeout: Establish a maximum total wait time for your application
This approach balances responsiveness with server efficiency, ensuring you get your translations promptly without overloading the system with unnecessary requests.
Example: Monitoring Translation Progress
Here’s how you might implement status checking for a translation task:
This function demonstrates a robust implementation of status polling with several key features:
- Exponential backoff: The wait time between requests starts small and gradually increases, which is efficient for both short and long-running tasks
- Multiple status handling: Each possible status value is handled appropriately
- Error reporting: Meaningful error messages help diagnose issues
- Progress tracking: The elapsed time is displayed to keep users informed
- Timeout protection: Both client-side and server-side timeouts are accounted for
By implementing a similar approach in your application, you can create a responsive user experience that keeps users informed about translation progress while efficiently managing system resources.
When to Stop Polling
You should stop polling when you receive one of these definitive statuses:
SUCCESS
: You’ve received your translationsERROR
: The task failed and won’t recoverTIMEOUT
: The server timed out the requestPAYMENT_REQUIRED
: Payment issues need to be resolved
Only the PENDING
status indicates that you should continue polling.
With this endpoint, you gain visibility into the translation process, allowing your application to respond appropriately based on real-time status information and retrieve completed translations as soon as they’re available.
Authorizations
The x-api-key
is a custom header required for authenticating requests to our API. Include this header in your request with the appropriate API key value to securely access our endpoints. You can find your API key(s) in the 'API' section of our studio website.
Path Parameters
This parameter represents a unique identifier for a task. It is used in various API endpoints to query the status or result of a specific task. The task_id
is typically returned when a task is created.
Response
Successful Response
The response is of type object
.