Docs

Locale API


Client integration with  

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. Country codes returned follow the ISO 3166-1 standard.

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

HTTP Response

Status Code Content Type Payload
200  OK application/json Locale Object
Example Request
  • import { Client, Locale } from "appwrite";
    
    const client = new Client();
    
    const locale = new Locale(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = locale.get();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Locale locale = Locale(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = locale.get();
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    let client = Client()
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    let locale = Locale(client)
    
    let locale = try await locale.get()
    
    
  • import io.appwrite.Client
    import io.appwrite.services.Locale
    
    val client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    val locale = Locale(client)
    
    val response = locale.get()
    
  • import io.appwrite.Client;
    import io.appwrite.coroutines.CoroutineCallback;
    import io.appwrite.services.Locale;
    
    Client client = new Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2"); // Your project ID
    
    Locale locale = new Locale(client);
    
    locale.get(new CoroutineCallback<>((result, error) -> {
       if (error != null)
            error.printStackTrace();
            return;
        }
    
        Log.d("Appwrite", result.toString());
    }));
    
  • query {
        localeGet {
            ip
            countryCode
            country
            continentCode
            continent
            eu
            currency
        }
    }
    
  • GET /v1/locale HTTP/1.1
    Host: HOSTNAME
    Content-Type: application/json
    X-Appwrite-Response-Format: 1.0.0
    X-Appwrite-Project: 5df5acd0d48c2
    X-Appwrite-JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...
    
    

List Countries

GET/v1/locale/countries

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

HTTP Response

Status Code Content Type Payload
200  OK application/json Countries List Object
Example Request
  • import { Client, Locale } from "appwrite";
    
    const client = new Client();
    
    const locale = new Locale(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = locale.listCountries();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Locale locale = Locale(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = locale.listCountries();
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    let client = Client()
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    let locale = Locale(client)
    
    let countryList = try await locale.listCountries()
    
    
  • import io.appwrite.Client
    import io.appwrite.services.Locale
    
    val client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    val locale = Locale(client)
    
    val response = locale.listCountries()
    
  • import io.appwrite.Client;
    import io.appwrite.coroutines.CoroutineCallback;
    import io.appwrite.services.Locale;
    
    Client client = new Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2"); // Your project ID
    
    Locale locale = new Locale(client);
    
    locale.listCountries(new CoroutineCallback<>((result, error) -> {
       if (error != null)
            error.printStackTrace();
            return;
        }
    
        Log.d("Appwrite", result.toString());
    }));
    
  • query {
        localeListCountries {
            total
            countries {
                name
                code
            }
        }
    }
    
  • GET /v1/locale/countries HTTP/1.1
    Host: HOSTNAME
    Content-Type: application/json
    X-Appwrite-Response-Format: 1.0.0
    X-Appwrite-Project: 5df5acd0d48c2
    X-Appwrite-JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...
    
    

List EU Countries

GET/v1/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.

HTTP Response

Status Code Content Type Payload
200  OK application/json Countries List Object
Example Request
  • import { Client, Locale } from "appwrite";
    
    const client = new Client();
    
    const locale = new Locale(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = locale.listCountriesEU();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Locale locale = Locale(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = locale.listCountriesEU();
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    let client = Client()
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    let locale = Locale(client)
    
    let countryList = try await locale.listCountriesEU()
    
    
  • import io.appwrite.Client
    import io.appwrite.services.Locale
    
    val client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    val locale = Locale(client)
    
    val response = locale.listCountriesEU()
    
  • import io.appwrite.Client;
    import io.appwrite.coroutines.CoroutineCallback;
    import io.appwrite.services.Locale;
    
    Client client = new Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2"); // Your project ID
    
    Locale locale = new Locale(client);
    
    locale.listCountriesEU(new CoroutineCallback<>((result, error) -> {
       if (error != null)
            error.printStackTrace();
            return;
        }
    
        Log.d("Appwrite", result.toString());
    }));
    
  • query {
        localeListCountriesEU {
            total
            countries {
                name
                code
            }
        }
    }
    
  • GET /v1/locale/countries/eu HTTP/1.1
    Host: HOSTNAME
    Content-Type: application/json
    X-Appwrite-Response-Format: 1.0.0
    X-Appwrite-Project: 5df5acd0d48c2
    X-Appwrite-JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...
    
    

List Countries Phone Codes

GET/v1/locale/countries/phones

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

HTTP Response

Status Code Content Type Payload
200  OK application/json Phones List Object
Example Request
  • import { Client, Locale } from "appwrite";
    
    const client = new Client();
    
    const locale = new Locale(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = locale.listCountriesPhones();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Locale locale = Locale(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = locale.listCountriesPhones();
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    let client = Client()
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    let locale = Locale(client)
    
    let phoneList = try await locale.listCountriesPhones()
    
    
  • import io.appwrite.Client
    import io.appwrite.services.Locale
    
    val client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    val locale = Locale(client)
    
    val response = locale.listCountriesPhones()
    
  • import io.appwrite.Client;
    import io.appwrite.coroutines.CoroutineCallback;
    import io.appwrite.services.Locale;
    
    Client client = new Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2"); // Your project ID
    
    Locale locale = new Locale(client);
    
    locale.listCountriesPhones(new CoroutineCallback<>((result, error) -> {
       if (error != null)
            error.printStackTrace();
            return;
        }
    
        Log.d("Appwrite", result.toString());
    }));
    
  • query {
        localeListCountriesPhones {
            total
            phones {
                code
                countryCode
                countryName
            }
        }
    }
    
  • GET /v1/locale/countries/phones HTTP/1.1
    Host: HOSTNAME
    Content-Type: application/json
    X-Appwrite-Response-Format: 1.0.0
    X-Appwrite-Project: 5df5acd0d48c2
    X-Appwrite-JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...
    
    

List Continents

GET/v1/locale/continents

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

HTTP Response

Status Code Content Type Payload
200  OK application/json Continents List Object
Example Request
  • import { Client, Locale } from "appwrite";
    
    const client = new Client();
    
    const locale = new Locale(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = locale.listContinents();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Locale locale = Locale(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = locale.listContinents();
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    let client = Client()
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    let locale = Locale(client)
    
    let continentList = try await locale.listContinents()
    
    
  • import io.appwrite.Client
    import io.appwrite.services.Locale
    
    val client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    val locale = Locale(client)
    
    val response = locale.listContinents()
    
  • import io.appwrite.Client;
    import io.appwrite.coroutines.CoroutineCallback;
    import io.appwrite.services.Locale;
    
    Client client = new Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2"); // Your project ID
    
    Locale locale = new Locale(client);
    
    locale.listContinents(new CoroutineCallback<>((result, error) -> {
       if (error != null)
            error.printStackTrace();
            return;
        }
    
        Log.d("Appwrite", result.toString());
    }));
    
  • query {
        localeListContinents {
            total
            continents {
                name
                code
            }
        }
    }
    
  • GET /v1/locale/continents HTTP/1.1
    Host: HOSTNAME
    Content-Type: application/json
    X-Appwrite-Response-Format: 1.0.0
    X-Appwrite-Project: 5df5acd0d48c2
    X-Appwrite-JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...
    
    

List Currencies

GET/v1/locale/currencies

List of all currencies, including currency symbol, 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.

HTTP Response

Status Code Content Type Payload
200  OK application/json Currencies List Object
Example Request
  • import { Client, Locale } from "appwrite";
    
    const client = new Client();
    
    const locale = new Locale(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = locale.listCurrencies();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Locale locale = Locale(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = locale.listCurrencies();
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    let client = Client()
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    let locale = Locale(client)
    
    let currencyList = try await locale.listCurrencies()
    
    
  • import io.appwrite.Client
    import io.appwrite.services.Locale
    
    val client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    val locale = Locale(client)
    
    val response = locale.listCurrencies()
    
  • import io.appwrite.Client;
    import io.appwrite.coroutines.CoroutineCallback;
    import io.appwrite.services.Locale;
    
    Client client = new Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2"); // Your project ID
    
    Locale locale = new Locale(client);
    
    locale.listCurrencies(new CoroutineCallback<>((result, error) -> {
       if (error != null)
            error.printStackTrace();
            return;
        }
    
        Log.d("Appwrite", result.toString());
    }));
    
  • query {
        localeListCurrencies {
            total
            currencies {
                symbol
                name
                symbolNative
                decimalDigits
                rounding
                code
                namePlural
            }
        }
    }
    
  • GET /v1/locale/currencies HTTP/1.1
    Host: HOSTNAME
    Content-Type: application/json
    X-Appwrite-Response-Format: 1.0.0
    X-Appwrite-Project: 5df5acd0d48c2
    X-Appwrite-JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...
    
    

List Languages

GET/v1/locale/languages

List of all languages classified by ISO 639-1 including 2-letter code, name in English, and name in the respective language.

HTTP Response

Status Code Content Type Payload
200  OK application/json Languages List Object
Example Request
  • import { Client, Locale } from "appwrite";
    
    const client = new Client();
    
    const locale = new Locale(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = locale.listLanguages();
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Locale locale = Locale(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = locale.listLanguages();
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    let client = Client()
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    let locale = Locale(client)
    
    let languageList = try await locale.listLanguages()
    
    
  • import io.appwrite.Client
    import io.appwrite.services.Locale
    
    val client = Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2") // Your project ID
    
    val locale = Locale(client)
    
    val response = locale.listLanguages()
    
  • import io.appwrite.Client;
    import io.appwrite.coroutines.CoroutineCallback;
    import io.appwrite.services.Locale;
    
    Client client = new Client(context)
        .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
        .setProject("5df5acd0d48c2"); // Your project ID
    
    Locale locale = new Locale(client);
    
    locale.listLanguages(new CoroutineCallback<>((result, error) -> {
       if (error != null)
            error.printStackTrace();
            return;
        }
    
        Log.d("Appwrite", result.toString());
    }));
    
  • query {
        localeListLanguages {
            total
            languages {
                name
                code
                nativeName
            }
        }
    }
    
  • GET /v1/locale/languages HTTP/1.1
    Host: HOSTNAME
    Content-Type: application/json
    X-Appwrite-Response-Format: 1.0.0
    X-Appwrite-Project: 5df5acd0d48c2
    X-Appwrite-JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...