Skip to main content

Python wrapper for NextDNS API.

Project description

GitHub Release PyPI PyPI - Downloads Buy me a coffee PayPal_Me

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nextdns-2.0.1.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

nextdns-2.0.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file nextdns-2.0.1.tar.gz.

File metadata

  • Download URL: nextdns-2.0.1.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for nextdns-2.0.1.tar.gz
Algorithm Hash digest
SHA256 4a88fc5c96a7eb5854faf7382bd8ed3e6d11fe20efb895b31d5cdcce5aa1c9ae
MD5 da3ddfa07a61a39bf3f8042fe76d6d49
BLAKE2b-256 21766a5347ee6dbf17bebbc27a097fa77fe083acdac0dbc6e9e10aacb08c6ab0

See more details on using hashes here.

File details

Details for the file nextdns-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: nextdns-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for nextdns-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d9d5f0c3643177843f385816d89478411c743c74b9a375f4ef9e858d68e2d82
MD5 c9e7f91a2699c4c60a985b979eb50236
BLAKE2b-256 0448fdd45197650daac232b6a7911ab8c17efb5e86cd3eca5541d0d3ed549a7f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page