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-3.1.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

nextdns-3.1.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nextdns-3.1.0.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for nextdns-3.1.0.tar.gz
Algorithm Hash digest
SHA256 e91104f27a1457c4d4a12c9bbab6b0cad1ce94ec14846c9cce494cedaab9c811
MD5 bae0f131493a61df4050185f00159027
BLAKE2b-256 c64921ba3cada231e18a1c86e7494787783da294ce8e7dd80d5a82bfb18dd288

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nextdns-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for nextdns-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 802b1a596bcf441f995099e3cf7f8112424bb5636c181af81704a4e9d12dc33e
MD5 4e1ddc83234a9b65ee409fee195e07f5
BLAKE2b-256 01cdddbf6f12e090cbc3b7e818fe688e19936b441a114fdafd2f4b1a8788f3a8

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