Skip to main content

Python wrapper for NextDNS API.

Project description

CI codecov GitHub Release PyPI PyPI - Downloads Buy me a coffee PayPal_Me Revolut.Me

nextdns

Python wrapper for NextDNS API.

To generate an API key you need a NextDNS account, which you can create using this referral.

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()

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

How to create a dev environment

git clone https://github.com/bieniu/nextdns.git
cd nextdns
./scripts/setup-local-env.sh

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nextdns-5.0.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nextdns-5.0.1.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for nextdns-5.0.1.tar.gz
Algorithm Hash digest
SHA256 3387952bf60df9fa933d970c500673bad842865f9fc8e5b782331e9da489f452
MD5 134b8b8b7b011946880a73cad8f70fe4
BLAKE2b-256 1d592659a16ceddb5d28018c6d1ea395bdacc4a4406c7b16b87175c0aecd96f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nextdns-5.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for nextdns-5.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9cc119e07517967c567e5c890712addb46476cb006fa1512a6958b902b9948f3
MD5 445614ee4e4309ac25198a722bcefa11
BLAKE2b-256 2bd93c7324083a3a0a8df66d7e73d4263592ff0430a1e921208f2b07d5998751

See more details on using hashes here.

Supported by

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