Package: pybgpkit
PyBGPKITPython bindings for BGPKIT software. For all software offerings, please check out our GitHub
repository athttps://github.com/bgpkit.SDKsBGPKIT ParserOriginal Rust BGPKIT Parser code available at:https://github.com/bgpkit/bgpkit-parser-pyExample:importbgpkitparser=bgpkit.Parser(url="https://spaces.bgpkit.org/parser/update-example",filters={"peer_ips":"185.1.8.65, 2001:7f8:73:0:3:fa4:0:1"})count=0foreleminparser:count+=1print(elem)assertcount==4227TheParserconstructor takes the following parameters:url: the URL or local file path toward an MRT filefitlers: optional a dictionary of filters, available filters are:origin_asn: origin AS numberprefix: exact match prefixprefix_super: exact prefix and its super prefixesprefix_sub: exact prefix and its sub prefixesprefix_super_sub: exact prefix and its super and sub prefixespeer_ip: peer's IP addresspeer_ips: peers' IP addressespeer_asn: peer's ASNtype: message type (withdraworannounce)ts_start: start unix timestampts_end: end unix timestampas_path: regular expression for AS path stringcache_dir: optional string for specifying a download cache directoryEach returning item has the following field:timestamp: float, unix timestampelem_type: str,A, announcement;W, withdrawnpeer_ip: str, peer IP addresspeer_asn: int, peer ASNprefix: str, the announced/withdrawn IP prefixnext_hop: str or None, next hop IP addressas_path: str or None, AS path str, e.g.60924 6939 58715 63969 135490origin_asns: [int] or None, array of originating ASNs of the prefixorigin: str or None,IGP,EGP, orINCOMPLETElocal_pref: int or None, local preferencemed: int or None, multi-exitmultiple exit discriminatorcommunities: [str] or None, community values, e.g.['60924:6', '60924:150', '60924:502', '60924:2002', 'ecop:67:0:000000000000']atomic: str,AGfor atomic aggregate, andNAGfor non-atomic aggregateaggr_ip: str or None, aggregator IP addressaggr_asn: int or None, aggregator ASNBGPKIT BrokerOriginal Rust version BGPKIT Broker code available at:https://github.com/bgpkit/bgpkit-brokerExample:importbgpkitbroker=bgpkit.Broker()items=broker.query(ts_start="1634693400",ts_end="2021-10-20T01:30:00")foriteminitems:print(item)print(len(items))assertlen(items)==58Available fields:Broker()api_url: the base URL for the BGPKIT Broker instance. Default:https://api.broker.bgpkit.com/v2page_size: the number of items per API call (no need to change it). Default: 100.query()ts_start: start timestamp for MRT file, UNIX timestamp formatts_end: end timestamp for MRT file, UNIX timestamp formatcollector: collector name, e.g.rrc00orroute-views2data_type:riborupdateBGPKIT ROAS LookupBGPKIT ROAS lookup API provides lookup for historical RPKI ROAS data lookup. The following example shows a query that
asks for all the validated ROA payload for RIPE NCC on the date of2018-01-01.importbgpkitroas=bgpkit.Roas()data=roas.query(debug=True,asn=3333,date="2018-01-01")forentryindata:print(entry)assertlen(data)==10{'tal': 'ripencc', 'prefix': '193.0.0.0/21', 'asn': 3333, 'max_len': 21, 'date_ranges': [['2015-03-10', '2016-01-26'], ['2016-01-30', '2018-12-27'], ['2019-01-03', '2019-10-21'], ['2019-10-23', '2020-02-23'], ['2020-02-25', '2020-04-05'], ['2020-04-07', '2020-08-02'], ['2020-08-04', '2021-04-21'], ['2021-04-23', '2021-04-24'], ['2021-04-28', '2022-02-26']]}
{'tal': 'ripencc', 'prefix': '193.0.10.0/23', 'asn': 3333, 'max_len': 23, 'date_ranges': [['2015-03-10', '2016-01-26'], ['2016-01-30', '2018-12-27'], ['2019-01-03', '2019-10-21'], ['2019-10-23', '2020-02-23'], ['2020-02-25', '2020-04-05'], ['2020-04-07', '2020-08-02'], ['2020-08-04', '2021-04-21'], ['2021-04-23', '2021-04-24'], ['2021-04-28', '2022-02-26']]}
{'tal': 'ripencc', 'prefix': '193.0.12.0/23', 'asn': 3333, 'max_len': 23, 'date_ranges': [['2015-03-10', '2016-01-26'], ['2016-01-30', '2018-12-27'], ['2019-01-03', '2019-10-21'], ['2019-10-23', '2020-02-23'], ['2020-02-25', '2020-04-05'], ['2020-04-07', '2020-08-02'], ['2020-08-04', '2021-04-21'], ['2021-04-23', '2021-04-24'], ['2021-04-28', '2022-02-26']]}
{'tal': 'ripencc', 'prefix': '193.0.18.0/23', 'asn': 3333, 'max_len': 23, 'date_ranges': [['2015-03-10', '2016-01-26'], ['2016-01-30', '2018-12-27'], ['2019-01-03', '2019-10-21'], ['2019-10-23', '2020-02-23'], ['2020-02-25', '2020-04-05'], ['2020-04-07', '2020-08-02'], ['2020-08-04', '2021-04-21'], ['2021-04-23', '2021-04-24'], ['2021-04-28', '2022-02-26']]}
{'tal': 'ripencc', 'prefix': '193.0.20.0/23', 'asn': 3333, 'max_len': 23, 'date_ranges': [['2015-03-10', '2016-01-26'], ['2016-01-30', '2018-12-27'], ['2019-01-03', '2019-10-21'], ['2019-10-23', '2020-02-23'], ['2020-02-25', '2020-04-05'], ['2020-04-07', '2020-08-02'], ['2020-08-04', '2021-04-21'], ['2021-04-23', '2021-04-24'], ['2021-04-28', '2022-02-26']]}
{'tal': 'ripencc', 'prefix': '193.0.22.0/23', 'asn': 3333, 'max_len': 23, 'date_ranges': [['2015-03-10', '2016-01-26'], ['2016-01-30', '2018-12-27'], ['2019-01-03', '2019-10-21'], ['2019-10-23', '2020-02-23'], ['2020-02-25', '2020-04-05'], ['2020-04-07', '2020-08-02'], ['2020-08-04', '2021-04-21'], ['2021-04-23', '2021-04-24'], ['2021-04-28', '2022-02-26']]}
{'tal': 'ripencc', 'prefix': '193.0.24.0/22', 'asn': 3333, 'max_len': 26, 'date_ranges': [['2017-01-14', '2018-12-27'], ['2019-01-03', '2019-06-24']]}
{'tal': 'ripencc', 'prefix': '193.0.24.0/24', 'asn': 3333, 'max_len': 24, 'date_ranges': [['2017-02-25', '2018-12-27'], ['2019-01-03', '2019-06-24']]}
{'tal': 'ripencc', 'prefix': '2001:610:240::/42', 'asn': 3333, 'max_len': 42, 'date_ranges': [['2015-03-10', '2016-01-26'], ['2016-01-30', '2018-12-27'], ['2019-01-03', '2019-10-21'], ['2019-10-23', '2020-02-23'], ['2020-02-25', '2020-04-05'], ['2020-04-07', '2020-08-02'], ['2020-08-04', '2021-04-21'], ['2021-04-23', '2021-04-24'], ['2021-04-28', '2022-02-26']]}
{'tal': 'ripencc', 'prefix': '2001:67c:2e8::/48', 'asn': 3333, 'max_len': 48, 'date_ranges': [['2015-03-10', '2016-01-26'], ['2016-01-30', '2018-12-27'], ['2019-01-03', '2019-10-21'], ['2019-10-23', '2020-02-23'], ['2020-02-25', '2020-04-05'], ['2020-04-07', '2020-08-02'], ['2020-08-04', '2021-04-21'], ['2021-04-23', '2021-04-24'], ['2021-04-28', '2022-02-26']]}Available query fields:Roas()api_url: the base URL for the BGPKIT ROAS instance. Default:https://api.roas.bgpkit.comquery()prefix: prefix to query instrasn: AS number to query ininttal: trust anchor to query instr, available values:ripencc,arin,apnic,afrinic,lacnicdate: date to query, format:YYYY-MM-DD, e.g.2022-01-01max_len: filter results to only VRP's with specific max lengthdebug: boolean toggle to display debug information, defaultFalseBuild and UploadInstallpython-buildmodule:python3-mpipinstallbuildtwineBuild current package:python3-mbuildUpload to PyPi (needs credentials)python3-mtwineuploaddist/*