Skip to main content

Get country information data (queryMyRegion)

queryMyRegion API is an IP-based country/region identification service that retrieves the corresponding country or region information based on the player's IP address.

Data source (https://www.ipip.net/accuracy.html) ensures data accuracy.

caution
  • Due to factors in the data source, the conversion between IP and region is not 100% accurate.
  • This API may fail to return result due to network jitter or other factors.It is not recommended to use it in critical game logic.Users must also consider the default adaptation strategy in case of failure.
  • The conversion relationship between IP and region will default to change as data is updated in the IP database.If a fixed conversion relationship between IP and region is needed, please contact Player Network Assistant.

Request sample​

accountApi.queryMyRegion().then(
(res) => {
console.log(res);
}
);

Response parameters​

ParametersTypeExplanation
retnumberReturn code
0: Request successful
!=0: Request failed, refer to msg for detailed results
msgstringResult Explanation
alpha2stringAlpha 2 codes of countries or regions as per ISO 3166-1.For example, CN represents China, AT represents Austria.
regionstringISO 3166-1 Numeric code for a country or region
For example, 156 represents China, and 040 represents Austria
timestampnumberUnix timestamp
seqstringData Stream Message Serial Number

Response sample​

{
ret: 0,
msg: "success",
alpha2: "HK",
region: "344",
seq: "1639128374-0343981578-017512-0000925611",
timestamp: 1639128374,
}