Skip to main content

ASN Lookup

The ASN Lookup endpoint retrieves information about an Autonomous System Number (ASN), including the organization name, country, RIR allocation, and optionally the associated IP prefixes.

Endpoints

ASN Lookup

GET /v1/asn/{asn}

Look up information for a specific ASN.

GET /v1/asn/search

Search for ASNs by organization name.

ASN Statistics

GET /v1/asn/stats

Get statistics about the ASN registry.


ASN Lookup

Path Parameters

ParameterTypeRequiredDescription
asnintegerYesAutonomous System Number (1 to 4294967295)

Query Parameters

ParameterTypeDefaultDescription
include_prefixesbooleanfalseInclude associated IP prefixes
prefix_limitinteger100Maximum prefixes to return (max 1000)

Response (200)

{
"data": {
"asn": 15169,
"name": "Google LLC",
"country": "US",
"rir": "ARIN",
"allocation_date": "2000-03-30"
},
"meta": {
"request_id": "550e8400-e29b-41d4-a716-446655440003",
"processing_time_ms": 2
}
}

Response with Prefixes

When include_prefixes=true:

{
"data": {
"asn": 15169,
"name": "Google LLC",
"country": "US",
"rir": "ARIN",
"allocation_date": "2000-03-30",
"prefixes": [
{
"prefix": "8.8.8.0/24",
"country": "US",
"is_datacenter": true,
"threat_score": 0
},
{
"prefix": "8.8.4.0/24",
"country": "US",
"is_datacenter": true,
"threat_score": 0
},
{
"prefix": "172.217.0.0/16",
"country": "US",
"is_datacenter": true,
"threat_score": 0
}
],
"total_prefixes": 1234
},
"meta": {
"request_id": "550e8400-e29b-41d4-a716-446655440003",
"processing_time_ms": 25
}
}

Response Fields

FieldTypeDescription
asnintegerAutonomous System Number
namestringOrganization name
countrystringISO 3166-1 alpha-2 country code
rirstringRegional Internet Registry (ARIN, RIPE, APNIC, LACNIC, AFRINIC)
allocation_datestringDate when the ASN was allocated (YYYY-MM-DD)
prefixesarrayAssociated IP prefixes (when requested)
total_prefixesintegerTotal count of prefixes for this ASN

Prefix Object

FieldTypeDescription
prefixstringCIDR notation prefix
countrystringCountry code
is_datacenterbooleanWhether this prefix is a datacenter
threat_scoreintegerThreat score for this prefix (0-100)

ASN Search

Search for ASNs by organization name.

Query Parameters

ParameterTypeRequiredDescription
qstringYesSearch query (minimum 2 characters)
limitintegerNoMaximum results (default 20, max 100)

Response (200)

{
"data": {
"results": [
{
"asn": 15169,
"name": "Google LLC",
"country": "US",
"rir": "ARIN"
},
{
"asn": 36040,
"name": "Google Fiber Inc.",
"country": "US",
"rir": "ARIN"
},
{
"asn": 139070,
"name": "Google Cloud Japan",
"country": "JP",
"rir": "APNIC"
}
],
"count": 3
},
"meta": {
"processing_time_ms": 5
}
}

ASN Statistics

Get global statistics about the ASN registry.

Response (200)

{
"data": {
"total_asns": 75000,
"by_rir": {
"ARIN": 25000,
"RIPE": 28000,
"APNIC": 15000,
"LACNIC": 5000,
"AFRINIC": 2000
}
},
"meta": {
"processing_time_ms": 10
}
}

Error Responses

400 Bad Request - Invalid ASN

{
"data": {
"error": "invalid ASN",
"code": "INVALID_ASN"
},
"meta": {
"processing_time_ms": 0
}
}

404 Not Found - ASN Not Found

{
"data": {
"error": "ASN not found",
"code": "NOT_FOUND"
},
"meta": {
"processing_time_ms": 2
}
}

Code Examples

cURL

# Basic ASN lookup
curl -X GET "https://api.limesindex.com/v1/asn/15169" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Accept: application/json"

# ASN lookup with prefixes
curl -X GET "https://api.limesindex.com/v1/asn/15169?include_prefixes=true&prefix_limit=50" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Accept: application/json"

# Search for ASNs
curl -X GET "https://api.limesindex.com/v1/asn/search?q=Google&limit=10" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Accept: application/json"

# Get ASN statistics
curl -X GET "https://api.limesindex.com/v1/asn/stats" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Accept: application/json"

Python

import requests
import os
from typing import Optional, List

API_KEY = os.environ.get("LIMESINDEX_API_KEY")
BASE_URL = "https://api.limesindex.com"

