ASN Data API
You need reliable ASN data enriched with IP geolocation and network security context so you can make real-time decisions (routing, fraud checks, compliance gating) with minimal integration work. By the end of this post, you’ll query an IP, parse the ASN and security fields, and ship a production-ready integration that caches responses, handles timezones, and respects authentication and pricing constraints.
What this API returns and why ASN matters
The ASN tells you which autonomous system an IP is announced from, which is essential for traffic policy, analytics, and abuse mitigation. The same response also includes geolocation, ISP/organization names, and a minimal security profile (proxy, VPN, and cloud-provider flags). You’ll request a single endpoint and receive a consolidated JSON payload that is easy to parse in any stack.
- Endpoint: /api/ip
- Method: GET
- Auth: Authorization: Bearer YOUR_KEY
- Transport: HTTPS (JSON)
This post stays within the single documented path and official sample response so you can copy exactly what’s shown and trust it to work.
Authentication, base URL, and environments
All requests must include an Authorization header with a Bearer token. Replace only the token value with your key; do not modify the header name or schema. Use the same header in all environments (local, CI, production).
- Base URL: https://ipxapi.com
- Endpoint path: /api/ip
- Header: Authorization: Bearer YOUR_KEY
- Accept header: application/json
For machine-to-machine connectivity or serverless execution contexts, the MCP endpoint is also available here: MCP. Keep the same authorization pattern.
Quickstart: one curl to get ASN data for a fixture IP
The following request uses the documented fixture IP. Copy and run it as-is after inserting your key. Live flags can change; treat the example as a product fixture, not as your current IP.
curl "https://ipxapi.com/api/ip?ip=148.105.12.120" -H "Accept: application/json" -H "Authorization: Bearer YOUR_KEY"
Official JSON sample (fixture)
Below is the official product-fixture JSON. Use it to wire your parser, unit tests, and field mapping. The key you’ll typically read for ASN is as. Security information is under the security object.
{"status":"success","country":"United States","countryCode":"US","region":"US-CA","regionName":"California","city":"Mountain View","zip":"94043","lat":37.40599,"lon":-122.0786,"timezone":"America/Los_Angeles","isp":"MailChimp","org":"MailChimp","as":"AS14782 MailChimp","query":"148.105.12.120","inEU":false,"continentCode":"NA","security":{"is_proxy":false,"is_vpn":false,"is_cloud_provider":true}}
Same official JSON (expanded formatting)
This is the same fixture in expanded form. Copy it for local test fixtures, mocks, and schema validation. Do not alter field names or nesting.
{
"status": "success",
"country": "United States",
"countryCode": "US",
"region": "US-CA",
"regionName": "California",
"city": "Mountain View",
"zip": "94043",
"lat": 37.40599,
"lon": -122.0786,
"timezone": "America/Los_Angeles",
"isp": "MailChimp",
"org": "MailChimp",
"as": "AS14782 MailChimp",
"query": "148.105.12.120",
"inEU": false,
"continentCode": "NA",
"security": {
"is_proxy": false,
"is_vpn": false,
"is_cloud_provider": true
}
}
Important fields you’ll likely use:
- as — ASN string (e.g., “AS14782 MailChimp”).
- isp, org — network/organizational names associated with the IP.
- country, region, regionName, city, zip — location context.
- lat, lon — numeric coordinates (WGS84 in decimal degrees).
- timezone — IANA timezone name.
- security.is_proxy, security.is_vpn, security.is_cloud_provider — boolean indicators.
- query — the IP that was requested.
Language example: JavaScript fetch
This example fetches the same endpoint, validates the HTTP response, and extracts ASN, organization, and security flags. It uses the documented fixture IP to keep your first run deterministic.
async function lookupIp() {
const url = "https://ipxapi.com/api/ip?ip=148.105.12.120";
const res = await fetch(url, {
headers: {
"Accept": "application/json",
"Authorization": "Bearer YOUR_KEY"
},
// Optionally set a short timeout strategy with AbortController in production.
});
if (!res.ok) {
// Bubble up the HTTP status and body for observability.
const text = await res.text().catch(() => "");
throw new Error(`ipxapi request failed: ${res.status} ${res.statusText} :: ${text}`);
}
const data = await res.json();
// Minimal parsing of the fields you’ll actually use
const asn = data.as; // e.g., "AS14782 MailChimp"
const isp = data.isp;
const org = data.org;
const country = data.country;
const region = data.region;
const city = data.city;
const sec = data.security || {};
const isProxy = !!sec.is_proxy;
const isVpn = !!sec.is_vpn;
const isCloud = !!sec.is_cloud_provider;
return {
asn,
isp,
org,
country,
region,
city,
isProxy,
isVpn,
isCloud,
timezone: data.timezone,
coordinates: [data.lat, data.lon],
ip: data.query
};
}
// Example usage
lookupIp()
.then(result => {
console.log("ASN:", result.asn);
console.log("Org:", result.org, "ISP:", result.isp);
console.log("Security - proxy:", result.isProxy, "vpn:", result.isVpn, "cloud:", result.isCloud);
console.log("Geo:", result.country, result.region, result.city, "TZ:", result.timezone);
})
.catch(err => {
console.error("Lookup error:", err);
});
Practical integration details that save time
- Timezones: timezone is an IANA string (e.g., America/Los_Angeles). Use a library like Intl APIs or moment-timezone for conversions if needed.
- Coordinates: lat and lon are decimal degrees; treat them as doubles. When caching, store as numbers, not strings, to avoid parsing overhead.
- Caching: IP-to-attributes data changes relatively infrequently. A TTL of hours to a few days is common, but set a shorter TTL for security flags if your risk model requires it. Consider negative caching for known invalid inputs.
- Idempotence: GET /api/ip is safe to re-try on transient failures. Use exponential backoff and a circuit breaker in production.
- Input validation: Always validate that the input is a syntactically valid IPv4/IPv6 before calling the API to avoid noisy logs and wasted requests.
- Observability: Log query (the IP), status, and a hash of the response to monitor drift without storing full PII indefinitely.
- Privacy: Geolocation and ASN data can be sensitive under some policies. Coordinate with your privacy team on retention and data subject access requests.
Use cases: from ASN to policy decisions
ASN and security flags help you decide how to treat requests:
- Access policy: Deny or challenge traffic from known cloud providers when your app expects consumer last-mile networks.
- Fraud and abuse: Weight risk scoring if is_proxy or is_vpn flag is true. Keep the exact risk logic in your own codebase.
- Localization: Use country/region/city and timezone to set sensible defaults, then prompt users for confirmation.
- Routing and analytics: Group traffic by ASN or org to understand network-level usage patterns.
Keep your logic defensive: treat missing fields as unknown rather than safe or unsafe. Always check for the presence of security and as keys before using them.
Error handling and robustness
Handle three classes of errors: transport (network timeouts), HTTP (non-2xx), and semantic (status not success, or required fields missing). Log enough context to debug, but avoid storing full responses indefinitely.
- Network timeouts: Retry with backoff. Use AbortController in fetch or equivalent in your HTTP client.
- HTTP 4xx: Fix input or credentials. Do not retry blindly.
- HTTP 5xx: Retry with jitter and fall back to cached data when available.
- Semantic issues: If status is not success or fields like as are null, skip policy changes and mark the decision as unknown.
Testing: stable fixtures you can trust
Use the official fixture below to pin unit tests and ensure your parser survives formatting differences (compact vs formatted). Do not substitute fields or rename keys; keep them exactly as shown.
{"status":"success","country":"United States","countryCode":"US","region":"US-CA","regionName":"California","city":"Mountain View","zip":"94043","lat":37.40599,"lon":-122.0786,"timezone":"America/Los_Angeles","isp":"MailChimp","org":"MailChimp","as":"AS14782 MailChimp","query":"148.105.12.120","inEU":false,"continentCode":"NA","security":{"is_proxy":false,"is_vpn":false,"is_cloud_provider":true}}
For integration tests that snapshot responses, you can also include the expanded version to test your unmarshalling logic across whitespace and indentation changes.
{
"status": "success",
"country": "United States",
"countryCode": "US",
"region": "US-CA",
"regionName": "California",
"city": "Mountain View",
"zip": "94043",
"lat": 37.40599,
"lon": -122.0786,
"timezone": "America/Los_Angeles",
"isp": "MailChimp",
"org": "MailChimp",
"as": "AS14782 MailChimp",
"query": "148.105.12.120",
"inEU": false,
"continentCode": "NA",
"security": {
"is_proxy": false,
"is_vpn": false,
"is_cloud_provider": true
}
}
Schema notes and field mapping
Keep your internal model close to the response structure to reduce impedance. The keys you’ll reach for most often in ASN workflows are as, isp, org, and security.*. Do not rename these in transit; map them at the edge of your domain model.
- as: string containing “AS
”. Do not split unless you control all edge cases. - security: object with boolean flags. Defaults are not implied; check presence.
- lat, lon: numeric. Avoid locale-sensitive parsing; always parse as English decimal.
- timezone: IANA identifier. Hand to standard libraries for offsets and DST.
Reference fixture again for schema stability:
{
"status": "success",
"country": "United States",
"countryCode": "US",
"region": "US-CA",
"regionName": "California",
"city": "Mountain View",
"zip": "94043",
"lat": 37.40599,
"lon": -122.0786,
"timezone": "America/Los_Angeles",
"isp": "MailChimp",
"org": "MailChimp",
"as": "AS14782 MailChimp",
"query": "148.105.12.120",
"inEU": false,
"continentCode": "NA",
"security": {
"is_proxy": false,
"is_vpn": false,
"is_cloud_provider": true
}
}
Pricing, trial, and request planning
The Basic plan is $29.99/mo. The trial runs for 7 days or 50 requests (whichever comes first). Use caching and batching at the edge of your application to minimize duplicate lookups, especially during sign-in storms or bot spikes. Monitor your usage and set alerts in your platform before you start a high-volume campaign.
For feature specifics, consult the Documentation. Do not rely on assumptions about hidden parameters or secondary endpoints—stick to the documented ones.
Security and key management
Never embed your key in client-side code shipped to browsers or mobile apps. Proxy calls through your server, inject the Authorization header at the server, and apply request-level ACLs and rate limits. Rotate keys periodically and store them in a secrets manager compatible with your deployment stack.
Operational tips: latency, fallbacks, and observability
Place the lookup as early as possible in your request lifecycle if it gates downstream work (e.g., fraud scoring) but after trivial input validation to avoid unnecessary network calls. Consider a low-latency cache (in-memory or Redis) keyed by IP with TTLs tuned to your threat model.
- Latency: Co-locate your services with ipxapi egress where possible. Use keep-alive connections.
- Fallbacks: On transient errors, fall back to the last-known-good cached value rather than skipping checks entirely.
- Metrics: Track response time, error rates, cache hit ratio, and the rate of security flag changes over time.
Field-by-field walkthrough using the official sample
This final example reiterates the official payload so you can follow along field by field when mapping into your code. Copy the JSON as-is for your tests; do not modify the values.
{"status":"success","country":"United States","countryCode":"US","region":"US-CA","regionName":"California","city":"Mountain View","zip":"94043","lat":37.40599,"lon":-122.0786,"timezone":"America/Los_Angeles","isp":"MailChimp","org":"MailChimp","as":"AS14782 MailChimp","query":"148.105.12.120","inEU":false,"continentCode":"NA","security":{"is_proxy":false,"is_vpn":false,"is_cloud_provider":true}}
Use as for ASN-aware routing and analytics. Use security.is_cloud_provider to adjust heuristics when you expect consumer traffic. Pair timezone with country/region for default locale choices.
FAQ
What endpoint should I call to get ASN data?
Call GET /api/ip with the ip query parameter and include Authorization: Bearer YOUR_KEY. See the Quickstart curl example above.
Which field contains the ASN?
Use the as field. Keep the full string and parse only if your logic requires splitting the number and name.
How should I cache responses?
Cache by IP with a TTL aligned to your risk tolerance. A few hours is common, but use shorter TTLs if you rely heavily on security flags.
Can I detect proxies, VPNs, or cloud providers?
Yes. Read security.is_proxy, security.is_vpn, and security.is_cloud_provider. Treat missing fields as unknown rather than safe or unsafe.
How do I try this without committing to a paid plan?
Use the trial: 7 days or 50 requests. Integrate with the fixture IP, then expand gradually with caching to stay within limits while testing.
Ready to integrate ASN data with geolocation and security flags in minutes? Create your account now: Register. For full parameter details and operational notes, refer to the Documentation, and explore machine connectivity via MCP.
