3-Step Quickstart Guide

Jump right into it and learn how to make API requests in seconds using our 3-Step Quickstart Guide.

Code Examples

Skip to code examples in various programming languages, such as JavaScript (jQuery.ajax) and PHP (cURL).

Code Examples

API Documentation

ipapi provides an easy-to-use API interface allowing customers to look various pieces of information IPv4 and IPv6 addresses are associated with. For each IP address processed, the API returns more than 45 unique data points, such as location data, connection data, ISP information, time zone, currency and security assessment data.

The API is REST-based, lookup requests are made using straightforward HTTP GET URLs and results are returned in lightweight JSON or XML format within a matter of a few milliseconds.

This API documentation will outline in detail the API's specification, access and features. At the very bottom you will find code examples in different programming languages. In case any technical questions are left unanswered, please feel free to contact ipapi Customer Service.

Specs & Overview

API Access Key & Authentication

After creating an account, you will be assigned a API access key, a unique hash consisting of 32 characters that will allow you to authenticate with the ipapi API interface. To do this, simply append your API access key to the API's base URL using the access_key parameter.

https://api.ipapi.com/api/161.185.160.93
    ? access_key = YOUR_ACCESS_KEY

Keep your API access key safe: Your API access key is private and should at no time be shown publicly. You can reset it with immediate effect using your account dashboard at any given time.

API Response

Following a successful API request, the API will return more than 40 unique response objects containing result data. An API response can be returned in JSON or XML format and is structured into 4 modules: General information, location data, time zone data, currency data, connection data and security data. Response objects contained in each module will be explained in detail in the API Response Objects section.

Find below an example API response for an IPv4 address in Brooklyn, New York.

Example API Response:

{ "ip": "161.185.160.93", "hostname": "161.185.160.93", "type": "ipv4", "continent_code": "NA", "continent_name": "North America", "country_code": "US", "country_name": "United States", "region_code": "NY", "region_name": "New York", "city": "Brooklyn", "zip": "11238", "latitude": 40.676, "longitude": -73.9629, "location": { "geoname_id": 5110302, "capital": "Washington D.C.", "languages": [ { "code": "en", "name": "English", "native": "English" } ], "country_flag": "http://assets.ipapi.com/flags/us.svg", "country_flag_emoji": "🇺🇸", "country_flag_emoji_unicode": "U+1F1FA U+1F1F8", "calling_code": "1", "is_eu": false }, "time_zone": { "id": "America/New_York", "current_time": "2018-09-24T05:07:10-04:00", "gmt_offset": -14400, "code": "EDT", "is_daylight_saving": true }, "currency": { "code": "USD", "name": "US Dollar", "plural": "US dollars", "symbol": "$", "symbol_native": "$" }, "connection": { "asn": 22252, "isp": "The City of New York" }, "security": { "is_proxy": false, "proxy_type": null, "is_crawler": false, "crawler_name": null, "crawler_type": null, "is_tor": false, "threat_level": "low", "threat_types": null } }
<result> <ip>161.185.160.93</ip> <hostname>161.185.160.93</hostname> <type>ipv4</type> <continent_code>NA</continent_code> <continent_name>North America</continent_name> <country_code>US</country_code> <country_name>United States</country_name> <region_code>NY</region_code> <region_name>New York</region_name> <city>Brooklyn</city> <zip>11238</zip> <latitude>40.676</latitude> <longitude>-73.9629</longitude> <location> <geoname_id>5110302</geoname_id> <capital>Washington D.C.</capital> <languages> <code>en</code> <name>English</name> <native>English</native> </languages> <country_flag>https://assets.ipapi.com/images/assets/flags_svg/us.svg</country_flag> <country_flag_emoji>🇺🇸</country_flag_emoji> <country_flag_emoji_unicode>U+1F1FA U+1F1F8</country_flag_emoji_unicode> <calling_code>1</calling_code> <is_eu/> </location> <time_zone> <id>America/New_York</id> <current_time>2018-09-24T08:27:07-04:00</current_time> <gmt_offset>-14400</gmt_offset> <code>EDT</code> <is_daylight_saving>1</is_daylight_saving> </time_zone> <currency> <code>USD</code> <name>US Dollar</name> <plural>US dollars</plural> <symbol>$</symbol> <symbol_native>$</symbol_native> </currency> <connection> <asn>22252</asn> <isp>The City of New York</isp> </connection> <security> <is_proxy/> <proxy_type/> <is_crawler/> <crawler_name/> <crawler_type/> <is_tor/> <threat_level>low </threat_level> <threat_types/> </security> </result>
JSONXML

