{"id":13473714,"url":"https://github.com/danielpigott/cloudflare-cli","last_synced_at":"2025-04-04T13:10:14.089Z","repository":{"id":14119924,"uuid":"16824935","full_name":"danielpigott/cloudflare-cli","owner":"danielpigott","description":"CLI for interacting with Cloudflare","archived":false,"fork":false,"pushed_at":"2023-04-15T17:39:26.000Z","size":821,"stargazers_count":212,"open_issues_count":16,"forks_count":42,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-30T06:33:20.711Z","etag":null,"topics":["cli","cloudflare","javascript"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielpigott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-02-14T02:40:37.000Z","updated_at":"2024-10-21T11:43:34.000Z","dependencies_parsed_at":"2024-01-05T20:58:53.804Z","dependency_job_id":"b5e5050a-26db-441e-8777-9988d6bde3f8","html_url":"https://github.com/danielpigott/cloudflare-cli","commit_stats":{"total_commits":111,"total_committers":15,"mean_commits":7.4,"dds":0.5765765765765766,"last_synced_commit":"f4f22e60061d09143d41c40c9825a2fa3e1f3523"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpigott%2Fcloudflare-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpigott%2Fcloudflare-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpigott%2Fcloudflare-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielpigott%2Fcloudflare-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielpigott","download_url":"https://codeload.github.com/danielpigott/cloudflare-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247182350,"owners_count":20897379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cloudflare","javascript"],"created_at":"2024-07-31T16:01:06.191Z","updated_at":"2025-04-04T13:10:14.070Z","avatar_url":"https://github.com/danielpigott.png","language":"JavaScript","readme":"cloudflare-cli\n==============\n[![npm version](https://badge.fury.io/js/cloudflare-cli.svg)](https://badge.fury.io/js/cloudflare-cli)\n[![CircleCI](https://circleci.com/gh/danielpigott/cloudflare-cli.svg?style=svg)](https://circleci.com/gh/danielpigott/cloudflare-cli)\n\nCLI for interacting with Cloudflare\n\n## Installation\nYou can install using NPM or using Docker\n\nInstall via npm\n```bash\nnpm install -g cloudflare-cli\n```\n\nInstall from Dockerhub\n```bash\ndocker pull dpig/cloudflare-cli:latest\n# Running a command\ndocker run --rm -it dpig/cloudflare-cli -h\n```\n\nBuild Dockerfile locally\n```bash\ngit clone https://github.com/danielpigott/cloudflare-cli.git\\\ndocker build -t cloudflare-cli .\n# Running a command\ndocker run --rm -it cloudflare-cli -h\n```\n\n## Setup\nYou can setup a yaml config file with default parameters e.g. token and email.\nBy default cfcli will look for \".cfcli.yml\" in your home directory (you can also pass in a config file with -c)\n\n### Cloudflare API Keys and Tokens\n\nCloudflare has two API client methods:  [API Tokens](https://developers.cloudflare.com/api/tokens) and [API Keys](https://developers.cloudflare.com/api/keys) (Legacy) (See below screenshot)\n* **API Tokens** can be setup with specific permissions and do _not_ use an email address. Recommended by Cloudflare\n* **API Keys** are the legacy method, do not have specific permissions and require the corresponding user's email address to be provided.\n\nIn the `cfcli` setup, if you _exclude_ an email address, then the `cfcli` tool will assume you are using an **API Token** instead of an **API Key**.\n\n![doc/cloudflare_api_tokens_and_keys.png](doc/cloudflare_api_tokens_and_keys.png)\n\n\n### Configuration Example\nIf you have only one cloudflare account you can set it up as below:\n\n```yaml\ndefaults:\n    token: \u003ccloudflare-token\u003e\n    email: \u003cyou@domain.com\u003e #Only required if using legacy API Key\n    domain: \u003cdefault-cloudflare-domain\u003e\n```\n\nIf you have multiple cloudflare accounts, and you can set up accounts as below:\n\n```yaml\ndefaults:\n    account: work\naccounts:\n    work:\n        token: \u003ccloudflare-token\u003e\n        email: \u003cyou@domain.com\u003e\n        domain: \u003cdefault-cloudflare-domain\u003e\n    play:\n        token: \u003ccloudflare-token\u003e\n        email: \u003cyou@domain.com\u003e\n        domain: \u003cdefault-cloudflare-domain\u003e\n    adventure:\n        token: \u003ccloudflare-token\u003e\n        domain: \u003cdefault-cloudflare-domain\u003e\n```\n\nYou can then use `-u play` to interact with the second cloudflare account.\n\nIf the `email` option is excluded, then the request will be made using what is assumed to be an **API Token** vs. an **API Key.**\n\n```yaml\ndefaults:\n    account: adventure\naccounts:\n    adventure:\n        token: \u003ccloudflare-token\u003e\n        domain: \u003cdefault-cloudflare-domain\u003e\n```\n\n### Environment Variables\n\n* Environment variables take precedence over the configuration file.\n* If the `CF_API_EMAIL` variable is excluded, then the request will be made using what is assumed to be an **API Token** vs. an **API Key.**\n\n```\nCF_API_KEY # maps to token\nCF_API_EMAIL # maps to email\nCF_API_DOMAIN # maps to domain\n```\n\n## Usage\n\n```\nNAME\n    cfcli - Interact with cloudflare from the command line\n\nSYNOPSIS\n    cfcli [options] command [parameters]\n\nOPTIONS:\n    -c  --config    Path to yml file with config defaults (defaults to ~/.cfcli.yml\n    -e  --email     Email of your cloudflare account\n    -k  --token     Token for your cloudflare account\n    -u  --account   Choose one of your named cloudflare accounts from .cfcli.yml\n    -d  --domain    Domain to operate on\n    -a  --activate  Activate cloudflare after creating record (for addrecord)\n    -f  --format    Format when printing records (csv,json or table)\n    -t  --type      Type of record (for dns record functions)\n    -p  --priority  Set priority when adding a record (MX or SRV)\n    -q  --query     Comma separated filters to use when finding a record\n    -l  --ttl       Set ttl on add or edit (120 - 86400 seconds, or 1 for auto)\n    -h  --help      Display help\n\nCOMMANDS:\n    add \u003cname\u003e \u003ccontent\u003e\n        Add a DNS record. Use -a to activate cf after creation\n    always-use-https on|off\n        Toggle Always Use HTTPS mode on/off\n    devmode on|off\n        Toggle development mode on/off\n    disable \u003cname\u003e [content]\n        Disable cloudflare caching for given record and optionally specific value\n    edit \u003cname\u003e \u003ccontent\u003e\n        Edit a DNS record.\n    enable \u003cname\u003e [content]\n        Enable cloudflare caching for given record and optionally specific value\n    find \u003cname\u003e [content]\n        Find a record with given name and optionally specific value\n    ls\n        List dns records for the domain\n    purge [urls]\n        Purge file at given urls (space separated) or all files if no url given\n    rm \u003cname\u003e [content]\n        Remove record with given name and optionally specific value\n    zone-add \u003cname\u003e\n        Add a zone for given name\n    zones\n        List domains in your cloudflare account\n```\n\n### Examples\nAdd a new A record (mail) and activate cloudflare (-a)\n```\ncfcli -a -t A add mail 8.8.8.8\n```\n\nEdit a record (mail) and set the TTL\n```\ncfcli --ttl 120 edit  mail 8.8.8.8\n```\n\nAdd an SRV record (then 3 numbers are priority, weight and port respectively)\n```\ncfcli -t SRV add _sip._tcp.example.com 1 1 1 example.com\n```\n\nFind all records matching the content value test.com\n```\ncfcli find -q content:test.com\n```\n\nRemove all records with the name test\n```\ncfcli rm test\n```\n\nRemove record with name test, type of A and value 1.1.1.1\n```\ncfcli rm test -q content:1.1.1.1,type:A\n```\n\nEnable cloudflare for any records that match test\n```\ncfcli enable test\n```\n\nEnable cloudflare for a record test with the value test.com\n```\ncfcli enable test test.com\n```\n\nExport domain records for test.com to csv\n```\ncfcli -d test.com -f csv listrecords \u003e test.csv\n```\n\nPurge a given files from cache\n```\ncfcli -d test.com purge http://test.com/script.js http://test.com/styles.css\n```\n\nEnable dev mode for test.com domain\n```\ncfcli -d test.com devmode on\n```\n\nAdd the zone test.com\n```\ncfcli zone-add test.com\n```\n\n### Testing\nIn order to run the tests you will need to set valid values for the\n  `CF_API_EMAIL` and `CF_API_KEY` environment variables.\n\nRunning the tests will add a zone _(cloudflaretest.com)_, add and remove records against that domain and then remove the zone.\n\n The tests can be run with the following command\n\n```bash\nyarn test\n```\n","funding_links":[],"categories":["JavaScript","DNS"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielpigott%2Fcloudflare-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielpigott%2Fcloudflare-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielpigott%2Fcloudflare-cli/lists"}