API ip_info. Get Country Code by IP Address

 

The API "ip_info()" returns a 2-letter country code (US, UK, CN and etc) for an IP address. You can specify a list for IP addresses to find countries for each IP address by one API call.

 

Call required GET params:

  • method_name - must be 'ip_info',
  • ip - an IPv4 address to obtain 2 letter country code.

 

Optional POST params:

  • data - list of IP addresses separated by comma (,).

 

Example

https://api.cleantalk.org/?method_name=ip_info&ip=8.8.8.8

API returns JSON string, for example:

 {"data":{"8.8.8.8":{"country_code":"US","country_name":"United States"}}}

 

Response explanation:

  • data - array with checked records,
    • record - array with details per record,
      • country - a 2 letter country code for the IP address.

 

Restrictions

If you get calls limit, API returns error notice. Example:

{"error_message":"Calls limit exceeded.","error_no":10}

Current calls limit is 10 per 60 seconds.

If you get data elements limit in spam_check method, API returns error notice. Example:

{"error_message":"Received 1001 records to check, maximum 1000 records check per call.","error_no":8}

Current data elements limit is 1000.

 

Recommended timeout is no more than 180 seconds.

 

 

Was this information helpful?

It would also be interesting

Copied to clipboard