Country Code Service

Last Updated on : 2024-06-05 03:15:12download

Get country code list for current area

API endpoint

action: country.current

Request parameter

None

Sample request

{
    "action": "country.current",
     "params": {
      }
}

Response parameter

Parameter name Type Description
code Integer The response code.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
  • msg String The error message that is returned if the API call fails. This parameter value is empty if the API call succeeds.
    result Object Indicates whether the operation is successful.

    Get list of all country codes

    API endpoint

    action: country.all
    

    Request parameter

    None

    Sample request

    {
        "action": "country.all",
         "params": {
          }
    }
    

    Response parameter

    Parameter name Type Description
    code Integer The response code.
    success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
  • msg String The error message that is returned if the API call fails. This parameter value is empty if the API call succeeds.
    result Object Indicates whether the operation is successful.

    Get details of country code

    API endpoint

    action: country.search
    

    Request parameter

    Parameter name Type Description Required
    key String The keyword for searching. You can provide a country code, the country name in Chinese or English, or the abbreviation that matches the country code. Yes

    Sample request

    {
        "action": "country.search",
          "params": {
                "key": "cn"
          }
    }
    

    Response parameter

    Parameter name Type Description
    code Integer The response code.
    success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
  • msg String The error message that is returned if the API call fails. This parameter value is empty if the API call succeeds.
    result Object The returned result.

    Description of result

    Parameter name Type Description
    chinese String The country name in Chinese.
    english String The country name in English.
    code String Country code
    abbr String The abbreviation of the country or region name.

    Sample response

    {
        "success":true,
        "result":[
                     {
                         "chinese":"加拿大",
                         "code":"1",
                         "english":"Canada",
                         "abbr":"CA"
                     },
                     {
                         "chinese":"美国",
                         "code":"1",
                         "english":"The United States",
                         "abbr":"US"
                     }
                 ]
    }
    

    Get country code by IP

    API endpoint

    action: country.ip
    

    Request parameter

    Parameter name Type Description Required
    ip String The IP address. Yes

    Sample request

    {
        "action": "country.ip",
         "params": {
            "ip": "10.10.3.30"
         }
    }
    

    Response parameter

    Parameter name Type Description
    code Integer The response code.
    success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
  • msg String The error message that is returned if the API call fails. This parameter value is empty if the API call succeeds.
    result Object The returned result.

    Sample response

    {
        "success": true,
        "t": 1553152235816,
        "result": {
            "eu_countries": [
                {
                    "code": "7",
                    "abbr": "KZ",
                    "chinese": "哈萨克斯坦",
                    "english": "Kazakstan"
                }
            ],
            "cn_countries": [
                {
                    "code": "86",
                    "abbr": "CN",
                    "chinese": "中国",
                    "english": "China"
                }
            ],
            "us_countries": [
                {
                    "code": "1",
                    "abbr": "CA",
                    "chinese": "加拿大",
                    "english": "Canada"
                }
            ],
            "default_countries": {
                     "code": "86",
                     "abbr": "CN",
                     "chinese": "中国",
                     "english": "China"
                }
        }
    }