API Method ip_info. Get country code by IP address

The API method ip_info() returns a 2 letter country code (US, UK, CN and etc) for an IP address. You can specify a list for IP address 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.