Please note: To be able to show you a comprehensive API response, Hostname and Security data have been included in the result above. To enable this data for your API response, please follow the instructions in the following sections of this documentation: Hostname Lookup and Security Data.

API Endpoints

The API comes with a total of 3 available API endpoints, each covering a different type functionality. Please find below a quick overview and click on any of the endpoints to learn more about its usage.

256-bit HTTPS Encryption Available on: Standard Plan and higher

If supported by your subscription, you can connect to the API using industry standard HTTPS (SSL) by appending an s to the HTTP Protocol. You can see an example API request using HTTPS below.

Example API Request:

https://api.ipapi.com/api/161.185.160.93

JSONP Callbacks

The API supports JSONP Callbacks. To make use of this feature, simply append the API's callback parameter to your API request URL and set it to your preferred function name. The API will then return your API results set wrapped inside the tags of the function you specified.

Example API Request:

https://api.ipapi.com/api/161.185.160.93
    ? access_key = YOUR_ACCESS_KEY
    & callback = FUNCTION_NAME

Example API Response:

CALLBACK_FUNCTION ({
    {
        "ip": "161.185.160.93",
        "hostname": "161.185.160.93",
        "type": "ipv4",
        "continent_code": "NA",
        "continent_name": "North America",
        "country_code": "US",
        "country_name": "United States",
        "region_code": "NY",
        [...]
    }
})JSON ONLY              

Please note: The API also supports Access-Control (CORS) headers.

API Error Codes

In the event that your API request fails for any reason, the API will return a JSON error message detailing information about the error that occurred. As an example, find below an error the API responds with if the limit of monthly API requests has been reached.

Example Error:

{
    "success": false,
    "error": {
        "code": 104,
        "type": "monthly_limit_reached",
        "info": "Your monthly API request volume has been reached. Please upgrade your plan."    
    }
}JSON ONLY                  

Common API Errors:

Code Type Info
404 404_not_found User requested a resource which does not exist.
101 missing_access_key User did not supply an access key.
101 invalid_access_key User supplied an invalid access key.
102 inactive_user User account is inactive or blocked.
103 invalid_api_function User requested a non-existent API function.
104 usage_limit_reached User has reached his subscription's monthly request allowance.
105 function_access_restricted The user's current subscription does not support this API function.
105 https_access_restricted The user's current subscription plan does not support HTTPS.
301 invalid_fields User specified one or more invalid fields inside the fields parameter.
302 too_many_ips User specified too many IP addresses in a single Bulk Lookup request.
303 batch_not_supported_on_plan The user's current subscription plan does not support Bulk Lookup.

Endpoints

Standard IP Lookup Available on: All plans

To look up a single IP address of your choice, simply append an IPv4 or IPv6 address to the API's base URL. Below you will find an example API request, required parameters and an example API response.

Example API Request:

https://api.ipapi.com/api/161.185.160.93
    ? access_key = YOUR_ACCESS_KEY

Request Parameters:

Object Description
IP Address [Required] An IPv4 or IPv6 address of your choice. It is also possible to enter a domain URL to have the API resolve the domain to the underlying IP address.
access_key [Required] Your API access key, available in your account dashboard.
fields [optional] Specify API response field(s) according to the Specify Response Fields section.
hostname [optional] Set to 1 to enable Hostname Lookup.
security [optional] Set to 1 to enable Security Data.
language [optional] Set to a 2-letter language code according to the Specify Response Language section to specify response language.
callback [optional] Specify a JSONP callback function name according to the JSONP Callbacks section.
output [optional] Set to json or xml to choose between output formats.

