Accessing PeeringDB API via python

Published 01-07-2017 06:43:49

A quit note on how to query the PeeringDB API for a specific ASN.

import json
import requests
import pprint 

ASN = "3356"
url = "https://peeringdb.com/api/net?asn=" + ASN
resp = requests.get(url=url)
pdb_json = json.loads(resp.text)
pprint.pprint ( pdb_json ) 
 

Should return data which looks like this:

{"data": [{"aka": "",
            "asn": 3356,
            "created": "2005-06-10T02:28:32Z",
            "id": 504,
            "info_ipv6": True,
            "info_multicast": True,
            "info_prefixes4": 175000,
            "info_prefixes6": 8750,
            "info_ratio": "Balanced",
            "info_scope": "Global",
            "info_traffic": "1 Tbps+",
            "info_type": "NSP",
            "info_unicast": True,
            "irr_as_set": "AS3356",
            "looking_glass": "http://lg.level3.net/",
            "name": "Level 3 Communications, LLC",
            "notes": "",
            "org_id": 682,
            "policy_contracts": "Required",
            "policy_general": "Restrictive",
            "policy_locations": "Required - International",
            "policy_ratio": False,
            "policy_url": "http://www.level3.com/en/legal/ip-traffic-exchange-policy/",
            "route_server": "",
            "status": "ok",
            "updated": "2016-03-14T20:57:20Z",
            "website": "http://www.level3.com"}],
 "meta": {}}