Version 0.6.1  
Docs

Locale API

Server integration with     code examples.


The Locale service allows you to customize your app based on your users' location. Using this service, you can get your users' location, IP address, list of countries and continents names, phone codes, currencies, and more.

The user service supports multiple locales. This feature allows you to fetch countries and continents information in your app language. To switch locales, all you need to do is pass the 'X-Appwrite-Locale' header or set the 'setLocale' method using any of our available SDKs. View here the list of available locales.

Get User Locale

GET/locale

Get the current user location based on IP. Returns an object with user country code, country name, continent name, continent code, ip address and suggested currency. You can use the locale header to get the data in a supported language.

(IP Geolocation by DB-IP)

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "locale.read" permission scope.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = locale.get();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->get();
  • from appwrite.client import Client
    from appwrite.services.locale import Locale
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    locale = Locale(client)
    
    result = locale.get()
    

List Countries

GET/locale/countries

List of all countries. You can use the locale header to get the data in a supported language.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "locale.read" permission scope.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = locale.getCountries();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->getCountries();
  • from appwrite.client import Client
    from appwrite.services.locale import Locale
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    locale = Locale(client)
    
    result = locale.get_countries()
    

List EU Countries

GET/locale/countries/eu

List of all countries that are currently members of the EU. You can use the locale header to get the data in a supported language.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "locale.read" permission scope.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = locale.getCountriesEU();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->getCountriesEU();
  • from appwrite.client import Client
    from appwrite.services.locale import Locale
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    locale = Locale(client)
    
    result = locale.get_countries_e_u()
    

List Countries Phone Codes

GET/locale/countries/phones

List of all countries phone codes. You can use the locale header to get the data in a supported language.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "locale.read" permission scope.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = locale.getCountriesPhones();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->getCountriesPhones();
  • from appwrite.client import Client
    from appwrite.services.locale import Locale
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    locale = Locale(client)
    
    result = locale.get_countries_phones()
    

List Continents

GET/locale/continents

List of all continents. You can use the locale header to get the data in a supported language.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "locale.read" permission scope.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = locale.getContinents();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->getContinents();
  • from appwrite.client import Client
    from appwrite.services.locale import Locale
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    locale = Locale(client)
    
    result = locale.get_continents()
    

List Currencies

GET/locale/currencies

List of all currencies, including currency symol, name, plural, and decimal digits for all major and minor currencies. You can use the locale header to get the data in a supported language.

Authentication

To access this route, init your SDK with your project unique ID and API Key secret token. Make sure your API Key is granted with access to the "locale.read" permission scope.

Example Request
  • const sdk = require('node-appwrite');
    
    // Init SDK
    let client = new sdk.Client();
    
    let locale = new sdk.Locale(client);
    
    client
        .setProject('5df5acd0d48c2') // Your project ID
        .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    let promise = locale.getCurrencies();
    
    promise.then(function (response) {
        console.log(response);
    }, function (error) {
        console.log(error);
    });
  • <?php
    
    use Appwrite\Client;
    use Appwrite\Services\Locale;
    
    $client = new Client();
    
    $client
        ->setProject('5df5acd0d48c2') // Your project ID
        ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
    ;
    
    $locale = new Locale($client);
    
    $result = $locale->getCurrencies();
  • from appwrite.client import Client
    from appwrite.services.locale import Locale
    
    client = Client()
    
    (client
      .set_project('5df5acd0d48c2') # Your project ID
      .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key
    )
    
    locale = Locale(client)
    
    result = locale.get_currencies()