def lookup_asn(
asn: int,
include_prefixes: bool = False,
prefix_limit: int = 100
) -> dict:
"""Look up information for an ASN."""
params = {}
if include_prefixes:
params["include_prefixes"] = "true"
params["prefix_limit"] = prefix_limit

response = requests.get(
f"{BASE_URL}/v1/asn/{asn}",
headers={
"X-API-Key": API_KEY,
"Accept": "application/json"
},
params=params
)
response.raise_for_status()
return response.json()

def search_asn(query: str, limit: int = 20) -> dict:
"""Search for ASNs by organization name."""
response = requests.get(
f"{BASE_URL}/v1/asn/search",
headers={
"X-API-Key": API_KEY,
"Accept": "application/json"
},
params={"q": query, "limit": limit}
)
response.raise_for_status()
return response.json()

def get_asn_stats() -> dict:
"""Get ASN registry statistics."""
response = requests.get(
f"{BASE_URL}/v1/asn/stats",
headers={
"X-API-Key": API_KEY,
"Accept": "application/json"
}
)
response.raise_for_status()
return response.json()

# Example usage
# Basic lookup
result = lookup_asn(15169)
asn_data = result["data"]
print(f"ASN {asn_data['asn']}: {asn_data['name']}")
print(f"Country: {asn_data['country']}")
print(f"RIR: {asn_data['rir']}")
print(f"Allocated: {asn_data['allocation_date']}")

# Lookup with prefixes
result = lookup_asn(15169, include_prefixes=True, prefix_limit=10)
asn_data = result["data"]
print(f"\nPrefixes for {asn_data['name']} ({asn_data['total_prefixes']} total):")
for prefix in asn_data.get("prefixes", []):
print(f" {prefix['prefix']} - {prefix['country']}")

# Search
search_result = search_asn("Amazon", limit=5)
print("\nSearch results for 'Amazon':")
for asn in search_result["data"]["results"]:
print(f" AS{asn['asn']}: {asn['name']} ({asn['country']})")

JavaScript (Node.js)

const API_KEY = process.env.LIMESINDEX_API_KEY;
const BASE_URL = 'https://api.limesindex.com';

async function lookupASN(asn, options = {}) {
const params = new URLSearchParams();
if (options.includePrefixes) {
params.set('include_prefixes', 'true');
if (options.prefixLimit) {
params.set('prefix_limit', options.prefixLimit.toString());
}
}

const url = `${BASE_URL}/v1/asn/${asn}${params.toString() ? '?' + params : ''}`;

const response = await fetch(url, {
headers: {
'X-API-Key': API_KEY,
'Accept': 'application/json'
}
});

if (!response.ok) {
const error = await response.json();
throw new Error(`API Error: ${error.data.error}`);
}

return response.json();
}

async function searchASN(query, limit = 20) {
const params = new URLSearchParams({ q: query, limit: limit.toString() });
const url = `${BASE_URL}/v1/asn/search?${params}`;

const response = await fetch(url, {
headers: {
'X-API-Key': API_KEY,
'Accept': 'application/json'
}
});

if (!response.ok) {
const error = await response.json();
throw new Error(`API Error: ${error.data.error}`);
}

return response.json();
}

// Example usage
async function main() {
try {
// Basic lookup
const result = await lookupASN(15169);
console.log(`ASN ${result.data.asn}: ${result.data.name}`);
console.log(`Country: ${result.data.country}`);
console.log(`RIR: ${result.data.rir}`);

// With prefixes
const withPrefixes = await lookupASN(15169, {
includePrefixes: true,
prefixLimit: 5
});
console.log(`\nTop prefixes for ${withPrefixes.data.name}:`);
for (const prefix of withPrefixes.data.prefixes) {
console.log(` ${prefix.prefix}`);
}

// Search
const searchResults = await searchASN('Microsoft', 5);
console.log('\nSearch results for "Microsoft":');
for (const asn of searchResults.data.results) {
console.log(` AS${asn.asn}: ${asn.name}`);
}
} catch (error) {
console.error('Error:', error.message);
}
}

main();

Go

package main

import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
"strconv"
)

const baseURL = "https://api.limesindex.com"

type ASNInfo struct {
ASN int `json:"asn"`
Name string `json:"name"`
Country string `json:"country"`
RIR string `json:"rir"`
AllocationDate string `json:"allocation_date"`
Prefixes []Prefix `json:"prefixes,omitempty"`
TotalPrefixes int `json:"total_prefixes,omitempty"`
}

