You can get the country code of requesting IP. When an IP exists in the requesting IP field, use the IP. If nothing exists, time zone service checks the requesting client IP to return the relevant country code.
- Request URL
Common URL https://timezone.qpyou.cn/public/api/getCountryCodeByIp Distributed Environment URL https://timezone.globalwithhive.com/public/api/getTimezone Sandbox URL https://sandbox-timezone.qpyou.cn/public/api/getCountryCodeByIp HTTP Method POST Content-Type text/html Data Format JSON
- Request
Field Name Description Required ip If the requesting IP(IPv4 or IPv6) is null, it gets the country code through the IP of API-implementing client. N
- Response
Field Name Description Type result_code Result code. 0=Success Integer result_msg Result message String timezone Object-type time zone
Refer to the following Timezone objectObject
- Timezone object
Field Name Description Type country_code Country code based on the ISO 3166-1 alpha-2 String
- Request Sample
12345678910//IPv4{"ip" : "127.0.0.1"}//IPv6{"ip" : "::ffff:dc46:52e7" or "0:0:0:0:0:ffff:dc46:52e7" or "0000:0000:0000:0000:0000:ffff:dc46:52e7"}
- Response Sample
1234567{"result_code":0,"result_message":"Success","timezone" : {"country_code":"KR"}}
When the country code of requesting IP is not identified, success is returned as result value, and “UNKNOWN” is returned as country_code value.
- Response Sample in case IP unable to identify the time zone
1234567{"result_code":0,"result_message":"Success","timezone" : {"country_code":"UNKNOWN"}}