Example API Response:

A standard API response will come with general information about the given IP address and location data. If you are subscribed to the Standard Plan or higher, the API will additionally return time zone, currency and connection data.

{ "ip": "161.185.160.93", "type": "ipv4", "continent_code": "NA", "continent_name": "North America", "country_code": "US", "country_name": "United States", "region_code": "NY", "region_name": "New York", "city": "Brooklyn", "zip": "11238", "latitude": 40.676, "longitude": -73.9629, "location": { "geoname_id": 5110302, "capital": "Washington D.C.", "languages": [ { "code": "en", "name": "English", "native": "English" } ], "country_flag": "http://assets.ipapi.com/flags/us.svg", "country_flag_emoji": "🇺🇸", "country_flag_emoji_unicode": "U+1F1FA U+1F1F8", "calling_code": "1", "is_eu": false }, "time_zone": { "id": "America/New_York", "current_time": "2018-09-24T05:07:10-04:00", "gmt_offset": -14400, "code": "EDT", "is_daylight_saving": true }, "currency": { "code": "USD", "name": "US Dollar", "plural": "US dollars", "symbol": "$", "symbol_native": "$" }, "connection": { "asn": 22252, "isp": "The City of New York" } }
<result> <ip>161.185.160.93</ip> <type>ipv4</type> <continent_code>NA</continent_code> <continent_name>North America</continent_name> <country_code>US</country_code> <country_name>United States</country_name> <region_code>NY</region_code> <region_name>New York</region_name> <city>Brooklyn</city> <zip>11238</zip> <latitude>40.676</latitude> <longitude>-73.9629</longitude> <location> <geoname_id>5110302</geoname_id> <capital>Washington D.C.</capital> <languages> <code>en</code> <name>English</name> <native>English</native> </languages> <country_flag>https://assets.ipapi.com/images/assets/flags_svg/us.svg</country_flag> <country_flag_emoji>🇺🇸</country_flag_emoji> <country_flag_emoji_unicode>U+1F1FA U+1F1F8</country_flag_emoji_unicode> <calling_code>1</calling_code> <is_eu/> </location> <time_zone> <id>America/New_York</id> <current_time>2018-09-24T08:27:07-04:00</current_time> <gmt_offset>-14400</gmt_offset> <code>EDT</code> <is_daylight_saving>1</is_daylight_saving> </time_zone> <currency> <code>USD</code> <name>US Dollar</name> <plural>US dollars</plural> <symbol>$</symbol> <symbol_native>$</symbol_native> </currency> <connection> <asn>22252</asn> <isp>The City of New York</isp> </connection> </result>
JSONXML

API Response Objects: Looking for details about the response objects returned by the API? All available response objects are explained in detail in the API Response Objects section.

Bulk IP Lookup Available on: Business Plan and higher

To look up multiple IP addresses at once, simply attach a comma-separated list of IPv4 or IPv6 addresses to the API's base URL. The API will then respond with an array of results, containing one sub-array per IP address looked up.

Example API Request:

https://api.ipapi.com/api/161.185.160.93,87.111.168.248,210.138.184.59
    ? access_key = YOUR_ACCESS_KEY

Request Parameters:

Object Description
IP Addresses [Required] A comma-separated list of IPv4 or IPv6 addresses of your choice. It is also possible to enter domain URLs to have the API resolve the underlying IP addresses. (Limit: 50 values)
access_key [Required] Your API access key, available in your account dashboard.
fields [optional] Specify API response field(s) according to the Specify Response Fields section.
hostname [optional] Set to 1 to enable Hostname Lookup.
security [optional] Set to 1 to enable Security Data.
language [optional] Set to a 2-letter language code according to the Specify Response Language section to specify response language.
callback [optional] Specify a JSONP callback function name according to the JSONP Callbacks section.
output [optional] Set to json or xml to choose between output formats.

