Transifex

  • Documentation
  • API
  • Introduction to the Transifex API

Introduction to the Transifex API

Transifex offers an extensive API that's designed to expose as much of Transifex's functionality as possible and make it easy to integrate Transifex with your existing tools. The API calls are REST compliant and make use of the most common HTTP methods such as GET, POST, PUT, and DELETE. The API is also used by the Transifex Client.

You'll find the main entities in the API in the left menu. Every project has a source language and a set of files (resources). For software projects, the source language is the language used in the source code. Each resource in turn consists of the source file, that is, the internationalization file with the translatable strings in the source language and the translations of the strings.

Base URL for API calls

All API calls should use the following URL prefix:

https://www.transifex.com/api/2/

Authentication

Transifex requires all requests to the API to be authenticated through HTTP Basic Auth. The credentials to access the API are the same as the username and password you use to log into Transifex. Alternatively, you can also use an API token instead of your password. When using a token, the username field should be set to "api" and not your username.

To get your API token:

  • Head to your User Settings by going to the main navigation, and clicking on your profile image in the top right corner. 

  • In the left menu, click on API token.

  • Click Generate a token.

Once you've generated a token, you can edit its name so it's easier to remember where you use the token.

To keep your API token secure, we'll only show it once, so please be sure to save it somewhere secure. In case you lose your API token, you can regenerate a new one at any time. However, when you regenerate a new token, you'll need to update your applications and replace the old token with the new one.

If you signed up for Transifex using social login, i.e. GitHub, Google, or LinkedIn, then your Transifex account won’t have a password associated with it by default. You can generate or change your password through your account settings page.

Access control for API tokens

Transifex supports multiple API tokens per user (you can see in your API tokens page here). Transifex generates an API label accompanied by an incremental number: API token 1, API token 2, etc. 

After the API token is created, you can update this label in the "Edit API token" popup. This way you can define different usage per token and update it accordingly depending on the service that this token is being used for. 

If you want to revoke access, then the corresponding token can be deleted without affecting the other services that are also connected with this account.

In case you want to restrict access, you can create a generic user for a group of services/projects and generate multiple tokens for this account. If you want to prevent certain users from deleting a project, then those users should not be an administrator or project maintainer of the project.

Please also note that there is no limit in the number of users that can use the same Transifex account; however, there is an API rate limit per account. So, if many services use the same Transifex account, this limit might be reached more frequently.

Basic API usage

You can use a variety of desktop or web-based tools to test the API. A quick way to do it is through the command-line tool cURL.

Here's a list of the most useful options for cURL:

  • --user username:password: Give your username and your password (if your password contains special characters enclose it with apostrophe 'password').
  • -L: Follow HTTP redirections.
  • -i: Show response headers.
  • -X <METHOD>: Specify a HTTP method to use (GET, POST, PUT, DELETE).
  • -d: Pass in parameters enclosed in quotes; multiple parameters are separated by '&'.
  • -H: Add any extra headers.

Examples

GET

$ curl -i -L --user api:<token> -X GET https://www.transifex.com/api/2/projects/

POST

$ curl -i -L --user api:<token> -X POST \
-d '{"slug":"foo","name":"Foo","source_language_code":"en","description":"Description"}' \
-H "Content-Type: application/json" https://www.transifex.com/api/2/projects/

PUT

$ curl -i -L --user api:<token> -X PUT -d '{"name":"Foo2"}' \
-H "Content-Type: application/json" https://www.transifex.com/api/2/project/foo/

DELETE

$ curl -i -L --user api:<token> -X DELETE \
https://www.transifex.com/api/2/project/foo/

Heads up!

The trailing slash in the URLs is necessary to avoid any redirects, especially for POST requests.

Terminology

Here are a few key terms to keep in mind:

  • Slug: A small string in the URL of a project or resource. Only alphanumeric characters, underscores _, and dashes - are allowed in the slug.
  • Source language: The language you are translating from. For a software program, this is the language strings in the source code is in.
  • i18n type: The format used in a resource for internationalization (i18n). For example, PO, TS, PROPERTIES, etc. Transifex supports over 25 file formats.

API rate limits

To maintain optimal performance for our API and ensure its available to all our customers, we limit the request rate to 6,000 requests/hour. Once past that limit, requests will be throttled and you will get a 429 error code. 

HTTP/1.1 429 TOO MANY REQUESTS
Server: nginx/1.12.2
Date: Mon, 21 May 2018 11:07:19 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
X-Transifex-User: kchris25
Content-Language: en
Expires: Mon, 21 May 2018 11:07:19 GMT
Vary: Authorization, Host, Accept-Language, Cookie
Retry-After: 439
Last-Modified: Mon, 21 May 2018 11:07:19 GMT
Cache-Control: max-age=0
X-Frame-Options: SAMEORIGIN

Throttled, wait 439 seconds.%

After one hour, you’ll be able to make API requests again at the normal rate.