Python client for Farsight Security's DNSDB API
Project description
dnsdb
Python client for Farsight Security's DNSDB API.
Features
- supports all capabilities of DNSDB API
- sorting of results by last_seen
- convert epoch to ISO 8601
- normalize results with regard sensor or zone observation
- returns an object with the following attributes:
- records
- status code
- error
- quota
Installation
Use the package manager pip to install dnsdb.
pip install dnsdb
Usage
Setup
>>> from dnsdb import Dnsdb
>>> api_key="12345"
>>> dnsdb = Dnsdb(api_key)
Example 1
>>> result = dnsdb.search(name="www.example.com")
>>> pprint(result.status_code)
200
>>> pprint(result.error)
None
>>> pprint(result.records[0])
{'bailiwick': 'example.com.',
'count': 4213726,
'rdata': ['93.184.216.34'],
'rrname': 'www.example.com.',
'rrtype': 'A',
'source': 'sensor',
'time_first': '2014-12-10T00:19:18Z',
'time_last': '2019-03-05T14:37:31Z'}
>>> pprint(result.quota)
{'expires': None,
'limit': '1000000',
'remaining': '999970',
'reset': '1551830400',
'results_max': None}
Example 2
>>> result = dnsdb.search(name="hello.example.com")
>>> pprint(result.status_code)
404
>>> pprint(result.error)
{'code': 404, 'message': 'Error: no results found for query.'}
>>> pprint(result.records)
None
>>> pprint(result.quota)
{'expires': None,
'limit': '1000000',
'remaining': '999969',
'reset': '1551830400',
'results_max': None}
More Usage
from dnsdb import Dnsdb
api_key="12345"
dnsdb = Dnsdb(api_key)
result = dnsdb.search(name="fsi.io")
result = dnsdb.search(name="mail.fsi.io", inverse=True)
result = dnsdb.search(ip="104.244.14.108")
result = dnsdb.search(ip="104.244.14.0/24")
result = dnsdb.search(ip="2620:11c:f008::108")
result = dnsdb.search(hexadecimal="36757a35")
result = dnsdb.search(name="fsi.io", type="A")
result = dnsdb.search(name="farsightsecurity.com", bailiwick="com.")
result = dnsdb.search(name="fsi.io", wildcard_left=True)
result = dnsdb.search(name="fsi", wildcard_right=True)
result = dnsdb.search(name="fsi.io", sort=False)
result = dnsdb.search(name="fsi.io", remote_limit=150000, return_limit=1000)
result = dnsdb.search(name="fsi.io", time_last_after="2019-01-01")
result = dnsdb.search(name="fsi.io", time_last_after="2019-01-01T00:00:00Z")
result = dnsdb.search(name="fsi.io", epoch=True, time_last_after=1546300800)
result = dnsdb.search(name="fsi.io", epoch=True)
result = dnsdb.quota()
Contributing
Pull requests are welcome; for major changes, please open an issue first to discuss what you would like to change.
Please make sure to create and update tests as appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dnsdb-0.2.1.tar.gz
(7.1 kB
view hashes)
Built Distribution
dnsdb-0.2.1-py3-none-any.whl
(19.7 kB
view hashes)