Skip to content

Get the country list

Dynamically get the country list, which can be used for front-end login page country selection and international SMS input box selection to reduce the size of front-end static resources.

Method name

AuthenticationClient.getCountryList

Request parameters

NameTypeRequiredDefault valueDescriptionSample value

Sample code

ts
import { AuthenticationClient, Models } from "authing-node-sdk";

const authenticationClient = new AuthenticationClient({
  // Need to replace with your GenAuth AppId, Secret and Host
  appId: "GEN_AUTH_APP_ID",
  appSecret: "GEN_AUTH_APP_SECRET",
  appHost: "GEN_AUTH_APP_HOST",
});

(async () => {
  const result = await authenticationClient.getCountryList();

  console.log(JSON.stringify(result, null, 2));
})();

Request response

Type: GetCountryListRespDto

NameTypeDescription
statusCodenumberBusiness status code, which can be used to determine whether the operation is successful, 200 means success.
messagestringDescription
apiCodenumberSegment error code, which can be used to get the specific error type.
requestIdstringRequest ID. Returned when the request fails.
dataarrayresponse data

Sample result:

json
{
  "statusCode": 200,
  "message": "Operation successful",
  "requestId": "934108e5-9fbf-4d24-8da1-c330328abd6c",
  "data": {
    "alpha2": "CN",
    "alpha3": "CHN",
    "phoneCountryCode": "+86",
    "flag": "🇨🇳",
    "name": {
      "zh-CN": {
        "enabled": false,
        "value": "中国"
      },
      "en-US": {
        "enabled": false,
        "value": "China"
      }
    }
  }
}

Data structure

CountryDetailInfo

NameTypeIs it required?DescriptionSample value
alpha2stringYesAlpha-2 abbreviation of the country in ISO 3166 international standardCN
alpha3stringYesAlpha-3 abbreviation of the country in ISO 3166 international standardCHN
phoneCountryCodestringYesCountry mobile phone area code+86
flagstringYesFlag icon🇨🇳
nameYesName, multi-language structure, currently only supports Chinese and English Nested type: <a LangObject.{"zh-CN":{"enabled":false,"value":"中国"},"en-US":{"enabled":false,"value":"China"}}

LangObject

NameTypeIs it requiredDescriptionSample value
zh-CNYesMulti-language Chinese content Nested type: <a LangUnit.{"enabled":false,"value":"中文"}
en-USYesMultilingual English content Nesting type: <a LangUnit.{"enabled":false,"value":"English"}
zh-TWYesMultilingual Traditional Chinese content Nesting type: <a LangUnit.{"enabled":false,"value":"繁體中文"}
ja-JPYesMultilingual Japanese content Nesting type: <a LangUnit.{"enabled":false,"value":"日本語"}

LangUnit

NameTypeIs it required?DescriptionSample value
enabledbooleanyesWhether it is enabled. If enabled, and the console selects this language, the content will be displayed. (Off by default)
valuestringyesMultilingual content

Agent infrastructure for identity, memory, and web action.