Skip to main content

Cloudflare DNS provider extension for npmctl.

Project description

npmctl-cloudflare

Cloudflare DNS provider plugin for npmctl

Extend npmctl with Cloudflare-backed DNS record management for declarative workflows, provider discovery, and DNS-aware automation.

PyPI version Python versions CI Apache 2.0 License

npmctl-cloudflare package hits npmctl-cloudflare downloads

npmctl architecture infographic

npmctl-cloudflare is the Cloudflare DNS provider package for npmctl. Install it when you want desired-state DNS records or DNS diagnostics to resolve through Cloudflare instead of using only the base npmctl package.

Supported Python Versions

npmctl-cloudflare supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.

Why npmctl-cloudflare

  • Adds Cloudflare DNS provider discovery to npmctl
  • Lets DNS workflows live beside proxy and certificate desired state
  • Keeps Cloudflare API tokens out of the core CLI package
  • Supports operator diagnostics through npmctl dns doctor
  • Provides client helpers for Cloudflare A and CNAME record workflows

FAQ

What is npmctl-cloudflare?

Answer: npmctl-cloudflare is a plugin package that teaches npmctl how to talk to the Cloudflare DNS Records API for DNS record operations and DNS provider diagnostics.

When do I need npmctl-cloudflare?

Answer: You need npmctl-cloudflare when your npmctl workflow includes Cloudflare-managed DNS records or when you want npmctl to validate Cloudflare DNS connectivity and credentials.

Does npmctl-cloudflare work without npmctl?

Answer: No. npmctl-cloudflare is an extension package for npmctl, not a standalone CLI.

Can npmctl-cloudflare set A and CNAME records?

Answer: Yes. The Cloudflare DNS Records API supports A and CNAME records, and this package exposes helpers for create, replace, patch, and delete operations.

What credentials are required?

Answer: Cloudflare API access requires CLOUDFLARE_API_TOKEN. For diagnostics, grant zone read and DNS read access. For record changes, grant DNS write access to the target zone.

Install

Install the base CLI and the Cloudflare provider package together:

pipx install npmctl
pipx inject npmctl npmctl-cloudflare
npmctl plugins list

With uv:

uv tool install npmctl
uv tool install npmctl-cloudflare
npmctl plugins list

Inside a virtual environment:

python -m venv .venv
. .venv/bin/activate
python -m pip install npmctl npmctl-cloudflare
npmctl plugins list

Configure Cloudflare

Set the required environment variable:

export CLOUDFLARE_API_TOKEN=your-cloudflare-api-token

Optional for tests, proxies, or alternate endpoints:

export CLOUDFLARE_API_BASE_URL=https://api.cloudflare.com/client/v4

Verify Plugin Discovery

Check that npmctl can discover the provider:

npmctl plugins list
npmctl dns doctor --provider cloudflare

Minimal DNS Workflow

Once the provider is installed and configured, npmctl can validate or diagnose Cloudflare-backed DNS behavior through the base CLI:

npmctl dns providers
npmctl dns zones --provider cloudflare
npmctl dns records --provider cloudflare --zone example.com

Cloudflare API Surface

The provider follows the Cloudflare DNS Records API:

  • GET /zones: discover zones available to the token.
  • GET /zones/{zone_id}/dns_records: list DNS records in one zone.
  • POST /zones/{zone_id}/dns_records: create A, CNAME, and other supported records.
  • PUT /zones/{zone_id}/dns_records/{dns_record_id}: overwrite an existing record.
  • PATCH /zones/{zone_id}/dns_records/{dns_record_id}: partially update an existing record.
  • DELETE /zones/{zone_id}/dns_records/{dns_record_id}: delete a record.

Programmatic Record Operations

The npmctl DNS provider contract requires zones() and records(zone). This package also exposes client helpers for API-backed record mutation:

from npmctl_cloudflare import CloudflareClient, CloudflareConfig

client = CloudflareClient(CloudflareConfig.from_env())
record = client.create_record("example.com", type="A", name="www", value="192.0.2.10", ttl=300)
client.patch_record("example.com", str(record.record_id), value="192.0.2.11")
client.delete_record("example.com", str(record.record_id))

CNAME creation uses the same method:

client.create_record("example.com", type="CNAME", name="app", value="target.example.net", ttl=300)

Safety Notes

  • Only operate on zones that are authoritative in Cloudflare.
  • Use least-privilege API tokens scoped to the intended zone.
  • Keep CLOUDFLARE_API_TOKEN out of desired-state files and logs.
  • Cloudflare prevents CNAME records from coexisting with A or AAAA records on the same name.
  • Use npmctl owner metadata for desired DNS records so future apply support can remain owner-scoped.

More Documentation

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

npmctl_cloudflare-0.3.6.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

npmctl_cloudflare-0.3.6-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file npmctl_cloudflare-0.3.6.tar.gz.

File metadata

  • Download URL: npmctl_cloudflare-0.3.6.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for npmctl_cloudflare-0.3.6.tar.gz
Algorithm Hash digest
SHA256 7c366c17b0620416ad8c59ded3895e2b26b4c4aa52be0698037d959ed9cc9504
MD5 635baa8e5e8c3efb16e850dc7ac0a95f
BLAKE2b-256 06460b5b4571a3d46978f811b4f4be77c53531c62ef9b1831560cbd05468efc4

See more details on using hashes here.

File details

Details for the file npmctl_cloudflare-0.3.6-py3-none-any.whl.

File metadata

File hashes

Hashes for npmctl_cloudflare-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 73d0eb3001e600f71a0177fa5eeee27b48a71c11ebf7b8de6cf72f84e1a78427
MD5 f27b53f462df1fcfce0b3b238ba52679
BLAKE2b-256 f2fe4f31210f196ef484f63e48a0eca6a6e1674359bbcc85828d6aa1b4ffabff

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