API: Read translations

Last modified: February 27, 2023Author: 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"
   },
   {
      "key": "en",
      "name": "English"
   },
   {
      "key": "es",
      "name": "Español"
   }
]

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/v1/translations

Available query parameters

Query parameterDescription
textquery for translated text, uses 'contains with ignore case'
keyfilter by given translation key, uses 'equals'
languagefilter by given language key, uses 'equals'
customerIdfilter by given customer id, uses 'equals'; see customer-specific translations

Sample request

GET
https://api.simplelocalize.io
/api/v1/translations?languageKey=en&key=HELLO_WORLD

Response

{
    "msg": "OK",
    "status": 200,
    "data": {
        "content": [
            {
                "key": "HELLO_WORLD",
                "language": "en",
                "text": "Hello world!",
                "description": "Hello world description"
            }
        ]
    }
}