Example API Response:

A Bulk Lookup API response contains an array of results with each result associated with one of the IP addresses contained in the API request. The API results below have been shortened for readability purposes.

{ "ip": "161.185.160.93", "type": "ipv4", "continent_code": "NA", "continent_name": "North America", "country_code": "US", "country_name": "United States", "region_code": "NY", "region_name": "New York", "city": "Brooklyn", "zip": "11238", "latitude": 40.676, "longitude": -73.9629, [...] }, { "ip": "161.185.160.93", "type": "ipv4", "continent_code": "EU", "continent_name": "Europe", "country_code": "ES", "country_name": "Spain", "region_code": "GA", "region_name": "Galicia", "city": "Santiago de Compostela", "zip": "15781", "latitude": 42.88, "longitude": -8.5448, [...] }, { "ip": "210.138.184.59", "type": "ipv4", "continent_code": "AS", "continent_name": "Asia", "country_code": "JP", "country_name": "Japan", "region_code": "13", "region_name": "Tokyo", "city": "Tokyo", "zip": "102-0082", "latitude": 35.685, "longitude": 139.7514, [...] }
<result> <ip>161.185.160.93</ip> <type>ipv4</type> <continent_code>NA</continent_code> <continent_name>North America</continent_name> <country_code>US</country_code> <country_name>United States</country_name> <region_code>NY</region_code> <region_name>New York</region_name> <city>Brooklyn</city> <zip>11238</zip> <latitude>40.676</latitude> <longitude>-73.9629</longitude> [...] </result> <result> <ip>87.111.168.248</ip> <type>ipv4</type> <continent_code>EU</continent_code> <continent_name>Europe</continent_name> <country_code>ES</country_code> <country_name>Spain</country_name> <region_code>GA</region_code> <region_name>Galicia</region_name> <city>Santiago de Compostela</city> <zip>15781</zip> <latitude>42.88</latitude> <longitude>-8.5448</longitude> [...] </result> <result> <ip>210.138.184.59</ip> <type>ipv4</type> <continent_code>AS</continent_code> <continent_name>Asia</continent_name> <country_code>JP</country_code> <country_name>Japan</country_name> <region_code>13</region_code> <region_name>Tokyo</region_name> <city>Tokyo</city> <zip>102-0082</zip> <latitude>35.685</latitude> <longitude>139.7514</longitude> [...] </result>
JSONXML

API Response Objects: Looking for details about the response objects returned by the API? All available response objects are explained in detail in the API Response Objects section.

Origin IP Lookup Available on: All plans

To look up the IP address the current API request is coming from, simply attach check to the API's base URL. The API will then perform a lookup request based on that IP address and return a full set of API results.

Example API Request:

https://api.ipapi.com/api/check
    ? access_key = YOUR_ACCESS_KEY

Request Parameters:

Object Description
access_key [Required] Your API access key, available in your account dashboard.
fields [optional] Specify API response field(s) according to the Specify Response Fields section.
hostname [optional] Set to 1 to enable Hostname Lookup.
security [optional] Set to 1 to enable Security Data.
language [optional] Set to a 2-letter language code according to the Specify Response Language section to specify response language.
callback [optional] Specify a JSONP callback function name according to the JSONP Callbacks section.
output [optional] Set to json or xml to choose between output formats.

Example API Response:

