Quick Start
Every lookup is a single HTTP GET request. No SDK install, no OAuth handshake, no request signing — just a token and, optionally, an IP. The example below is real: it's the exact shape of data you'll get back for 8.8.8.8.
{
"ip": "8.8.8.8",
"hostname": "dns.google",
"country_code2": "US",
"country_code3": "USA",
"country_name": "United States",
"country_capital": "Washington",
"state_prov": "California",
"city": "Mountain View",
"zipcode": "94043",
"latitude": "37.4056",
"longitude": "-122.0775",
"is_eu": false,
"country_emoji": "🇺🇸",
"calling_code": "+1",
"country_tld": ".us",
"languages": "en",
"currency": {
"code": "USD",
"name": "Dollar",
"symbol": "$"
},
"time_zone": {
"name": "America/New_York",
"offset": -4,
"offset_with_dst": -3,
"current_time": "2026-08-21 03:12:46.964685-0400",
"current_time_unix": 1787296366.9647,
"current_tz_abbreviation": "EDT",
"current_tz_full_name": "America/New_York",
"is_dst": true
},
"asn": {
"asn": "AS15169",
"name": "Google LLC",
"domain": "google.com",
"route": "8.8.8.0/24",
"type": "hosting"
},
"company": {
"name": "AS15169 Google LLC",
"domain": "google.com",
"type": "isp"
},
"security": {
"is_tor": false,
"is_vpn": false,
"is_icloud_relay": false,
"is_proxy": false,
"is_datacenter": true,
"is_anonymous": false,
"is_known_attacker": false,
"is_known_abuser": false,
"is_threat": false,
"is_bogon": false,
"blocklists": [],
"scores": {
"vpn_score": 100,
"proxy_score": 1,
"threat_score": 100,
"trust_score": 33
}
}
}
Security and ASN Company Data fields availability depends on the subscription plan, starting from Pro Monthly plan.
See pricing for more details.
Try It Live
This calls the real IPFly API from your browser and renders the actual response — not a mock. Nothing is stored or logged by this page.
Enter your token above and click "Send request" to see a live response here.
Authentication
All requests require your API token as a query parameter. You can query your own IP by omitting the ip parameter.
Detect your own IP automatically:
Look up a specific IP address:
Get your API token by signing up for a free account.
Never call the IPFly API directly from client-side JavaScript, a mobile app bundle, or any code a user can inspect. Your token will be visible in network requests and can be extracted and abused by anyone viewing your page source. Always proxy requests through your own backend.
Restrict Your Token's Origin
Even proxied tokens are safer when locked down. In your dashboard, you can restrict a token to specific IPs and domains, so it stops working the moment it's used from anywhere else — including a leaked or stolen copy.
Leaving both fields empty allows requests from any origin. Once you add at least one IP or domain, the token only works from that allow-list — requests from anywhere else are rejected, even with a valid token.
Making Requests
All requests are simple HTTP GET calls. No special headers required. Every shaping option below is optional — a plain lookup with only token and ip behaves exactly as it always has.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Your API authentication token |
ip | string | No | IP address to lookup (IPv4 or IPv6). Omit to detect caller's IP. |
include | string | No | Add an optional group. Currently security — the threat-intelligence block. |
Response shaping parameters
These let you shape the answer to exactly what your integration needs — fewer keys, smaller payloads, a different structure. They work on both single lookups and bulk batches.
| Parameter | Type | Required | Description |
|---|---|---|---|
fields | string | No | Keep only these groups, keys or dotted paths. Details |
exclude | string | No | Drop these groups, keys or dotted paths from the answer. Details |
mask | string | No | Keep these keys but replace their values with null. Details |
flat | boolean | No | Flatten nested objects into dotted keys (asn.name). Details |
compact | boolean | No | Return the JSON without whitespace — typically 40–70% smaller. Details |
meta | boolean | No | Append a _meta block describing the request. Details |
Bulk parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
bulk | boolean | No | Run a bulk lookup. Requires bulk=true. |
ips | string | No | Comma separated IPs for a GET bulk lookup. On POST the IPs go in the JSON body instead. |
match | string | No | Bulk only — keep just the answers matching key:value rules. Details |
format | string | No | Bulk only — map (default) or array. Details |
Response headers
Every successful answer carries the current quota counters, so you can track usage without a second request.
| Header | Meaning | |
|---|---|---|
X-RateLimit-Daily-Used | number | Requests used today, after this one. |
X-RateLimit-Monthly-Used | number | Requests used this month, after this one. |
X-User-Plan | string | The plan the token is currently on. |
A note on IPv6
IPv6 addresses are fully supported and returned in the same response shape as IPv4 — pass them exactly as written (e.g. 2001:4860:4860::8888), no encoding needed. If a large share of your traffic is still IPv4-mapped through NAT64 or a CDN, expect the resolved location to reflect the edge or gateway, not the end user.
Bulk Lookups
One request, many IPs. The whole batch is resolved by the local lookup service in a single round trip, so a hundred addresses cost you a hundred lookups but only one HTTP call — and one round trip of latency instead of a hundred.
Request
Send the addresses as a JSON body:
{
"ips": ["8.8.8.8", "1.1.1.1", "9.9.9.9", "2001:4860:4860::8888"]
}For short batches a plain GET works too — handy from a browser, a bookmark or a health check:
Use POST for anything beyond a handful of addresses — URLs get truncated by proxies and browsers long before the batch limit, and a truncated batch fails with a confusing error rather than a partial result.
Response
The batch answers with a fixed envelope. Every address you sent appears in results, keyed by the address itself.
{
"plan": "free",
"requested": 3,
"successful": 3,
"matched": 3,
"results": {
"8.8.8.8": {
"ip": "8.8.8.8",
"hostname": "dns.google",
"country_code2": "US",
"country_name": "United States",
"city": "Mountain View",
"latitude": "37.4056",
"longitude": "-122.0775"
},
"1.1.1.1": {
"ip": "1.1.1.1",
"hostname": "one.one.one.one",
"country_code2": "AU",
"country_name": "Australia",
"city": "Sydney"
},
"9.9.9.9": {
"ip": "9.9.9.9",
"hostname": "dns.quad9.net",
"country_code2": "CH",
"country_name": "Switzerland",
"city": "Zurich"
}
}
}| Field | Type | Description |
|---|---|---|
plan | string | The plan the token is on. |
requested | number | How many addresses you sent (duplicates removed). |
successful | number | How many addresses resolved successfully. This is what the quota is charged for. |
matched | number | How many answers are left after an optional match filter. |
results | object | One entry per address, keyed by the address. See format=array for a list shape. |
Failed addresses
An address that cannot be resolved does not fail the whole batch — it carries its own error and the rest of the batch is unaffected:
{
"requested": 2,
"successful": 1,
"matched": 1,
"results": {
"8.8.8.8": { "ip": "8.8.8.8", "country_code2": "US", "...": "..." },
"not-an-ip": { "error": "Invalid IP address" }
}
}Quota is charged per address, not per request. A batch of 100 IPs consumes 100 lookups from your daily and monthly quota. The batch is rejected up front with 429 if the whole batch would push you over the limit — it never bills you for a batch it refuses.
Try a batch live
Paste a token and a few IPs, then hit "Send batch".
Bulk Filtering
Every shaping option from the response control section also applies to a batch — applied to each address individually. Two extra options are bulk only.
match — keep only what you care about
match takes one or more key:value rules and keeps only the answers that satisfy all of them. The rules can point at any field, including nested ones with a dotted path.
{
"plan": "free",
"requested": 4,
"successful": 4,
"matched": 2,
"results": {
"8.8.8.8": { "ip": "8.8.8.8", "country_code2": "US", "security": { "is_vpn": false } },
"9.9.9.9": { "ip": "9.9.9.9", "country_code2": "CH", "security": { "is_vpn": false } }
}
}| Rule | Matches on | Example |
|---|---|---|
key:value | A top level field, compared case-insensitively. | country_code2:US |
key.path:value | A nested field. | asn.type:hosting |
key:true | Boolean flags, spelled as true / false. | security.is_vpn:false |
| Several rules | Separated by commas — every rule must match for an answer to be kept. | country_code2:US,asn.type:hosting |
Filtering happens after the lookups, so every address in the batch is still charged to your quota even when the answer is dropped. Use fields to cut the payload size, not match, if you are trying to save quota.
format — map or array
By default the batch comes back as an object keyed by address. format=array turns it into a list where each entry carries its own ip — often easier to stream into a CSV, a spreadsheet or a queue.
{
"requested": 2,
"successful": 2,
"matched": 2,
"results": [
{ "ip": "8.8.8.8", "country_code2": "US", "city": "Mountain View" },
{ "ip": "1.1.1.1", "country_code2": "AU", "city": "Sydney" }
]
}Shaping a batch
fields, exclude, mask, flat, compact and meta all work on a batch. fields and exclude are applied to every address in the batch; flat flattens each answer; compact removes the whitespace from the whole envelope; meta adds a _meta block next to results.
{
"requested": 1,
"successful": 1,
"matched": 1,
"results": {
"8.8.8.8": {
"country_name": "United States",
"asn.name": "Google LLC"
}
}
}Bulk Code Examples
The same batch in four languages. Every snippet uses only the standard library or one common HTTP package.
curl -X POST "https://ipfly.world/api?token=YOUR_TOKEN&bulk=true" \
-H "Content-Type: application/json" \
-d '{"ips":["8.8.8.8","1.1.1.1","9.9.9.9"]}'
# Smaller payload, only the fields you need
curl -X POST "https://ipfly.world/api?token=YOUR_TOKEN&bulk=true&fields=ip,country_code2,city&compact=true" \
-H "Content-Type: application/json" \
-d '{"ips":["8.8.8.8","1.1.1.1"]}' | jq .resultsconst res = await fetch(
'https://ipfly.world/api?token=YOUR_TOKEN&bulk=true&fields=ip,country_code2,city',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ips: ['8.8.8.8', '1.1.1.1', '9.9.9.9'] })
}
);
const data = await res.json();
for (const [ip, info] of Object.entries(data.results)) {
console.log(ip, info.country_code2, info.city);
}async function bulkLookup(ips) {
const url = new URL('https://ipfly.world/api');
url.searchParams.set('token', process.env.IPFLY_TOKEN);
url.searchParams.set('bulk', 'true');
url.searchParams.set('compact', 'true');
const res = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ips })
});
if (!res.ok) throw new Error(`IPFly ${res.status}`);
return res.json();
}
const batch = await bulkLookup(['8.8.8.8', '1.1.1.1']);
console.log(batch.successful, 'of', batch.requested, 'resolved');import os
import requests
def bulk_lookup(ips, fields=None, timeout: float = 10.0) -> dict:
params = {"token": os.environ["IPFLY_TOKEN"], "bulk": "true"}
if fields:
params["fields"] = fields
r = requests.post(
"https://ipfly.world/api",
params=params,
json={"ips": ips},
timeout=timeout,
)
r.raise_for_status()
return r.json()
data = bulk_lookup(["8.8.8.8", "1.1.1.1"], fields="ip,country_code2,city")
for ip, info in data["results"].items():
print(ip, info.get("city"))<?php
$url = 'https://ipfly.world/api?token=' . urlencode($_ENV['IPFLY_TOKEN']) . '&bulk=true&compact=true';
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(['ips' => ['8.8.8.8', '1.1.1.1']]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_TIMEOUT => 10,
]);
$body = curl_exec($ch);
curl_close($ch);
$data = json_decode($body, true);
foreach ($data['results'] as $ip => $info) {
echo $ip . ' ' . ($info['city'] ?? '') . PHP_EOL;
}Field Groups
Every field the API can return belongs to one of four groups. Groups are the coarse unit of what a plan unlocks; individual fields inside them are yours to pick.
| Group | Contains | How to get it |
|---|---|---|
geo |
ip, hostname, country_code2, country_code3, country_name, country_capital, state_prov, state_code, district, city, zipcode, latitude, longitude, is_eu, country_emoji, calling_code, country_tld, languages, currency, time_zone |
Included by default on every plan. |
asn |
The asn object — AS number, name, domain, route, type. |
Included by default from the Pro Monthly plan up. |
company |
The company object — organisation name, domain, type. |
Included by default from the Pro Monthly plan up. |
security |
The security object — VPN, proxy, Tor and threat flags, blocklists, scores. |
Never included by default. Ask for it explicitly with include=security. |
The security group is opt-in
Threat data costs an extra outbound lookup per address, so it is never bundled into a normal request. Requesting it is a single extra parameter, on top of being on a plan that includes it:
Asking for the security group without include=security does not enable it — the flags stay out of the answer and no paid lookup is made. In a bulk batch, add include=security to the URL once and it applies to every address in the batch.
Field Filtering
The fields parameter decides what comes back. You can ask for a whole group, a single key, or a single key inside a nested object — and you get exactly that, nothing else.
Three ways to name a field
| Form | Example | What you get |
|---|---|---|
group | fields=geo | Every field of that group, including the nested objects inside it. |
key | fields=city | Just that top level key. |
key.path | fields=asn.name | Just that key inside a nested object. |
{
"ip": "8.8.8.8",
"hostname": "dns.google",
"country_code2": "US",
"country_name": "United States",
"city": "Mountain View",
"latitude": "37.4056",
"longitude": "-122.0775",
"time_zone": { "name": "America/New_York", "offset": -4 },
"asn": { "asn": "AS15169", "name": "Google LLC" }
}
{
"ip": "8.8.8.8",
"country_code2": "US",
"city": "Mountain View",
"asn": {
"name": "Google LLC"
}
}
Things worth knowing
The answer is literal
If you ask for fields=city you get city and nothing else — not even ip. Add the keys you actually need, ip included, and your payload shrinks with it.
Unknown names are ignored
A field that does not exist in the answer is skipped, and if none of the requested fields exist the answer is returned untouched — a typo never leaves you with an empty object.
Your plan still decides
Filtering narrows what your plan already gives you — it never unlocks a group you have not paid for. Asking for asn.name on a plan without ASN data returns an answer with no ASN block in it.
Cheaper and smaller
Fewer keys means a smaller body over the wire and less parsing on your side. Combine it with compact for the smallest possible payload.
Exclude & Mask
Sometimes it is easier to say what you don't want. exclude removes keys entirely, mask keeps them but blanks the value — useful when the shape of your payload must stay stable but the data should not travel.
| Parameter | Effect | Use it when |
|---|---|---|
exclude | The key is removed from the answer entirely. | You do not want the data at all, and want the smallest payload. |
mask | The key stays, its value becomes null. | Your schema expects the key, but the value must not leave your infrastructure. |
Both take the same names as fields — a group, a top level key, or a dotted path:
| Name | Applies to |
|---|---|
geo, asn, company, security | Every top level field of that group. |
hostname, city, zipcode | That single top level key. |
time_zone.current_time, security.scores | That single key inside a nested object. |
{
"ip": "8.8.8.8",
"hostname": "dns.google",
"city": "Mountain View",
"latitude": "37.4056",
"longitude": "-122.0775",
"time_zone": { "name": "America/New_York" }
}
{
"ip": "8.8.8.8",
"city": "Mountain View",
"latitude": null,
"longitude": null
}
Tip: mask the coordinates when you need the country but not the exact position. It is a one-line defence against turning a geolocation API into a precise location tracker — and it keeps your response schema stable, so the client code does not need a second code path.
fields, exclude and mask can be combined. fields picks the whitelist, exclude removes from it and mask blanks what is left — in that order.
Flatten & Compact
Two options that change the shape and the size of the payload, without touching a single value.
flat — one level, dotted keys
flat=true turns every nested object into dotted keys at the root. It is the difference between walking a tree and reading a row, which makes it the right option for CSV exports, spreadsheet imports and column-oriented databases.
{
"ip": "8.8.8.8",
"city": "Mountain View",
"asn": {
"asn": "AS15169",
"name": "Google LLC"
},
"security": {
"is_vpn": false
}
}
{
"ip": "8.8.8.8",
"city": "Mountain View",
"asn.asn": "AS15169",
"asn.name": "Google LLC",
"security.is_vpn": false
}
Lists stay lists — security.blocklists is still an array under its dotted key. Only objects are flattened.
compact — no whitespace
compact=true returns the same JSON without the pretty printing. Most answers are 40–70% smaller this way, which matters when you are pulling millions of records through a bulk endpoint.
{"ip":"8.8.8.8","hostname":"dns.google","country_code2":"US","city":"Mountain View","asn":{"asn":"AS15169","name":"Google LLC"}}Combine the two for the smallest possible answer:
Response Metadata
meta=true adds a _meta block to the answer describing the request that produced it — the plan it ran on, the groups that were resolved, which filters were applied, and when it happened.
{
"ip": "8.8.8.8",
"country_code2": "US",
"city": "Mountain View",
"_meta": {
"ip": "8.8.8.8",
"plan": "free",
"groups": ["geo", "asn"],
"timestamp": "2026-11-27T09:41:12Z",
"filters": {
"fields": "country_code2,city",
"exclude": null,
"mask": null,
"flat": false,
"compact": false
}
}
}| Field | Type | Description |
|---|---|---|
_meta.ip | string | The address that was looked up. |
_meta.plan | string | The plan the token is on. |
_meta.groups | array | The field groups that were resolved for this request. |
_meta.timestamp | string | When the answer was produced, in UTC (ISO 8601). |
_meta.filters | object | Which shaping options were applied to this answer. |
In a bulk batch the _meta block sits next to results and describes the batch instead of a single address:
{
"plan": "free",
"requested": 2,
"successful": 2,
"matched": 2,
"results": { "...": "..." },
"_meta": {
"plan": "free",
"groups": ["geo"],
"timestamp": "2026-11-27T09:41:12Z",
"filters": {
"fields": null,
"exclude": null,
"mask": null,
"match": "country_code2:US",
"flat": false,
"compact": false,
"format": "map"
}
}
}Tip: store the timestamp alongside your cached answers. It tells you exactly how fresh a cached record is, without having to guess from your own write time.
Sandbox & Test IPs
A handful of well-known, stable IPs are useful for integration tests and demos because their location and network ownership rarely change.
| IP | Good for testing | Typical result |
|---|---|---|
8.8.8.8 | Standard US result, hosting-type ASN | 🇺🇸Mountain View, CA — Google LLC |
1.1.1.1 | Anycast edge network, non-US | 🇦🇺Sydney/Anycast — Cloudflare |
9.9.9.9 | Privacy-focused resolver, EU-adjacent | 🇨🇭Quad9 Foundation |
2001:4860:4860::8888 | IPv6 code path | Same fields as IPv4, Google IPv6 DNS |
127.0.0.1 / 10.0.0.0/8 | Negative test — private/reserved ranges | Returns an error; these are never publicly routable |
A common first bug: testing from localhost during development. Your server's outbound IP (not 127.0.0.1) is what gets geolocated — if you're behind a home router or corporate NAT, expect an approximate result centered on your ISP, not your exact address. This is expected behavior for every IP geolocation provider, not an IPFly-specific limitation.
Standalone Fields
Root-level fields returned for every lookup.
| Field | Type | Description | Status |
|---|---|---|---|
ip | string | The queried IP address. | Required |
hostname | string | Reverse DNS hostname of the IP. | Required |
country_code2 | string | ISO 3166-1 alpha-2 country code. | Required |
country_code3 | string | ISO 3166-1 alpha-3 country code. | Required |
country_name | string | Common name of the country. | Required |
country_capital | string | Capital city of the country. | Required |
country_emoji | string | Country flag emoji. | Required |
calling_code | string | International dialing code. | Required |
country_tld | string | Country code top-level domain (e.g. .ua). | Required |
languages | string | Official languages of the country. | Required |
is_eu | boolean | Whether the country is an EU member. | Required |
Location Object
Detailed geographic data for the IP address.
| Field | Type | Description | Status |
|---|---|---|---|
state_prov | string | State / province / region name. | Optional |
state_code | string | State/province code. | Optional |
district | string | District or sub-region. | Optional |
city | string | City name. | Optional |
zipcode | string | ZIP / postal code. | Optional |
latitude | string | Latitude coordinate. | Required |
longitude | string | Longitude coordinate. | Required |
ASN Object
Autonomous System Number information.
| Field | Type | Description |
|---|---|---|
asn.asn | string | AS number (e.g. AS15169). |
asn.name | string | Organization name. |
asn.domain | string | Organization's domain. |
asn.route | string | IP route/prefix (CIDR notation). |
asn.type | string | Network type: isp, hosting, business, education. |
Timezone Object
Current time and timezone data for the IP's location.
| Field | Type | Description |
|---|---|---|
time_zone.name | string | IANA timezone name (e.g. Europe/Paris). |
time_zone.offset | number | UTC offset in hours (without DST). |
time_zone.offset_with_dst | number | UTC offset including DST. |
time_zone.current_time | string | Current local time string. |
time_zone.current_time_unix | number | Current time as Unix timestamp. |
time_zone.current_tz_abbreviation | string | Timezone abbreviation (e.g. EEST). |
time_zone.is_dst | boolean | Whether DST is currently active. |
Security Object
Threat intelligence and anonymization detection flags.
| Field | Type | Description |
|---|---|---|
security.is_tor | boolean | Whether the IP is a Tor exit node. |
security.is_vpn | boolean | Whether the IP is a used for VPN. |
security.is_icloud_relay | boolean | Whether the IP is a iCloud Apple proxy. |
security.is_proxy | boolean | Whether the IP is a known proxy. |
security.is_datacenter | boolean | Whether the IP belongs to a datacenter allocation. |
security.is_anonymous | boolean | Whether the IP is a used for anonymization. |
security.is_known_attacker | boolean | Whether the IP is used for DoS attacks, flood etc. |
security.is_known_abuser | boolean | Whether the IP is a used for abusing like hijack, malware etc. |
security.is_threat | boolean | Whether the IP belongs to a high and risk threat. |
security.is_bogon | boolean | Whether the IP belongs to a bogon CIDR ranges. |
security.blocklists | boolean | Whether the IP belongs to a specific organic ban-lists. |
security.scores | boolean | IP Reputation scores for VPN, Proxy, Threat and Trust Score. |
Currency Object
Local currency information for the IP's country.
| Field | Type | Description |
|---|---|---|
currency.code | string | ISO 4217 currency code (e.g. EUR). |
currency.name | string | Currency name (e.g. Euro). |
currency.symbol | string | Currency symbol (e.g. €). |
Errors & Status Codes
The API uses standard HTTP status codes: 2xx for success, 4xx for problems with the request, 5xx for problems on our end. Every error also returns a JSON body so you can branch on error.code without parsing status text.
| Status | Meaning | Typical cause |
|---|---|---|
| 200 | OK | Lookup succeeded. |
| 400 | Bad Request | Malformed or unparseable IP address. |
| 401 | Unauthorized | Missing or invalid token. |
| 403 | Forbidden | Token valid but suspended, or plan doesn't include this field set. |
| 404 | Not Found | No record for a private, reserved, or bogon IP. |
| 500 / 503 | Server Error | Transient issue on our side. Safe to retry with backoff. |
Example error response
{
"error": "Invalid API token! Please recheck your token or sign up at https://ipfly.world/billing"
}
Tip: check error.code rather than the human-readable message in your code — the message text is meant for logs and dashboards, and its wording may evolve over time, while the code is stable.
Rate Limits
Every plan carries a daily and a monthly request quota. The counters reset at midnight UTC and at the start of each billing month. Bulk requests are charged per address, so a batch of 100 consumes 100 lookups from your quota — but only one HTTP request.
Reading your usage
Every answer carries the current counters in its headers, so you can track usage without spending a request on a separate "usage" call:
| Header | Meaning | |
|---|---|---|
X-RateLimit-Daily-Used | number | Lookups used today, counted after this request. |
X-RateLimit-Monthly-Used | number | Lookups used this billing month, counted after this request. |
X-User-Plan | string | The plan the token is currently on. |
When you hit the limit
An exhausted quota returns 429 with the counters in the body, so your integration can tell "you are out of quota" apart from "that IP does not exist":
{
"error": "You've exceeded your daily request quota. Please upgrade your plan at https://ipfly.world/billing",
"limit": 100,
"used": 100,
"remaining": 0,
"plan": "free"
}Tip: a bulk request is rejected up front when the whole batch would push you over the limit — the API checks the batch size against the remaining quota before resolving anything, so a refused batch is never billed. Split the batch to fit instead.
Filtering does not refund quota. fields, exclude, mask and match run after the lookups are resolved, so an address that gets filtered out of the answer was still looked up and still counted. Use them to shape responses, not to avoid the cost of a lookup.
Best Practices
A few patterns that separate integrations that hold up in production from ones that break under real traffic.
Cache by IP
A given IP's location rarely changes hour to hour. Cache responses for 12–24 hours keyed on the IP to cut request volume dramatically — most apps see 80%+ cache hit rates once traffic has a returning-user base.
Keep the token server-side
Proxy lookups through your own backend. A token embedded in a browser bundle or mobile app will eventually be scraped and used to burn your quota.
Treat security flags as signals, not verdicts
is_vpn, is_proxy, and is_tor are strong risk signals, not proof of intent. Combine them with your own account and behavior signals before blocking a user outright — false positives on shared corporate NATs and mobile carrier gateways are common across every provider.
Fail open, not closed
If a lookup errors or times out, don't block the user's core action (checkout, login, page load) on it. Default to a safe fallback — e.g. no personalization, or a conservative currency — and log the failure for later review.
Batch thoughtfully
Processing a large IP list (log analysis, offline enrichment)? Parallelize with a bounded worker pool (5–10 concurrent requests) instead of firing everything at once — it's both friendlier to the API and easier to reason about failures.
Mind data-retention rules
An IP address paired with derived location data can count as personal data under GDPR and similar regimes. If you store lookups long-term, apply the same retention and deletion policies you use for other user PII.
Code Examples
The same lookup in six languages. Every snippet uses only the standard library or a single common HTTP package — no IPFly-specific SDK required.
curl "https://ipfly.world/api?token=YOUR_TOKEN" curl "https://ipfly.world/api?token=YOUR_TOKEN&ip=8.8.8.8" # Pretty-print with jq curl -s "https://ipfly.world/api?token=YOUR_TOKEN&ip=8.8.8.8" | jq .
const res = await fetch('https://ipfly.world/api?token=YOUR_TOKEN&ip=8.8.8.8');
if (!res.ok) throw new Error(`IPFly error: ${res.status}`);
const data = await res.json();
console.log(data.country_name); // "United States"
console.log(data.city); // "Mountain View"
console.log(data.security.is_vpn); // false
console.log(data.currency.symbol); // "$"// Native fetch, no dependencies needed on Node 18+
async function lookupIP(ip) {
const url = new URL('https://ipfly.world/api');
url.searchParams.set('token', process.env.IPFLY_TOKEN);
if (ip) url.searchParams.set('ip', ip);
const res = await fetch(url);
if (!res.ok) throw new Error(`IPFly ${res.status}`);
return res.json();
}
const geo = await lookupIP('8.8.8.8');
console.log(geo.country_name, geo.asn.name);<?php
$url = 'https://ipfly.world/api?token=' . urlencode($_ENV['IPFLY_TOKEN']) . '&ip=8.8.8.8';
$ctx = stream_context_create(['http' => ['timeout' => 5]]);
$json = @file_get_contents($url, false, $ctx);
if ($json === false) {
// network-level failure — fail open
exit;
}
$data = json_decode($json, true);
if (isset($data['error'])) {
error_log('IPFly error: ' . $data['error']['code']);
exit;
}
echo $data['country_name']; // "United States"
echo $data['security']['is_vpn']; // falseimport os
import requests
def lookup_ip(ip: str | None = None, timeout: float = 5.0) -> dict:
params = {"token": os.environ["IPFLY_TOKEN"]}
if ip:
params["ip"] = ip
r = requests.get("https://ipfly.world/api", params=params, timeout=timeout)
r.raise_for_status()
return r.json()
data = lookup_ip("8.8.8.8")
print(data["city"], data["asn"]["name"]) # Mountain View Google LLCimport java.net.URI;
import java.net.http.*;
import java.time.Duration;
var client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(5))
.build();
var request = HttpRequest.newBuilder()
.uri(URI.create("https://ipfly.world/api?token=" + System.getenv("IPFLY_TOKEN") + "&ip=8.8.8.8"))
.timeout(Duration.ofSeconds(5))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() != 200) {
throw new RuntimeException("IPFly error: " + response.statusCode());
}
System.out.println(response.body());require 'net/http'
require 'json'
uri = URI("https://ipfly.world/api")
uri.query = URI.encode_www_form(token: ENV['IPFLY_TOKEN'], ip: '8.8.8.8')
response = Net::HTTP.get_response(uri)
data = JSON.parse(response.body)
raise "IPFly error: #{data['error']['code']}" if data['error']
puts data['country_name']
puts data['security']['is_vpn']package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"os"
"time"
)
func main() {
q := url.Values{}
q.Set("token", os.Getenv("IPFLY_TOKEN"))
q.Set("ip", "8.8.8.8")
client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Get("https://ipfly.world/api?" + q.Encode())
if err != nil {
panic(err)
}
defer resp.Body.Close()
var data map[string]interface{}
json.NewDecoder(resp.Body).Decode(&data)
fmt.Println(data["country_name"])
}Build on reliable IP Intelligence
Start with free requests per day. No credit card. No commitments. Scale when you’re ready.