FastCF
from fastcore.utils import *
from fastcflare import *
Quickstart
from fastcflare import *
usrtok = os.environ['CLOUDFLARE_USR_TOK']
ucf = CloudflareApi(token=usrtok)
(await ucf.verify()).result.status
'active'
(await ucf.zones.list()).result[0].name
'aaa.as'
Create a token
This token would have access to manage DNS for a single domain:
acceml = os.environ['CLOUDFLARE_EML_ADD']
glbtok = os.environ['CLOUDFLARE_API_KEY']
gcf = CloudflareApi(email=acceml, api_key=glbtok)
doms = ['xxx']
pnms = ('Zone Read', 'DNS Write')
tok = await ucf.create_token(doms, pnms, 'domain mgt')
print(tok.result.value)
Then use it like this, e.g to create and delete a domain:
domnm = 'xxx'
zones = (await ucf.zones.list(name=domnm)).result
zid_sp = zones[0].id
dcf = CloudflareApi(token=tok.result.value)
print((await dcf.zones.dns_records.list(zone_id=zid_sp)).result[:3])
rec = await dcf.zones.dns_records.post(zid_sp, type='A', name='test-delete-me.xxx', content='192.0.2.1', ttl=1)
print(rec.result.id, rec.result.name)
print((await dcf.zones.dns_records.delete(zid_sp, rec.result.id)).result.id)
Intro to Account Tokens
Account-owned API tokens (created via /accounts/{id}/tokens) are tied to the account, not a specific user. They act as service principals — ideal for CI/CD pipelines and service-to-service integrations, since they remain valid even if the creating user leaves the organisation.
Creating Account Tokens
You need a token with “Create Additional Tokens” permission at the account level. Use the Cloudflare Python SDK with the Global API Key + email (not a user token):
from cloudflare import Cloudflare
cf = Cloudflare(api_token=your_cf_token, api_email='you@example.com')
accts = cf.accounts.list()
acct_id = accts.result[0].id
Look up available permission groups for your account:
groups = cf.accounts.tokens.permission_groups.list(account_id=acct_id)
{g.name: g.id for g in groups if 'dns' in g.name.lower() or 'zone' in g.name.lower()}
Create the token with nested resource format — zones must be nested under the account:
tok = cf.accounts.tokens.create(account_id=acct_id, name="dns-all-zones", policies=[{
"effect": "allow",
"resources": {f"com.cloudflare.api.account.{acct_id}": {"com.cloudflare.api.account.zone.*": "*"}},
"permission_groups": [
{"id": "c8fed203ed3043cba015a93ad1616f1f"}, # Zone Read
...
]
}])
dns_tok = tok.value # Save this — it's only shown once
⚠️ The resource format {"com.cloudflare.api.account.zone.*": "*"} (without nesting) will fail with: “Must specify a zone for account owned tokens, or nest zone under specific account resource”
Development
The op surface comes from cf_spec.py, Cloudflare’s OpenAPI schema in fastspec’s compact form. Refresh it from Cloudflare’s published schema with tools/build.py, then review the diff: op names can shift when the schema changes.
Metadata
Release files for fastcflare 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastcflare-0.1.1.tar.gz | 216.2 kB | Without provenance | Details for fastcflare-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastcflare-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for fastcflare-0.1.1-py3-none-any.whl |
Total release size: 435.5 kB
Release files / fastcflare-0.1.1.tar.gz
| Download URL | fastcflare-0.1.1.tar.gz |
|---|---|
| Size | 216.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03c4e96d76ce8edab8e222160489b113c3493903962318cca09a30b64f74e12b
|
|
BLAKE2b-256 checksum How to use checksums |
e3c3b6ae819e46ff42bd47de8b38267ea8b790b05f3a27d45004850d5e83764f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / fastcflare-0.1.1-py3-none-any.whl
| Download URL | fastcflare-0.1.1-py3-none-any.whl |
|---|---|
| Size | 219.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f649f167e79f39a0b6600a4ac721c0c5db3eb15a00bf34f750094560e4fb188
|
|
BLAKE2b-256 checksum How to use checksums |
bbf13170d57c9382de36bb2aedcd1a6bfc13261b67f6845c78204df40b24e47a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Security for fastcflare 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.