How to Use the IPstack API: From API Key to First Response in 2 Minutes

By the end of this guide you’ll have an API key, a working request, and parsed location data in your language of choice.

1

Step 1 - Create Your Account and Get Your API Key

Sign up at ipstack.com/signup/free with an email address. No credit card is required. The free IP API plan includes 100 requests a month, enough to complete this guide many times over.

Your access key appears on the dashboard as soon as you sign up. It is the only credential the API uses, passed as the access_key query parameter on every request.

Keep it server-side. Store the key in an environment variable like IPSTACK_KEY. A key in browser JavaScript is visible to anyone who opens the page source.

dashboard.ipstack.com
Your API Access Key
a1b2c3d4e5f6••••••••••Copy
↖ Find your key here, at the top of the dashboard

Illustration. The live dashboard may differ slightly.

2

Step 2 - Make Your First API Call

# cURL first: this is how you test
curl "https://api.ipstack.com/134.201.250.155?access_key=YOUR_KEY"
// Node 18+, no dependencies
const res = await fetch(
  `https://api.ipstack.com/134.201.250.155?access_key=${process.env.IPSTACK_KEY}`
);
const data = await res.json();
# Python 3, requests
import os, requests

data = requests.get(
    "https://api.ipstack.com/134.201.250.155",
    params={"access_key": os.environ["IPSTACK_KEY"]}
).json()
// PHP, no dependencies
$data = json_decode(file_get_contents(
  "https://api.ipstack.com/134.201.250.155?access_key=$key"
), true);

The Run in Postman collection is a ready-made client for testing. Free-plan keys call the API over http://, and HTTPS is included from Basic ($12.99/mo).

The response, annotated
{
  "ip": "134.201.250.155",      // the address you asked about
  "country_code": "US",            // ISO country
  "city": "Los Angeles",         // resolved city
  "latitude": 34.0453,            // area centroid, with longitude
  "longitude": -118.2413,
  "currency": { "code": "USD" }, // paid plans
  "security": {                  // Professional+
    "is_proxy": false,
    "threat_level": "low"
  }
}
3

Step 3 - Parse the Response and Use the Data

The response is a plain object, so use the data the way you would any parsed JSON. Here is the same visible result in each language: a location label built from two fields the free plan returns.

// "Los Angeles, US"
const { city, country_code } = data;
const label = `${city}, ${country_code}`;
document.querySelector("#geo-label").textContent = label;
# "Los Angeles, US"
label = f"{data['city']}, {data['country_code']}"
print(label)
// "Los Angeles, US"
$label = $data["city"] . ", " . $data["country_code"];
echo $label;

The Three IPstack Endpoints, Explained

All three endpoints share one base URL, and everything in this guide works on each of them.

EndpointURL shapeUse it when
Standard lookupGET /{ip}You have an address and want its profile. The workhorse for enrichment and checks.
Requester lookupGET /checkThe address you care about is whoever is calling. No IP extraction on your side.
Bulk lookup  PROFESSIONAL+GET /{ip1},{ip2},…Up to 50 addresses per request for logs, backfills, and batch enrichment.

For bulk and continuous check workflows, see the real-time IP lookup API.

Parameters That Change the Response

Append any of these to the query string. They combine freely.

ParameterExampleWhat it does
fields&fields=ip,city,country_codeReturns only the listed fields; dot notation reaches nested ones
hostname&hostname=1Adds reverse DNS for the address
security&security=1Includes the security block on plans that carry it
language&language=deLocalizes name fields into a supported language
output&output=xmlSwitches the response body from JSON to XML
callback&callback=myHandlerWraps the response for JSONP consumers

For output formats and payload trimming in depth, see the JSON IP API page.

Common Errors and How to Fix Them

Every error returns success: false plus a code. These three cover almost every first-week issue.

CodeWhat it meansHow to fix it
101Access key missing or invalidConfirm the environment variable loads and matches the key on your dashboard; watch for trailing whitespace
103Invalid API functionCheck the endpoint path for typos; only /{ip}, /check, and comma-separated bulk shapes exist
104Monthly request limit reachedWait for the monthly reset or upgrade from the dashboard; your key and code stay the same

The documentation lists every error code.

Global IP Data in One GET Request

One request returns location, network, and threat data for any IPv4 or IPv6 address.

Best Practices for Production

Cache what you look up

An IP's location changes slowly. A cache keyed by address with a sensible TTL cuts request volume without hurting freshness.

Keep the key out of clients

Keep the key in an environment variable on the server, and give browser code a proxy route instead. Anything shipped to a client is public.

Handle 104 before it happens

Catch the quota error, degrade gracefully, and alert yourself at 80% usage instead of discovering the limit in production. Upgrade options are on the pricing page.

Watch the status page

The API status page shows current availability; point your own uptime monitor at your integration too.

Building with AI agents?

IPstack's MCP server takes the same access key, and a connected coding agent can run these lookups while you work.

Explore IPstack MCP

Where to Go Next

Every field, in depth

What the 100+ fields mean and what teams build with them, industry by industry.

IP geolocation API

What costs nothing

The exact free-tier terms, the free-vs-paid matrix, and when upgrading starts to matter.

free IP API plan

The response, field by field

Response format, output switches, payload trimming, and copy-paste parsing recipes.

JSON IP API

Frequently Asked Questions - Using the IPstack API

Sign up at ipstack.com/signup/free with an email address; no credit card is needed. Your access key appears on the dashboard right after signup. Copy it into an environment variable and you are ready for Step 2 above; one key works across every endpoint.

Use /check: it resolves the address behind the request automatically, so GET https://api.ipstack.com/check?access_key=YOUR_KEY returns your visitor’s profile without you reading their IP first. It works on every plan. Prefer it whenever the address you care about belongs to whoever is calling you right now.

Join the addresses with commas in the URL path: https://api.ipstack.com/{ip1},{ip2},{ip3}?access_key=YOUR_KEY. The response becomes an array of result objects in the order you sent them, up to 50 per request on Professional+. Loop the array and parse each entry exactly like a single result.

Error 101 means the access key is missing or invalid: check that the environment variable actually loads and matches the dashboard. Error 104 means you hit your plan’s monthly request limit: wait for the reset or upgrade from the dashboard. Neither fix requires code changes, since your key and endpoints stay the same.

Yes: add output=xml to any request URL and the same data comes back as XML. Everything else stays identical, including field names and plan scope. Use it for legacy systems that expect XML; leave it off everywhere else, since JSON is the default and parses everywhere.

Any language that can send an HTTP GET works, which is effectively all of them. Official SDKs live at ipstack.com/sdk/, and the Postman collection gives you a no-code client for testing. The samples in this guide cover cURL, JavaScript, Python, and PHP.

Your first IPstack API response is 2 minutes away

Everything in this guide runs on a key you can create right now. Sign up, paste, and watch the JSON come back.