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

Uploaded Source

Built Distribution

nextdns-1.3.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nextdns-1.3.0.tar.gz
Algorithm Hash digest
SHA256 31823cce73e575dc77d1c2e8b4dba7fee6bbf730f9f7d031dba9377234329c8d
MD5 d4d6a550f4212a953cb97c50d643e58b
BLAKE2b-256 d96ea9d0ac5fbfa9fd25990a51b7ec26141d27d03e9e031f36d7f0ce05bc3509

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for nextdns-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 daa943554c1fd33f6af681911796940173b5eb727537d526175b28529ef741d6
MD5 68022a50ae98ce8d2287eeb29b6a930c
BLAKE2b-256 6254efd27e1bf53de6ec433e3aca7f244d698c392b5329381a2d3a2de3da3bc8

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