type Prefix struct {
Prefix string `json:"prefix"`
Country string `json:"country"`
IsDatacenter bool `json:"is_datacenter"`
ThreatScore int `json:"threat_score"`
}

type Meta struct {
RequestID string `json:"request_id"`
ProcessingTimeMs int `json:"processing_time_ms"`
}

type ASNLookupResponse struct {
Data ASNInfo `json:"data"`
Meta Meta `json:"meta"`
}

type ASNSearchResponse struct {
Data struct {
Results []ASNInfo `json:"results"`
Count int `json:"count"`
} `json:"data"`
Meta Meta `json:"meta"`
}

func lookupASN(apiKey string, asn int, includePrefixes bool, prefixLimit int) (*ASNLookupResponse, error) {
u, _ := url.Parse(fmt.Sprintf("%s/v1/asn/%d", baseURL, asn))
q := u.Query()
if includePrefixes {
q.Set("include_prefixes", "true")
q.Set("prefix_limit", strconv.Itoa(prefixLimit))
}
u.RawQuery = q.Encode()

req, _ := http.NewRequest("GET", u.String(), nil)
req.Header.Set("X-API-Key", apiKey)
req.Header.Set("Accept", "application/json")

resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()

body, _ := io.ReadAll(resp.Body)

var result ASNLookupResponse
if err := json.Unmarshal(body, &result); err != nil {
return nil, err
}

return &result, nil
}

func searchASN(apiKey, query string, limit int) (*ASNSearchResponse, error) {
u, _ := url.Parse(fmt.Sprintf("%s/v1/asn/search", baseURL))
q := u.Query()
q.Set("q", query)
q.Set("limit", strconv.Itoa(limit))
u.RawQuery = q.Encode()

req, _ := http.NewRequest("GET", u.String(), nil)
req.Header.Set("X-API-Key", apiKey)
req.Header.Set("Accept", "application/json")

resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()

body, _ := io.ReadAll(resp.Body)

var result ASNSearchResponse
if err := json.Unmarshal(body, &result); err != nil {
return nil, err
}

return &result, nil
}

func main() {
apiKey := os.Getenv("LIMESINDEX_API_KEY")

// Basic lookup
result, err := lookupASN(apiKey, 15169, false, 0)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}

fmt.Printf("ASN %d: %s\n", result.Data.ASN, result.Data.Name)
fmt.Printf("Country: %s\n", result.Data.Country)
fmt.Printf("RIR: %s\n", result.Data.RIR)

// With prefixes
withPrefixes, _ := lookupASN(apiKey, 15169, true, 5)
fmt.Printf("\nTop prefixes for %s:\n", withPrefixes.Data.Name)
for _, prefix := range withPrefixes.Data.Prefixes {
fmt.Printf(" %s\n", prefix.Prefix)
}

// Search
searchResult, _ := searchASN(apiKey, "Cloudflare", 5)
fmt.Printf("\nSearch results for 'Cloudflare':\n")
for _, asn := range searchResult.Data.Results {
fmt.Printf(" AS%d: %s\n", asn.ASN, asn.Name)
}
}

Use Cases

Network Analysis

def analyze_network_footprint(asn: int) -> dict:
"""Analyze the network footprint of an organization."""
result = lookup_asn(asn, include_prefixes=True, prefix_limit=1000)
data = result["data"]

analysis = {
"organization": data["name"],
"total_prefixes": data["total_prefixes"],
"datacenter_prefixes": 0,
"high_threat_prefixes": 0,
"countries": set()
}

for prefix in data.get("prefixes", []):
analysis["countries"].add(prefix["country"])
if prefix["is_datacenter"]:
analysis["datacenter_prefixes"] += 1
if prefix["threat_score"] >= 50:
analysis["high_threat_prefixes"] += 1

analysis["countries"] = list(analysis["countries"])
return analysis

Competitor Research

def find_competitors(company_name: str) -> list:
"""Find ASNs for a company and its competitors."""
result = search_asn(company_name, limit=50)

companies = {}
for asn in result["data"]["results"]:
name = asn["name"]
if name not in companies:
companies[name] = []
companies[name].append(asn["asn"])

return companies

IP to Organization Mapping

def get_organization_for_ip(ip: str) -> dict:
"""Get full organization details for an IP."""
# First, lookup the IP
ip_result = lookup_ip(ip)
asn = ip_result["data"]["asn"]

# Then get full ASN details
asn_result = lookup_asn(asn)

return {
"ip": ip,
"asn": asn,
"organization": asn_result["data"]["name"],
"country": asn_result["data"]["country"],
"rir": asn_result["data"]["rir"],
"allocated": asn_result["data"]["allocation_date"]
}