{ "ip": "161.185.160.93", "type": "ipv4", "continent_code": "NA", "continent_name": "North America", "country_code": "US", "country_name": "United States", "region_code": "NY", "region_name": "New York", "city": "Brooklyn", "zip": "11238", "latitude": 40.676, "longitude": -73.9629, "location": { "geoname_id": 5110302, "capital": "Washington D.C.", "languages": [ { "code": "en", "name": "English", "native": "English" } ], "country_flag": "http://assets.ipapi.com/flags/us.svg", "country_flag_emoji": "🇺🇸", "country_flag_emoji_unicode": "U+1F1FA U+1F1F8", "calling_code": "1", "is_eu": false }, "time_zone": { "id": "America/New_York", "current_time": "2018-09-24T05:07:10-04:00", "gmt_offset": -14400, "code": "EDT", "is_daylight_saving": true }, "currency": { "code": "USD", "name": "US Dollar", "plural": "US dollars", "symbol": "$", "symbol_native": "$" }, "connection": { "asn": 22252, "isp": "The City of New York" } }
<result> <ip>161.185.160.93</ip> <type>ipv4</type> <continent_code>NA</continent_code> <continent_name>North America</continent_name> <country_code>US</country_code> <country_name>United States</country_name> <region_code>NY</region_code> <region_name>New York</region_name> <city>Brooklyn</city> <zip>11238</zip> <latitude>40.676</latitude> <longitude>-73.9629</longitude> <location> <geoname_id>5110302</geoname_id> <capital>Washington D.C.</capital> <languages> <code>en</code> <name>English</name> <native>English</native> </languages> <country_flag>https://assets.ipapi.com/images/assets/flags_svg/us.svg</country_flag> <country_flag_emoji>🇺🇸</country_flag_emoji> <country_flag_emoji_unicode>U+1F1FA U+1F1F8</country_flag_emoji_unicode> <calling_code>1</calling_code> <is_eu/> </location> <time_zone> <id>America/New_York</id> <current_time>2018-09-24T08:27:07-04:00</current_time> <gmt_offset>-14400</gmt_offset> <code>EDT</code> <is_daylight_saving>1</is_daylight_saving> </time_zone> <currency> <code>USD</code> <name>US Dollar</name> <plural>US dollars</plural> <symbol>$</symbol> <symbol_native>$</symbol_native> </currency> <connection> <asn>22252</asn> <isp>The City of New York</isp> </connection> </result>
JSONXML

API Response Objects: Looking for details about the response objects returned by the API? All available response objects are explained in detail in the API Response Objects section.

Response Objects

Based on which plan you are subscribed to and the options you specify for your API request, there are over 40 unique response objects the API is capable of responding with. Find below a complete list of API response objects:

