API: Read translations

Last updated: February 09, 2024Author: Jakub Pomykała

This is split into two sections, Translation Hosting and REST API. The CDN offers free, fast and public access to your translations, it can be used in client-side application. API offers filter and query options, and uses your API Key which can be used also for modifying translations, so it should be used only in server-side applications and integrations.

Table of contents

Translation Hosting

Translation Hosting is a content-delivery network (CDN), it's a fast and safe to share the link to the public. It's not rate-limited, so you don't have to worry about the number of requests. You can use it safely in client-side applications. Fetching data from Translation Hosting is available in all pricing plans including the Community plan.

Parameters

  • projectToken - your project token which can be found in the 'Integrations > Project credentials' tab,
  • languageKey - language key from the 'Languages' tab, e.g.: en, pl, de,
  • environment - environment name, _latest or _production,
  • namespace - namespace, e.g.: common, home, auth,
  • customerId - customerId used for customer-specific translations, e.g.: ikea, adidas.

Get all translations

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/_index

Example response

{
  "de": {
    "SALE": "Verkauf",
    "ADDRESS": "Adresse"
  },
  "fr": {
    "SALE": "soldes",
    "ADDRESS": "adresse"
  }
}

Get translations by language key

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/{languageKey}

Example response

{
  "SALE": "Verkauf",
  "ADDRESS": "Adresse"
}

Get languages

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/_languages

Example response

[
   {
      "key": "de",
      "name": "Deutsch",
      "isDefault": false,
      "icon": "de"
   },
   {
      "key": "en",
      "name": "English",
      "isDefault": false,
      "icon": "gb"
   },
   {
      "key": "es",
      "name": "Español",
      "isDefault": false,
      "icon": "es"
   }
]

See blog post about hosted country flags and learn how to use icon values to show flags in your app.

Get translations by language key and namespace

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/{languageKey}/{namespace}

Example response

{
  "SALE": "Verkauf",
  "ADDRESS": "Adresse"
}

Get translations by language key, namespace and customerId

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/{languageKey}_{customerId}/{namespace}

Example response

{
  "SALE": "Verkauf",
  "ADDRESS": "Adresse"
}

Get customers

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/_customers

Example response

[
   {
      "key": "ikea",
      "name": "IKEA"
   },
   {
      "key": "adidas",
      "name": "Adidas"
   }
]

Get customer-specific translations

GET
https://cdn.simplelocalize.io
/{projectToken}/{environment}/{languageKey}_{customerId}

Example response

{
  "SALE": "Verkauf",
  "ADDRESS": "Adresse"
}

REST API

This section is about using REST API to fetch translations. It's possible to use it in server-side applications and integrations. If you are using this endpoint, the authorization is required. Add API Key for your project as a X-SimpleLocalize-Token request header.

Please note that the API Access is rate-limited, and you should not use it to fetch translations for every end-user nor use it in client-side applications. Use Translation Hosting instead.

Search translations

GET
https://api.simplelocalize.io
/api/v2/translations

Available query parameters

Query parameterDescription
textquery for translated text, uses 'contains with ignore case'
textStatussearch for empty or not empty translations, allowed values: EMPTY, NOT_EMPTY
reviewsStatusfilter by review status, allowed values: REVIEWED, NOT_REVIEWED
keyfilter by given translation key, uses 'equals'
namespacefilter by given translation namespace, uses 'equals'
languagefilter by given language key, uses 'equals'
customerIdfilter by given customer id, uses 'equals'; see customer-specific translations
pagepage for pagination
sizesize for pagination, max size: 500

Sample request

GET
https://api.simplelocalize.io
/api/v2/translations?language=en&key=HELLO_WORLD

Response

{
    "msg": "OK",
    "status": 200,
    "data":  [
            {
                "key": "HELLO_WORLD",
                "namespace": "common",
                "language": "en",
                "text": "Hello world!",
                "reviewStatus": "REVIEWED",
                "lastModifiedAt": "2021-01-01T00:00:00.000Z"
            }
        ]
}