ipstack API
ipstack offers a powerful, real-time IP to geolocation API capable of looking up accurate location data and assessing security threats originating from risky IP addresses. Results are delivered within milliseconds in JSON or XML format. Using the ipstack API you will be able to locate website visitors at first glance and adjust your user experience and application accordingly.
This documentation outlines in detail API features, available options and integration guides in different programming languages.
Quickstart Tool
All registered users (free or paid) can use our Quickstart Tool to try out all API functionalities at the click of a button. If you're already a customer, you will be able to go to the Quickstart Tool using the button below. If not, you can use the button to quickly set up an account.
Get a free API access key to start using the Quickstart tool.
Get free API Access KeyGetting Started
API Access Key
Your API Access Key is your unique authentication key used to gain access to the ipstack API. In order to authenticate with the API, append the access_key
parameter to the API's base URL and set it to your access key value.
Base URL:
https://api.ipstack.com/
Append your API Access Key: Here is an example API call illustrating how to authenticate with the ipstack API:
Sign Up to Run API Requesthttps://api.ipstack.com/134.201.250.155 ? access_key = YOUR_ACCESS_KEY
API Response
The ipstack API is capable of delivering data either in JSON format (default) or XML format. Find below the API result ipstack would return in response to the API call shown in the section above, which queries the API for the IP address 134.201.250.155
.
{ "ip": "134.201.250.155", "hostname": "134.201.250.155", "type": "ipv4", "continent_code": "NA", "continent_name": "North America", "country_code": "US", "country_name": "United States", "region_code": "CA", "region_name": "California", "city": "Los Angeles", "zip": "90013", "latitude": 34.0453, "longitude": -118.2413, "location": { "geoname_id": 5368361, "capital": "Washington D.C.", "languages": [ { "code": "en", "name": "English", "native": "English" } ], "country_flag": "https://assets.ipstack.com/images/assets/flags_svg/us.svg", "country_flag_emoji": "🇺🇸", "country_flag_emoji_unicode": "U+1F1FA U+1F1F8", "calling_code": "1", "is_eu": false }, "time_zone": { "id": "America/Los_Angeles", "current_time": "2018-03-29T07:35:08-07:00", "gmt_offset": -25200, "code": "PDT", "is_daylight_saving": true }, "currency": { "code": "USD", "name": "US Dollar", "plural": "US dollars", "symbol": "$", "symbol_native": "$" }, "connection": { "asn": 25876, "isp": "Los Angeles Department of Water & Power" }, "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>134.201.250.155</ip> <hostname>134.201.250.155</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>CA</region_code> <region_name>California</region_name> <city>Los Angeles</city> <zip>90013</zip> <latitude>34.0453</latitude> <longitude>-118.2413</longitude> <location> <geoname_id>5368361</geoname_id> <capital>Washington D.C.</capital> <languages> <code>en</code> <name>English</name> <native>English</native> </languages> <country_flag>https://assets.ipstack.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/Los_Angeles</id> <current_time>2018-03-29T07:53:46-07:00</current_time> <gmt_offset>-25200</gmt_offset> <code>PDT</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>25876</asn> <isp>Los Angeles Department of Water & Power</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
API responses come with comprehensive location-related data, currency-related data, timezone-related data, connection-related data and security-related data. Throughout the Response Objects section you will learn more about the given response structure and its objects.
Please note: For illustration purposes we have included both Hostname Lookup and the Security Module in the above API response. Please refer to the sections Hostname Lookup and Security Module for details.
Available Endpoints
The ipstack API offers 3 different endpoints, each accepting a different set of parameters and returning different results. Click on the headings below to jump to the respective endpoint's description.
- Standard LookupLook up the data behind an IP address.
- Bulk LookupLook up the data behind multiple IP addresses at once.
- Requester LookupLook up the data behind the IP address your API request is coming from.
Connecting via HTTPS
All premium subscription plans available for the ipstack API come with support for 256-bit SSL encryption. To connect to the API via HTTPS, simply use the https
protocol instead of standard http
.
JSONP Callbacks
The ipstack API supports JSONP Callbacks, enabling you to enter a function name and cause the API to return your requested API result wrapped inside that function. In order to specify a callback, pass a function name into the API's callback
GET parameter.
Example Request: In our example request we are specifying the function name to be MY_FUNCTION
Sign Up to Run API Requesthttps://api.ipstack.com/134.201.250.155 ? access_key = YOUR_ACCESS_KEY & callback = MY_FUNCTION
Example Response: Your API response will be wrapped inside your preferred callback function.
MY_FUNCTION ( { "ip": "134.201.250.155", "type": "ipv4", "continent_code": "NA", "continent_name": "North America", "country_code": "US", "country_name": "United States", "region_code": "CA", [...] } )JSON ONLY
Please note: JSONP Callbacks can only be used along with the API's output format being set to json
.
Error Codes
Whenever a requested resource is not available or an API call fails for another reason, a JSON error is returned. Errors always come with an error code and a description.
Example Error: The following error is returned if your monthly API request volume has been exceeded.
{ "success": false, "error": { "code": 104, "type": "monthly_limit_reached", "info": "Your monthly API request volume has been reached. Please upgrade your plan." } }
Other Errors:
Code | Type | Info |
---|---|---|
404 |
404_not_found |
The requested resource does not exist. |
101 |
missing_access_key |
No API Key was specified. |
101 |
invalid_access_key |
No API Key was specified or an invalid API Key was specified. |
102 |
inactive_user |
The current user account is not active. User will be prompted to get in touch with Customer Support. |
103 |
invalid_api_function |
The requested API endpoint does not exist. |
104 |
usage_limit_reached |
The maximum allowed amount of monthly API requests has been reached. |
105 |
function_access_restricted |
The current subscription plan does not support this API endpoint. |
105 |
https_access_restricted |
The user's current subscription plan does not support HTTPS Encryption. |
301 |
invalid_fields |
One or more invalid fields were specified using the fields parameter. |
302 |
too_many_ips |
Too many IPs have been specified for the Bulk Lookup Endpoint. (max. 50) |
303 |
batch_not_supported_on_plan |
The Bulk Lookup Endpoint is not supported on the current subscription plan |
Endpoints
Standard IP Lookup
The ipstack's primary endpoint is called Standard Lookup and is used to look up single IPv4 or IPv6 addresses. To call this endpoint, simply attach any IPv4 or IPv6 address to the API's base URL.
API Request:
Sign Up to Run API Requesthttps://api.ipstack.com/134.201.250.155 ? access_key = YOUR_ACCESS_KEY
Request Parameters:
Parameter | Description |
---|---|
IP Address |
[Required] Any IPv4 or IPv6 address; you can also enter a domain URL to have ipstack resolve the domain to the underlying IP address. |
access_key |
[Required] Your API Access Key. |
fields |
[optional] Set to your preferred output field(s) according to the Specify Output Fields section. |
hostname |
[optional] Set to 1 to enable Hostname Lookup. |
security |
[optional] Set to 1 to enable the Security module. |
language |
[optional] Set to a 2-letter language code according to the Specify Output Language section to change output 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. |
API Response:
{ "ip": "134.201.250.155", "type": "ipv4", "continent_code": "NA", "continent_name": "North America", "country_code": "US", "country_name": "United States", "region_code": "CA", "region_name": "California", "city": "Los Angeles", "zip": "90013", "latitude": 34.0453, "longitude": -118.2413, "location": { "geoname_id": 5368361, "capital": "Washington D.C.", "languages": [ { "code": "en", "name": "English", "native": "English" } ], "country_flag": "https://assets.ipstack.com/images/assets/flags_svg/us.svg", "country_flag_emoji": "🇺🇸", "country_flag_emoji_unicode": "U+1F1FA U+1F1F8", "calling_code": "1", "is_eu": false }, "time_zone": { "id": "America/Los_Angeles", "current_time": "2018-03-29T07:35:08-07:00", "gmt_offset": -25200, "code": "PDT", "is_daylight_saving": true }, "currency": { "code": "USD", "name": "US Dollar", "plural": "US dollars", "symbol": "$", "symbol_native": "$" }, "connection": { "asn": 25876, "isp": "Los Angeles Department of Water & Power" } }<result> <ip>134.201.250.155</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>CA</region_code> <region_name>California</region_name> <city>Los Angeles</city> <zip>90013</zip> <latitude>34.0453</latitude> <longitude>-118.2413</longitude> <location> <geoname_id>5368361</geoname_id> <capital>Washington D.C.</capital> <languages> <code>en</code> <name>English</name> <native>English</native> </languages> <country_flag>https://assets.ipstack.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/Los_Angeles</id> <current_time>2018-03-29T07:53:46-07:00</current_time> <gmt_offset>-25200</gmt_offset> <code>PDT</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>25876</asn> <isp>Los Angeles Department of Water & Power</isp> </connection> </result>JSONXML
Response Objects: See the Response Objects section to view detailed descriptions for all API response objects and their values returned by the ipstack API.
Bulk IP Lookup
The ipstack API also offers the ability to request data for multiple IPv4 or IPv6 addresses at the same time. In order to process IP addresses in bulk, simply append multiple comma-separated IP addresses to the API's base URL.
API Request:
Sign Up to Run API Requesthttps://api.ipstack.com/134.201.250.155,72.229.28.185,110.174.165.78 ? access_key = YOUR_ACCESS_KEY
Request Parameters:
Parameter | Description |
---|---|
IP Addresses |
[Required] A comma-separated list of IPv4 or IPv6 addresses; you can also enter a domain URLs to have ipstack resolve the domains to their underlying IP addresses. (Maxmium allowed values: 50) |
access_key |
[Required] Your API Access Key. |
fields |
[optional] Set to your preferred output field(s) according to the Specify Output Fields section. |
hostname |
[optional] Set to 1 to enable Hostname Lookup. |
security |
[optional] Set to 1 to enable the Security module. |
language |
[optional] Set to a 2-letter language code according to the Specify Output Language section to change output 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. |
API Response:
JSON: The API response for bulk queries will contain one IP data object per requested IP address/domain.
XML: Please note that in XML format the main response object will be <batch></batch>
and contain one <result></result>
with its respective index number per requested IP address/domain.
[ { "ip": "134.201.250.155", "type": "ipv4", "continent_code": "NA", "continent_name": "North America", "country_code": "US", "country_name": "United States", "region_code": "CA", "region_name": "California", "city": "Los Angeles", "zip": "90013", "latitude": 34.0453, "longitude": -118.2413, "location": { ... }, "time_zone": { ... }, "currency": { ... }, "connection": { ... }, }, { "ip": "72.229.28.185", "type": "ipv4", "continent_code": "NA", "continent_name": "North America", "country_code": "US", "country_name": "United States", "region_code": "NY", "region_name": "New York", "city": "New York", "zip": "10036", "latitude": 40.7605, "longitude": -73.9933, "location": { ... }, "time_zone": { ... }, "currency": { ... }, "connection": { ... }, }, { "ip": "110.174.165.78", "type": "ipv4", "continent_code": "OC", "continent_name": "Oceania", "country_code": "AU", "country_name": "Australia", "region_code": "NSW", "region_name": "New South Wales", "city": "Coffs Harbour", "zip": "2450", "latitude": -30.2963, "longitude": 153.1135, "location": { ... }, "time_zone": { ... }, "currency": { ... }, "connection": { ... }, } ]<batch> <result index="0"> <ip>134.201.250.155</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>CA</region_code> <region_name>California</region_name> <city>Los Angeles</city> <zip>90013</zip> <latitude>34.0453</latitude> <longitude>-118.2413</longitude> <location> [...] </location> <time_zone> [...] </time_zone> <currency> [...] </currency> <connection> [...] </connection> </result> <result index="1"> <ip>72.229.28.185</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>New York</city> <zip>10036</zip> <latitude>40.7605</latitude> <longitude>-73.9933</longitude> <location> [...] </location> <time_zone> [...] </time_zone> <currency> [...] </currency> <connection> [...] </connection> </result> <result index="2"> <ip>110.174.165.78</ip> <type>ipv4</type> <continent_code>OC</continent_code> <continent_name>Oceania</continent_name> <country_code>AU</country_code> <country_name>Australia</country_name> <region_code>NSW</region_code> <region_name>New South Wales</region_name> <city>Coffs Harbour</city> <zip>2450</zip> <latitude>-30.2963</latitude> <longitude>153.1135</longitude> <location> [...] </location> <time_zone> [...] </time_zone> <currency> [...] </currency> <connection> [...] </connection> </result> </batch>JSONXML
Response Objects: See the Response Objects section to view detailed descriptions for all API response objects and their values returned by the ipstack API.
Requester IP Lookup
The ipstack API also offers a separate API endpoint capable of detecting the IP address which the current API request is coming from. In order to use this endpoint, simply append check
to the API's base URL and specify your preferred optional parameters.
API Request:
Sign Up to Run API Requesthttps://api.ipstack.com/check ? access_key = YOUR_ACCESS_KEY
Request Parameters:
Parameter | Description |
---|---|
access_key |
[Required] Your API Access Key. |
fields |
[optional] Set to your preferred output field(s) according to the Specify Output Fields section. |
hostname |
[optional] Set to 1 to enable Hostname Lookup. |
security |
[optional] Set to 1 to enable the Security module. |
language |
[optional] Set to a 2-letter language code according to the Specify Output Language section to change output 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. |
API Response:
{ "ip": "155.52.187.7", "type": "ipv4", "continent_code": "NA", "continent_name": "North America", "country_code": "US", "country_name": "United States", "region_code": "MA", "region_name": "Massachusetts", "city": "Boston", "zip": "02115", "latitude": 42.3424, "longitude": -71.0878, "location": { "geoname_id": 4930956, "capital": "Washington D.C.", "languages": [ { "code": "en", "name": "English", "native": "English" } ], "country_flag": "https://assets.ipstack.com/images/assets/flags_svg/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-03-30T07:54:25-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": 40127, "isp": "Longwood Medical and Academic Area (LMA)" } }<result> <ip>155.52.187.7</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>MA</region_code> <region_name>Massachusetts</region_name> <city>Boston</city> <zip>02115</zip> <latitude>42.3424</latitude> <longitude>-71.0878</longitude> <location> <geoname_id>4930956</geoname_id> <capital>Washington D.C.</capital> <languages> <code>en</code> <name>English</name> <native>English</native> </languages> <country_flag>https://assets.ipstack.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-03-30T07:54:25-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>40127</asn> <isp>Longwood Medical and Academic Area (LMA)</isp> </connection> </result>JSONXML
Response Objects: See the Response Objects section to view detailed descriptions for all API response objects and their values returned by the ipstack API.
Response Objects
Depending on your subscription plan and the options you choose for your API request, the ipstack API will respond using a series of different modules and objects. Find below a list of all available API response objects explained.
Scroll left & right to navigate
Response Object | Description |
---|---|
ip |
Returns the requested IP address. |
hostname |
Returns the hostname the requested IP resolves to, only returned if Hostname Lookup is enabled. |
type |
Returns the IP address type IPv4 or IPv6 . |
continent_code |
Returns the 2-letter continent code associated with the IP. View all 2-letter continent codes |
continent_name |
Returns the name of the continent associated with the IP. |
country_code |
Returns the 2-letter country code associated with the IP. List of all 2-letter country codes |
country_name |
Returns the name of the country associated with the IP. |
region_code |
Returns the region code of the region associated with the IP (e.g. CA for California). |
region_name |
Returns the name of the region associated with the IP. |
city |
Returns the name of the city associated with the IP. |
zip |
Returns the ZIP code associated with the IP. |
latitude |
Returns the latitude value associated with the IP. |
longitude |
Returns the longitude value associated with the IP. |
location |
[Object] Returns multiple location-related objects |
location > geoname_id |
Returns the unique geoname identifier in accordance with the Geonames Registry. |
location > capital |
Returns the capital city of the country associated with the IP. |
location > languages |
[Object] Returns an object containing one or multiple sub-objects per language spoken in the country associated with the IP. |
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 name (in the API request's main language) of the given language. (e.g. Portuguese ) |
location > languages > native |
Returns the native name of the given language. (e.g. Português ) |
location > country_flag |
Returns an HTTP URL leading to an SVG-flag icon for the country associated with the IP. |
location > country_flag_emoji |
Returns the emoji icon for the flag of the country associated with the IP. |
location > country_flag_emoji_unicode |
Returns the unicode value of the emoji icon for the flag of the country associated with the IP. (e.g. U+1F1F5 U+1F1F9 for the Portuguese flag) |
location > calling_code |
Returns the calling/dial code of the country associated with the IP. (e.g. 351 ) for Portugal. |
location > is_eu |
Returns true or false depending on whether or not the county associated with the IP is in the European Union. |
time_zone |
[Object] Returns an object containing timezone-related data. |
time_zone > id |
Returns the ID of the time zone associated with the IP. (e.g. America/Los_Angeles for PST) |
time_zone > current_time |
Returns the current date and time in the location associated with the IP. (e.g. 2018-03-29T22:31:27-07:00 ) |
time_zone > gmt_offset |
Returns the GMT offset of the given time zone in seconds. (e.g. -25200 for PST's -7h GMT offset) |
time_zone > code |
Returns the universal code of the given time zone. List of all available codes |
time_zone > is_daylight_saving |
Returns true or false depending on whether or not the given time zone is considered daylight saving time. |
currency |
[Object] Returns an object containing currency-related data. |
currency > code |
Returns the 3-letter code of the main currency associated with the IP. Example: USD - List of all available currency codes |
currency > name |
Returns the name of the given currency. |
currency > plural |
Returns the plural name of the given currency. |
currency > symbol |
Returns the symbol letter of the given currency. |
currency > symbol_native |
Returns the native symbol letter of the given currency. |
connection |
[Object] Returns an object containing connection-related data. |
connection > asn |
Returns the Autonomous System Number associated with the IP. |
connection > isp |
Returns the name of the ISP associated with the IP. |
security |
[Object] Returns an object containing security-related data. |
security > is_proxy |
Returns true or false depending on whether or not the given IP is associated with a proxy. |
security > proxy_type |
Returns the type of proxy the IP is associated with. View all potential proxy types |
security > is_crawler |
Returns true or false depending on whether or not the given IP is associated with a crawler. |
security > crawler_name |
Returns the name of the crawler the IP is associated with. |
security > crawler_type |
Returns the type of crawler the IP is associated with. View all potential crawler types |
security > is_tor |
Returns true or false depending on whether or not the given IP is associated with the anonymous Tor system. |
security > threat_level |
Returns the type of threat level the IP is associated with. View all threat levels |
security > threat_types |
[object] Returns an object containing all threat types associated with the IP. View all potential threat types |
Options
Specify Output Format
Using the ipstack API's output
parameter the API result format can be switched between JSON (default) and XML. Set the output
parameter to json
or xml
depending on your preference.
Requesting JSON Format
Sign Up to Run API Requesthttps://api.ipstack.com/134.201.250.155 ? access_key = YOUR_ACCESS_KEY & output = json
Requesting XML Format
Sign Up to Run API Requesthttps://api.ipstack.com/134.201.250.155 ? access_key = YOUR_ACCESS_KEY & output = xml
To see the API response, navigate to the API Response section.
Specify Response Fields
To save bandwidth and speed up response times, the ipstack API's fields
parameter can be used to limit API results to a certain object or set of objects.
This parameter is supported by all 3 API endpoints. To use this feature, append the fields
parameter to your API request URL and specify one of the following options:
fields = main // returns main API objects from "ip" to "longitude" fields = country_code // returns only the "country_code" object fields = location // returns the entire "location" object with sub-objects fields = location.capital // returns only the "capital" object inside "location" fields = country_code,location.capital // returns both the "country_code" and the "capital" object
Example Request:
Setting the fields
object to country_code
causes the ipstack API to return only the country_code
object.
Sign Up to Run API Requesthttps://api.ipstack.com/134.201.250.155 ? access_key = YOUR_ACCESS_KEY & fields = country_code
Example Response:
{ "country_code": "US" }
Important: Please note that modules not supported by your subscription plan (e.g. time_zone
on the Free Plan) will cause error 301
to be returned by the API. The same error will be shown when trying to access the Security Module without having set &security=1
in the API request.
Specify Response Language
The ipstack API is capable of delivering its result set in different languages. To request data in a language other than English (default), append the API's language
parameter to your API request URL and set it to one of the supported 2-letter language codes.
Supported languages:
en
- English/USde
- Germanes
- Spanishfr
- Frenchja
- Japanesept-br
- Portugues (Brazil)ru
- Russianzh
- Chinese
Example Request: In the following example request the language is set to de
for German.
Sign Up to Run API Requesthttps://api.ipstack.com/134.201.250.155 ? access_key = YOUR_ACCESS_KEY & language = de
Example Response: The API now responds in German.
{ "ip": "134.201.250.155", "type": "ipv4", "continent_code": "NA", "continent_name": "Nordamerika", <-- translated "country_code": "US", "country_name": "United States", "region_code": "CA", "region_name": "Kalifornien", <-- translated "city": "Los Angeles", "zip": "90013", "latitude": 34.0453, "longitude": -118.2413, "location": { ... }, "time_zone": { ... }, "currency": { ... }, "connection": { ... }, }<result> <ip>134.201.250.155</ip> <type>ipv4</type> <continent_code>NA</continent_code> <continent_name>Nordamerika</continent_name> <country_code>US</country_code> <country_name>United States</country_name> <region_code>CA</region_code> <region_name>Kalifornien</region_name> <city>Los Angeles</city> <zip>90013</zip> <latitude>34.0453</latitude> <longitude>-118.2413</longitude> <location> [...] </location> <time_zone> [...] </time_zone> <currency> [...] </currency> <connection> [...] </connection> </result>JSONXML
Please note that certain objects may not be subject to translation.
Enable Security Module
Customers subscribed to the Professional Plus Plan may access the ipstack API's Security Module, which can be used to assess risks and threats originating from certain IP addresses before any harm can be done to a website or web application.
In order to use this feature, append the API's security
parameter and set it to 1
.
Example Request:
Sign Up to Run API Requesthttps://api.ipstack.com/103.3.61.114 ? access_key = YOUR_ACCESS_KEY & security = 1
Example Response: If the Security Module is supported by your subscription plan, the API response will now contain a security
object. For illustration purposes the IP address 103.3.61.114
, which is known to be used by the Tor system, has been used for this example API request.
[...] "security": { "is_proxy": false, "proxy_type": null, "is_crawler": false, "crawler_name": null, "crawler_type": null, "is_tor": true, "threat_level": "high", "threat_types": [ "tor" ] } [...][...] <security> <is_proxy/> <proxy_type/> <is_crawler/> <crawler_name/> <crawler_type/> <is_tor/> <threat_level>low</threat_level> <threat_types/> </security> [...]JSONXML
To learn more about each security response object, please refer to the Response Objects section.
Enable Hostname Lookup
By default, the ipstack API does not return information about the hostname the given IP address resolves to. In order to include the hostname object in your API result, append the API's hostname
parameter and set it to 1
.
Example Request:
Sign Up to Run API Requesthttps://api.ipstack.com/160.39.144.19 ? access_key = YOUR_ACCESS_KEY & hostname = 1
Example Response: If Hostname Lookup is enabled, the API response will now come with a hostname
object containing the given hostname value.
{ "ip": "160.39.144.19", "hostname": "dyn-160-39-144-19.dyn.columbia.edu", [...] }<result> <ip>160.39.144.19</ip> <hostname>dyn-160-39-144-19.dyn.columbia.edu</type> [...] </result>JSONXML
Important: Hostname Lookup is disabled by default to reduce bandwidth. Please note that enabling Hostname Lookup may increase API response times.
Sample Code
PHP (cURL)
Standard Lookup: Find below an example for the Standard Lookup Endpoint using PHP cURL.
// set IP address and API access key $ip = '134.201.250.155'; $access_key = 'YOUR_ACCESS_KEY'; // Initialize CURL: $ch = curl_init('https://api.ipstack.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 "capital" object inside "location" echo $api_result['location']['capital'];
JavaScript (jQuery.ajax)
Standard Lookup: Find below an example for the Standard Lookup Endpoint using jQuery.ajax.
// 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.ipstack.com/' + ip + '?access_key=' + access_key, dataType: 'jsonp', success: function(json) { // output the "capital" object inside "location" alert(json.location.capital); } });