Python wrapper for NextDNS API.
Project description
nextdns
Python wrapper for NextDNS API.
How to use package
"""Example of usage."""
import asyncio
import logging
from aiohttp import ClientSession
from nextdns import ApiError, InvalidApiKeyError, NextDns
API_KEY = "xxx"
logging.basicConfig(level=logging.DEBUG)
async def main():
"""Main function."""
async with ClientSession() as websession:
try:
nextdns = await NextDns.create(websession, API_KEY)
profile_id, profile_name = nextdns.profiles[2]
profile = await nextdns.get_profile(profile_id)
status = await nextdns.get_analytics_status(profile_id)
dnssec = await nextdns.get_analytics_dnssec(profile_id)
encryption = await nextdns.get_analytics_encryption(profile_id)
ip_versions = await nextdns.get_analytics_ip_versions(profile_id)
protocols = await nextdns.get_analytics_protocols(profile_id)
except InvalidApiKeyError:
print("Invalid API Key")
except ApiError as error:
print(f"API Error: {error.status}")
else:
print(f"Profile: {profile_name} ({profile_id})")
print(profile)
print(status)
print(dnssec)
print(encryption)
print(ip_versions)
print(protocols)
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
loop.close()
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
nextdns-5.0.0.tar.gz
(19.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
nextdns-5.0.0-py3-none-any.whl
(17.1 kB
view details)
File details
Details for the file nextdns-5.0.0.tar.gz.
File metadata
- Download URL: nextdns-5.0.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
401f96f2d61dd830817e5fe50472b0495d742da98d4c645afa15a270cef506df
|
|
| MD5 |
0cafb0892b08c01b378135f20ed94e6e
|
|
| BLAKE2b-256 |
7215d74ee05c29c5600e3cda690eba802065c8b1acd8547612f00eb30afe6af6
|
File details
Details for the file nextdns-5.0.0-py3-none-any.whl.
File metadata
- Download URL: nextdns-5.0.0-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2abb521c4db4f68045381d4240ecade343829f193131cb363686325025cbfe3
|
|
| MD5 |
eb39f0712dcbb2addba85bc6d1b703a8
|
|
| BLAKE2b-256 |
0223c8a6ecf7636c31bc6f624f1424435061707250922c9d04a7c7ec141005ca
|