Response Object Description
ip Returns the IP address as requested.
hostname Returns the hostname the requested IP is associated with; requires Hostname Lookup to be enabled.
type Returns IPv4 or IPv6, depending on type of the requested IP address.
continent_code Returns the 2-letter continent code associated with the IP address.
View all 2-letter continent codes
continent_name Returns the continent name associated with the IP address.
country_code Returns the 2-letter country code associated with the IP address.
List of all 2-letter country codes
country_name Returns the country name associated with the IP address.
region_code Returns the region code associated with the IP address (e.g. NY for New York).
region_name Returns region name associated with the IP address.
city Returns the city associated with the IP address.
zip Returns the ZIP code associated with the IP address.
latitude Returns the latitude associated with the IP address.
longitude Returns the longitude associated with the IP address.
location [Object] Returns multiple objects related to location.
location > geoname_id Returns the geoname identifier in accordance with the Geonames Registry.
location > capital Returns the capital city of the country associated with the IP address.
location > languages [Object] Returns an object containing one or multiple sub-objects per language associated with the IP address.
location > languages > code Returns the 2-letter language code for the given language.
List of all 2-letter language codes
location > languages > name Returns the language name (in the API request's main language). (e.g. Spanish)
location > languages > native Returns the native language name. (e.g. Español)
location > country_flag Returns an HTTP URL to an SVG country flag icon associated with the IP address.
location > country_flag_emoji Returns the emoji icon for the country flag associated with the IP address.
location > country_flag_emoji_unicode Returns the unicode value of the emoji icon for the country flag associated with the IP address. (e.g. U+1F1EA U+1F1F8 for the Spanish flag)
location > calling_code Returns the calling/dial code associated with the IP address. (e.g. 34) for Spain.
location > is_eu Returns true if the given country is part of the EU, false if not.
time_zone [Object] Returns an object containing data related to time zone.
time_zone > id Returns the time zone ID associated with the IP address. (e.g. America/New_York for EDT)
time_zone > current_time Returns the current date and time associated with the IP address. (e.g. 2018-03-29T22:31:27-07:00)
time_zone > gmt_offset Returns the offset to GMT time of the given time zone in seconds. (e.g. -14400 for EDT)
time_zone > code Returns the universal code of the given time zone.
List of all available codes
time_zone > is_daylight_saving Returns true if the given time zone is daylight saving time, false if not.
currency [Object] Returns an object containing data related to currency.
currency > code Returns the 3-letter code of the main currency associated with the IP address.
Example: USD - List of all available currency codes
currency > name Returns the name of the given currency.
currency > plural Returns the name of the given currency in plural.
currency > symbol Returns the symbol of the given currency.
currency > symbol_native Returns the native symbol of the given currency.
connection [Object] Returns an object containing data related to connection.
connection > asn Returns the Autonomous System Number associated with the IP address.
connection > isp Returns the ISP associated with the IP address.
security [Object] Returns an object containing data related to security.
security > is_proxy Returns true if the given IP address is associated with a proxy, false if not.
security > proxy_type If relevant, returns the type of proxy the IP address is associated with.
View all potential proxy types
security > is_crawler Returns true if the given IP address is associated with a crawler, false if not.
security > crawler_name If relevant, returns the name of the crawler the IP address is associated with.
security > crawler_type If relevant, returns the type of crawler the IP address is associated with.
View all potential crawler types
security > is_tor Returns true if the given IP address is associated with the anonymous Tor system, false if not.
security > threat_level Returns the level of threat the IP address is associated with.
View all threat levels
security > threat_types [object] If relevant, returns an object containing all threat types associated with the IP address.
View all potential threat types

Options

Specify Response Format Available on: All plans

The API is capable of delivering API results in JSON (default) and XML format. The response format can be controlled by appending the API's output parameter to your API request URL and setting it to json or xml.

Example API Request - JSON:

https://api.ipapi.com/api/161.185.160.93
    ? access_key = YOUR_ACCESS_KEY
    & output = json

Example API Request - XML:

https://api.ipapi.com/api/161.185.160.93
    ? access_key = YOUR_ACCESS_KEY
    & output = xml

Would you like to see an API response? Jump to the API Response section.

Specify Response Fields Available on: All plans

API responses from ipapi can be extensive in size. To limit your API result set to specific fields or types of information, simply append the API's fields parameter to your API request URL and set it to a specific field or a comma-separated list of fields.

Examples:

fields = main // returns general API fields, only from "ip" to "longitude"
  
fields = city // returns only the "city" object

fields = location // returns the complete "location" object with sub-objects
fields = location.calling_code // returns only the "calling_code" object inside "location"
  
fields = latitude,longitude // returns both the "latitude" and the "longitude" objects

Example API Request - JSON:

https://api.ipapi.com/api/161.185.160.93
    ? access_key = YOUR_ACCESS_KEY
    & fields = latitude,longitude

Would you like to see an API response? Jump to the API Response section.

Specify Response Language Available on: All plans

The API is capable of translating certain applicable objects contained in the API response. The default language is always English; other languages can be requested by appending the API's language to your API request URL and setting it to one of the available 2-letter language codes.

Available Language Codes:

en    - English/US
de    - German
ed    - Spanish
fr    - French
ja    - Japanese
pt-br - Portuguese (Brazil)
ru    - Russian
zh    - Chinese

Example API Request:

In the example request below we are specifying Spanish as language.

https://api.ipapi.com/api/161.185.160.93
    ? access_key = YOUR_ACCESS_KEY
    & language = es

Example API Response:

In the example response below you will notice that all applicable response objects have been translated to Spanish. Please note that the API response has been shortened for readability purposes.

{ "ip": "161.185.160.93", "type": "ipv4", "continent_code": "NA", "continent_name": "Norteamérica", <-- translated "country_code": "US", "country_name": "Estados Unidos", <-- translated "region_code": "NY", "region_name": "Nueva York", <-- translated "city": "Brooklyn", "zip": "11238", "latitude": 40.676, "longitude": -73.9629, [...] }
<result> <ip>161.185.160.93</ip> <type>ipv4</type> <continent_code>NA</continent_code> <continent_name>Norteamérica</continent_name> <-- translated <country_code>US</country_code> <country_name>Estados Unidos</country_name> <-- translated <region_code>NY</region_code> <region_name>Nueva York</region_name> <-- translated <city>Brooklyn</city> <zip>11238</zip> <latitude>40.676</latitude> <longitude>-73.9629</longitude> [...] </result>
JSONXML

Enable Hostname Lookup Available on: All plans

To reduce bandwidth and speed up API responses standard IP lookups do not return hostname information. To include hostname data in your API responses, simply append the API's hostname parameter and set it to 1.

Example API Request:

https://api.ipapi.com/api/1.4.193.15
    ? access_key = YOUR_ACCESS_KEY
    & hostname = 1

Example API Response:

As you can see below, hostname information is now returned right after the IP address.

{ "ip": "1.4.193.15", "hostname": "node-cun.pool-1-4.dynamic.totbb.net", [...] }
<result> <ip>161.185.160.93</ip> <hostname>node-cun.pool-1-4.dynamic.totbb.net</type> [...] </result>
JSONXML

Please note: Enabling Hostname Lookup may cause the speed of API requests to decrease slightly.

Enable Security Data Available on: Business Pro Plan and higher

The API is capable of delivering valuable security assessment data, including the detection of threats like the TOR Network, proxies, and more. To enable Security Data in your API request, simply append the API's security parameter to your API request URL and set it to 1.

Example API Request:

https://api.ipapi.com/api/76.8.255.114
    ? access_key = YOUR_ACCESS_KEY
    & security = 1

Example API Response:

In the API response below you will notice that the threat types attack_source and attack_source_mail have been detected, indicating that the given IP address is in some way associated with spam via email.

{ [...] "security": { "is_proxy": false, "proxy_type": null, "is_crawler": false, "crawler_name": null, "crawler_type": null, "is_tor": false, "threat_level": "high", "threat_types": [ "attack_source", "attack_source_mail" ] } }
<result> [...] <security> <is_proxy/> <proxy_type/> <is_crawler/> <crawler_name/> <crawler_type/> <is_tor/> <threat_level>high</threat_level> <threat_types>attack_source</threat_types> <threat_types>attack_source_mail</threat_types> </security> </result>
JSONXML

Please note: In the above response the rest of the API response has been skipped for readability purposes.

Code Examples

PHP (CURL)

Standard Lookup via PHP

Find below a PHP (CURL) example making use of the Standard Lookup endpoint:

// set IP address and API access key
$ip = '161.185.160.93';
$access_key = 'YOUR_ACCESS_KEY';

// Initialize CURL:
$ch = curl_init('https://api.ipapi.com/'.$ip.'?access_key='.$access_key.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true

// Store the data:
$json = curl_exec($ch);
curl_close($ch);

// Decode JSON response:
$api_result = json_decode($json, true);

// Output the "calling_code" object inside "location"
echo $api_result['location']['calling_code'];

JavaScript (jQuery.ajax)

Standard Lookup via JavaScript (jQuery.ajax)

Find below a JS example making use of the Standard Lookup endpoint:

// set endpoint and your access key
var ip = '134.201.250.155'
var access_key = 'YOUR_ACCESS_KEY';

// get the API result via jQuery.ajax
$.ajax({
    url: 'https://api.ipapi.com/' + ip + '?access_key=' + access_key,   
    dataType: 'jsonp',
    success: function(json) {

        // output the "calling_code" object inside "location"
        alert(json.location.calling_code);
        
    }
});

Any technical questions left? Reach out to us, our team is happy to help. Contact Us