ASN Lookup API by QWeb Ltd

This is the ASN lookup API by QWeb Ltd. Use this API to get the AS name and known CIDR IP blocks belonging to a given ASN.

We built this API as a quick method to retrieve the CIDR IP ranges known to belong to a given ASN. Some of our security systems use this API to retrieve a list of IP addresses known to be a part of the same network as IPs that have been detected as particularly malicious, so that they can block entire networks as quickly as possible.

All network operators who own IP addresses are assigned an Autonomous System Number, or ASN. These are unique numbers that identify the operator. You can use our IP Lookup API to find the ASN of any given IP address, and you can use this ASN Lookup API to find all of the IP ranges we know to belong to a given ASN. So if your network is being attacked by seemingly random IP addresses, using these two APIs you can very quickly determine whether these IPs belong to the same network, and generate a block list.

This API returns separate lists of the IPv4 and IPv6 CIDR ranges belonging to a given ASN, returning a single JSON object containing both of these lists.

Be aware that some operators are assigned multiple ASNs, often with the same, or similar, textual AS identifiers. This API returns only the CIDR ranges belonging to the given ASN, not all ranges belonging to the organisation. This is by design, because different subdivisions are often managed by separate parties or used for different purposes, and it would not be wise to compile a block list from all of the IPs belonging to an organisation if only a small part of its infrastructure is being used maliciously. Google, for example, offer proxy services which could be abused by attackers, but you would not want to block the entire Google network from communicating with your servers.

Usage

To use this API, first create a free API Console account and then log in to the API Console to generate an access key.

Once you have an access key, simply send a GET request to https://apis.qweb.co.uk/asn-lookup/ACCESS_KEY/ASN.json and a JSON formatted response will be returned.

The returned data will be a JSON object containing an answer property, which will either be success if the API key and ASN are valid, or an error message on fail. Additionally, if the return is successful, the JSON object will contain asn, as, ipv4, and ipv6 properties.

ipv4 and ipv6 will contain arrays of CIDR addresses belonging to the ASN.

For example, https://apis.qweb.co.uk/asn-lookup/ACCESS_KEY/15395.json will return the following JSON:

{
	"asn":"15395",
	"as":"Rackspace Ltd.",
	"ipv4":[
		"134.0.72.0\/21",
		"134.213.0.0\/16",
		"134.8.0.0\/24",
		"146.177.0.0\/20",
		"146.177.128.0\/17",
		"146.177.16.0\/22",
		"146.177.22.0\/23",
		"146.177.24.0\/21",
		"146.177.32.0\/19",
		"146.177.64.0\/21",
		"146.177.72.0\/23",
		"146.177.75.0\/24",
		"146.177.76.0\/22",
		"146.177.80.0\/20",
		"146.177.96.0\/19",
		"147.75.20.0\/22",
		"162.13.0.0\/16",
		"164.138.226.0\/24",
		"164.177.128.0\/19",
		"185.144.228.0\/22",
		"185.28.196.0\/24",
		"185.55.189.0\/24",
		"193.138.122.0\/24",
		"193.142.244.0\/24",
		"212.100.224.0\/19",
		"212.64.128.0\/19",
		"216.239.100.0\/24",
		"216.239.105.0\/24",
		"31.222.128.0\/18",
		"37.188.96.0\/19",
		"46.227.46.0\/24",
		"46.38.160.0\/19",
		"5.79.0.0\/18",
		"78.136.0.0\/18",
		"83.138.128.0\/18",
		"89.234.0.0\/18",
		"92.52.64.0\/18",
		"94.236.0.0\/17",
		"95.138.128.0\/18"
	],
	"ipv6":[
		"2a00:1a48::\/31"
	],
	"answer":"success"
}

Being a REST API, you can access this data from any device with a working Internet connection, using any programming language or development framework that has the ability to request HTTP URIs. The following example is a PHP script using Curl to request and display the IPv4 CIDR ranges for ASN 15395.

$api = curl_init();

$accessKey = 'YOUR_ACCESS_KEY';
$asn = '15395';

curl_setopt($api, CURLOPT_URL, 'https://apis.qweb.co.uk/asn-lookup/'.$accessKey.'/'.$asn.'.json');
curl_setopt($api, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($api);
curl_close($api);

$data = json_decode($response);

if($data->answer == 'success')
	print_r($data->ipv4);

This ASN lookup API has a built-in cache mechanic and is super quick to respond, and we of course aim to keep our servers up at all times, but in case of network issues and for the best possible performance, we recommend building your application to cache the results of your lookups locally. Lookup responses don't change often, so a cache of about 1 month should still be reasonably accurate.

Generate an access key or See our other API services

This service includes IP2Location LITE data available from https://lite.ip2location.com.

Copyright © 2023 - 2024 QWeb Ltd. All rights reserved. Company number 11693058. Privacy Policy