Version 0.5.3  
Docs

Locale API

Showing API references for integration, using 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
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.get();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • 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()
    
  • package main
    
    import (
        "fmt"
        "github.com/appwrite/sdk-for-go"
    )
    
    func main() {
        var client := appwrite.Client{}
    
        client.SetProject("5df5acd0d48c2") // Your project ID
        client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        var service := appwrite.Locale{
            client: &client
        }
    
        var response, error := service.Get()
    
        if error != nil {
            panic(error)
        }
    
        fmt.Println(response)
    }

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
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.getCountries();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • 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()
    
  • package main
    
    import (
        "fmt"
        "github.com/appwrite/sdk-for-go"
    )
    
    func main() {
        var client := appwrite.Client{}
    
        client.SetProject("5df5acd0d48c2") // Your project ID
        client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        var service := appwrite.Locale{
            client: &client
        }
    
        var response, error := service.GetCountries()
    
        if error != nil {
            panic(error)
        }
    
        fmt.Println(response)
    }

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
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.getCountriesEU();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • 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()
    
  • package main
    
    import (
        "fmt"
        "github.com/appwrite/sdk-for-go"
    )
    
    func main() {
        var client := appwrite.Client{}
    
        client.SetProject("5df5acd0d48c2") // Your project ID
        client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        var service := appwrite.Locale{
            client: &client
        }
    
        var response, error := service.GetCountriesEU()
    
        if error != nil {
            panic(error)
        }
    
        fmt.Println(response)
    }

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
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.getCountriesPhones();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • 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()
    
  • package main
    
    import (
        "fmt"
        "github.com/appwrite/sdk-for-go"
    )
    
    func main() {
        var client := appwrite.Client{}
    
        client.SetProject("5df5acd0d48c2") // Your project ID
        client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        var service := appwrite.Locale{
            client: &client
        }
    
        var response, error := service.GetCountriesPhones()
    
        if error != nil {
            panic(error)
        }
    
        fmt.Println(response)
    }

List Countries

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
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.getContinents();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • 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()
    
  • package main
    
    import (
        "fmt"
        "github.com/appwrite/sdk-for-go"
    )
    
    func main() {
        var client := appwrite.Client{}
    
        client.SetProject("5df5acd0d48c2") // Your project ID
        client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        var service := appwrite.Locale{
            client: &client
        }
    
        var response, error := service.GetContinents()
    
        if error != nil {
            panic(error)
        }
    
        fmt.Println(response)
    }

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
  • let sdk = new Appwrite();
    
    sdk
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    let promise = sdk.locale.getCurrencies();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • 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()
    
  • package main
    
    import (
        "fmt"
        "github.com/appwrite/sdk-for-go"
    )
    
    func main() {
        var client := appwrite.Client{}
    
        client.SetProject("5df5acd0d48c2") // Your project ID
        client.SetKey("919c2d18fb5d4...a2ae413da83346ad2") // Your secret API key
    
        var service := appwrite.Locale{
            client: &client
        }
    
        var response, error := service.GetCurrencies()
    
        if error != nil {
            panic(error)
        }
    
        fmt.Println(response)
    }