[!WARNING]
v3.x
of this library is a ground-up rewrite of the SDK, using code generation from our OpenAPI spec.This package should be in a usable state for many projects, but expect frequent minor breaking changes as we rename methods and types until GA. If this isn't suitable for you project, we recommend pinning to the
2.x
releases for now.We will be archiving the current repository (
cloudflare/node-cloudflare
) in favour of the newer repository (cloudflare/cloudflare-typescript
) to ensure consistency with our other libraries. The repository will still be accessible if you wish to use it, however, you will not be able to raise new issues or propose changes. Those should instead be directed to the newer repository.
Cloudflare v4 API bindings for Node.js, providing a sourdough "BREAD" (Browse, Read, Edit, Add, and Delete) interface.
With these bindings, you'll get the following features:
Node.js v4 and greater are supported.
Set your account email address and API key. The API key can be found on the My Profile -> API Tokens page in the Cloudflare dashboard.
var cf = require('cloudflare')({
email: 'you@example.com',
key: 'your Cloudflare API key'
});
Create your token on the My Profile -> API Tokens page in the Cloudflare dashboard.
var cf = require('cloudflare')({
token: 'your Cloudflare API token'
});
Every resource is accessed via your cf
instance:
// cf.{ RESOURCE_NAME }.{ METHOD_NAME }
Every resource method returns a promise, which can be chained or used with async/await.
cf.zones.read('023e105f4ecef8ad9ca31a8372d0c353').then(function (resp) {
return resp.result.status;
});
// where supported
async function getZoneStatus(id) {
var resp = await cf.zones.read('023e105f4ecef8ad9ca31a8372d0c353');
return resp.result.status;
}