API
This is our application programming interface (API).
Do you prefer to integrate the locize api on your own?
No problem! If you want to make a low level integration or just did not found an appropriate client library here you find our simple api description or you can access API via:
Fetch namespace resources
The most important feature first!
It's a simple HTTP GET request with this url pattern:
https://api.locize.app/{projectId}/{version}/{language}/{namespace}
example:
(You can find your projectId in your project settings under the API Tab.)
Each of these requests counts as download for your next invoice.
Fetch private namespace resources
Some projects have a higher demand for privacy. To accomplish this, you can set your versions to publish in private mode which means you will need an API key to fetch your namespace resources.
It's a simple HTTP GET request with this url pattern:
https://api.locize.app/private/{projectId}/{version}/{language}/{namespace}
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
Each of these requests counts as private download for your next invoice.
Fetch the available languages
You have the possibility to ask locize which languages are available for a particular project. That way you can have a dynamic language selector.
It's an even simpler HTTP GET request with this url pattern:
https://api.locize.app/languages/{projectId}
example:
Advice:
This request has a minimum cache duration of 1 hour.
(You can find your projectId in your project settings under the API Tab.)
Missing translations
You can say to locize that some translations are missing. For example this is very useful in development. This will not replace an existing translation.
This is a little bit more advanced. It's a HTTP POST request with this url pattern:
https://api.locize.app/missing/{projectId}/{version}/{language}/{namespace}
example:
optional context:
In case you want to also save a context information for a specific translation, you can define a nested object like this:
optional tags:
In case you want to also save tags for a specific translation, you can define a nested object like this:
Advice:
Translations not defined in your reference language will not be shown in the locize app.
You should post missing translation to the reference language first!
If you send more than 1000 keys, you have to page your request. This means you have to create multiple requests and send a maximum of 1000 keys per request.
If you get a 412 status code, this means it was an unnecessary request and nothing was missing. If the publishing mode for the requested version is set to manual, you may want to set it to auto publish.
(You can find your projectId and API Key in your project settings under the API Tab.)
You should not use this endpoint in production. Read this guide before you're going to production.
Used translations
You can say to locize which translations are used. Locize will then remember at which time the translations have been last used. For example this is very useful in development. For example during an e2e test you can spot which translations are probably not used anymore.
This is also a HTTP POST request, with this url pattern:
https://api.locize.app/used/{projectId}/{version}/{language}/{namespace}
example:
Advice:
To best work with the "not used for" filter in the UI, you may do this requests for your reference language.
If you send more than 1000 keys, you have to page your request. This means you have to create multiple requests and send a maximum of 1000 keys per request.
(You can find your projectId and API Key in your project settings under the API Tab.)
You should not use this endpoint in production. Read this guide before you're going to production.
Update/Remove translations
You can say to locize that some translations should be updated or deleted. For example this is very useful for an integration from an other already existing system to slowly transition the translations to locize.
This is also a little bit more advanced. It's a HTTP POST request with this url pattern:
https://api.locize.app/update/{projectId}/{version}/{language}/{namespace}
To completely replace a namespace set the query parameter replace
to true. This will remove all the keys in that namespace that are not included in your body. If you have more than 1000 keys in a namespace, we do consider NOT to use the replace
parameter, this will probably delete more keys than you want to.
If you need to change or remove multiple keys, please do not create a single http request per key, but put them together in batches of maximum 1000 keys.
example:
optional context:
In case you want to also save a context information for a specific translation, you can define a nested object like this:
optional tags:
In case you want to also save tags for a specific translation, you can define a nested object like this:
optional review:
In case you want to use the review workflow and enabled it, you can add the ?review=true
query parameter:
This will create a new review:
Advice:
Translations not defined in your reference language will not be shown in the locize app.
You should post translation to the reference language first!
If you send more than 1000 keys, you have to page your request. This means you have to create multiple requests and send a maximum of 1000 keys per request. If this is the case, please do not use the
replace
query parameter.Do NOT create a single request per individual key, but include up to 1000 keys in a single request.
If you get a 429 status code, this means you are sending too many requests for the same namespace and should slow down to send requests and/or make sure you're NOT creating a single request per key.
If you get a 412 status code, this means it was an unnecessary request and nothing did change. If the publishing mode for the requested version is set to manual, you may want to set it to auto publish.
Do not use the review option in combination with the replace option.
(You can find your projectId and API Key in your project settings under the API Tab.)
You should not use this endpoint in production. Read this guide before you're going to production.
List all namespace resources
If you need an overview of all published translation files of your project, you can do this with a simple HTTP GET request with this url pattern:
https://api.locize.app/download/{projectId}/{version}/{language}/{namespace}
{namespace}, {language} and {version} are optional and are used as filter.
example:
Advice:
By providing the appropriate API key as bearer token you can also retrieve information about your private namespace resources. (if using the private publishing feature)
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
You should not use this endpoint in production.
If you need to know the lastModified timestamp of a specific namespace, you should parse the last-modified
header in the Fetch namespace resources response.
Fetch/filter the (unpublished) namespace resources
Sometimes in your localization process you want to know which are the translations that are approved by your reviewer. Assuming you have defined some tags to mark translations as approved, with this api you're able to filter by these tags.
This is pretty easy. It's a simple HTTP GET request with this url pattern:
https://api.locize.app/pull/{projectId}/{version}/{language}/{namespace}
with positive tags filter: https://api.locize.app/pull/{projectId}/{version}/{language}/{namespace}?tags=[0,2]
(you need to pass the tag index)
in combination with a negative tags filter: https://api.locize.app/pull/{projectId}/{version}/{language}/{namespace}?tags=[0,2]&!tags=[1]
Another use case could be to track the amount of words changed during a time period. To do this, you can pull the translations at period 1, save this state and the current timestamp and later at period 2 you can pull again with an additional filter.
i.e. get all translations updated after 2017-12-06T19:42:18.139Z (UTC): https://api.locize.app/pull/{projectId}/{version}/{language}/{namespace}?updatedAt=>1512589338139
(number of milliseconds since 1970/01/01)
i.e. get all translations updated before 2017-12-06T19:42:18.139Z (UTC): https://api.locize.app/pull/{projectId}/{version}/{language}/{namespace}?updatedAt=<1512589338139
In the same way there is also the createdAt
filter.
Additionally another use case could be to remove unused translations. (This is only possible if you make use of the Used translations endpoint) To do this, you can pull the translations with an additional filter.
i.e. get all translations used after 2017-12-06T19:42:18.139Z (UTC): https://api.locize.app/pull/{projectId}/{version}/{language}/{namespace}?lastUsed=>1512589338139
(number of milliseconds since 1970/01/01)
i.e. get all translations used before 2017-12-06T19:42:18.139Z (UTC): https://api.locize.app/pull/{projectId}/{version}/{language}/{namespace}?lastUsed=<1512589338139
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
There is also an option to ask for more segment information with the query parameter raw=true
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
You should not use this endpoint in production. To fetch the translation in production, please use the Fetch namespaces resources endpoint.
Each of these requests counts as private download for your next invoice.
Fetch configured project tags
You may have defined some tags to mark translations as approved, etc. With this api you're able to fetch these tags.
A very simple HTTP GET request with this url pattern:
https://api.locize.app/tags/{projectId}
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
Versioning
Copy version
If you are using multiple versions of your translations you can ask locize to copy (replace) all translations from one version to the other. For example this is very useful when you release your translation files from one version to the other via your custom tooling. It's the same behavior like Overwriting via the UI.
This is easy. It's a HTTP POST request without body with this url pattern:
https://api.locize.app/copy/{projectId}/version/{fromVersion}/{toVersion}
example:
Hint:
The response body contains a jobId, which you can use to check if asynchronous action has been completed with the Get async job endpoint.
(You can find your projectId and API Key in your project settings under the API Tab. Keep in mind to use the API Key for {toVersion}
)
Copy language from version to other version
For a more granular copy action, you can ask locize to copy (replace) all translations from one version to the other for a particular language.
Another HTTP POST request without body with this url pattern:
https://api.locize.app/copy/{projectId}/version/{fromVersion}/{toVersion}/{language}
example:
Hint:
The response body contains a jobId, which you can use to check if asynchronous action has been completed with the Get async job endpoint.
(You can find your projectId and API Key in your project settings under the API Tab. Keep in mind to use the API Key for {toVersion}
)
Publish version
If you want to fully automate your CI/CD pipeline by publishing a version exactly at the same time when you deploy a new version of your product this api call is exactly what you are looking for.
This is very easy. It's a HTTP POST request without body with this url pattern:
https://api.locize.app/publish/{projectId}/{version}
example:
Hint:
The response body contains a jobId, which you can use to check if asynchronous action has been completed with the Get async job endpoint.
(You can find your projectId and API Key in your project settings under the API Tab. Keep in mind to use the API Key for the correct {version}
)
Get async job
To wait for an async action (i.e. copy, copy language, publish) to be completed, you can make use this endpoint.
It's a simple HTTP GET request without body with this url pattern:
https://api.locize.app/jobs/{projectId}/{jobId}
Pull this endpoint with an interval of at least 2 seconds until no job object is returned anymore. The job is done as soon as no job object is returned. Depending on how big your project is it may take also several minutes until the job gets finished. (for example for the copy version job)
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
Sometimes you want to automate even more. I.e if you want to create your own translation management ui. The following endpoints are probably what you are looking for.
Create a new namespace
https://api.locize.app/create/{projectId}/{version}/{namespace}
A body containing initial values is optional.
It will create a new namespace in your reference language.
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
Create a new namespace in a specific language
https://api.locize.app/create/{projectId}/{version}/{language}/{namespace}
A body containing initial values is optional.
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
Rename a namespace in all languages
https://api.locize.app/rename/{projectId}/{version}/{fromNamespace}/{toNamespace}
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
Delete a namespace from all languages
https://api.locize.app/delete/{projectId}/{version}/{namespace}
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
Language functionality
Add new language
This is the same as adding a new language via UI.
https://api.locize.app/language/{projectId}/{language}
example (will add that language to all versions):
Optionally, specify in which versions you want to add that language:
(You can find your projectId and API Key (requires admin role) in your project settings under the API Tab.)
Remove language
https://api.locize.app/language/{projectId}/{language}
example:
Optionally, specify in which versions you want to update languages:
(You can find your projectId and API Key (requires admin role) in your project settings under the API Tab.)
Update languages
Can be used to set the languages at once.
Languages not passed via request, are removed.
https://api.locize.app/language/{projectId}
example:
Optionally, specify in which versions you want to update languages:
(You can find your projectId and API Key (requires admin role) in your project settings under the API Tab.)
Add new version
This is the same as adding a new version via UI.
https://api.locize.app/version/{projectId}/{version}
The body optionally contains
autoPublish
true
orfalse
, defaults tofalse
cacheControlMaxAge
number
, amount of seconds used for Cache-control max-age
example:
(You can find your projectId and API Key (requires admin role) in your project settings under the API Tab.)
Users
Invite new users
https://api.locize.app/invite/{projectId}
The body contains
email the user's email address
role can be
"user"
or"publisher"
or"admin"
(default:"user"
)scope is an object describing a scope restriction (default: empty arrays for languages and versions)
To skip sending the email automatically set the query parameter send
to false. This will not send any email. This way you can send the invitation mail by your own, if you want to.
example:
(You can find your projectId and API Key (requires admin role) in your project settings under the API Tab.)
Fetch users
For example when you want to build your own translation management ui, this endpoint will be very useful if you want to display the project's users.
Just a HTTP GET request with this url pattern:
https://api.locize.app/users/{projectId}
example:
(You can find your projectId and API Key (requires admin role) in your project settings under the API Tab.)
Statistics
Statistics: project
Do you want to show some cool overview images like this:
You can access the same data we use on the locize UI also for your own ui.
Simply make a HTTP GET request with this url pattern:
https://api.locize.app/stats/project/{projectId}
example:
(You can find your projectId and API Key in your project settings under the API Tab.)
Statistics: user
There are some nice statistics for users too:
Another HTTP GET request with this url pattern:
for a specific user: https://api.locize.app/stats/user/{projectId}/{userId}
https://api.locize.app/stats/user/{projectId}/{userId}?year=2019
or for all users: https://api.locize.app/stats/users/{projectId}
https://api.locize.app/stats/users/{projectId}?year=2019
To retrieve an other year than the current one set the query parameter year
with the appropriate value.
example:
(You can find your projectId and API Key (requires admin role) in your project settings under the API Tab.)
Tenant functionality
Create a new tenant project
https://api.locize.app/tenant/create/{projectId}
The body contains
name the project's name (required)
company the company name of the tenant
projectUrl an url that represents the tenant project
canEditLanguages defines if the tenant user can add or remove languages, can be
true
orfalse
(default:false
)subscribeToParent adds the tenant project to the collective billing of the main/parent project (1 invoice for everything), can be
true
orfalse
(default:false
)referenceLanguage you can optionally pass a different reference language compared to the parent project, if not provided the same referenceLanguage like in the parent project is used
This response will include the id, that can be used other api endpoints.
example:
(You can find your projectId and API Key (requires admin role) in your project settings under the API Tab.)
Update tenant project settings
https://api.locize.app/tenant/update/{projectId}/{tenantProjectId}
The body contains
canEditLanguages can be
true
orfalse
(default:false
)
This response will include the id, that can be used other api endpoints.
example:
(You can find your projectId and API Key (requires admin role) in your project settings under the API Tab.)
List all tenants of project
https://api.locize.app/tenants/{projectId}
example:
(You can find your projectId and API Key (requires admin role) in your project settings under the API Tab.)
Last updated