Package Exports
- cloudflare
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cloudflare) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
CloudFlare API Client for Node.js
An edible "BREAD" (Browse, Read, Edit, Add, and Delete) API Client for the CloudFlare v4 Client API.
With this API client, you'll get the following features:
- Promise-based API, allowing for easy async/await usage in harmony JavaScript engines, and with JavaScript transpilers.
- Effortlessly connects over HTTP/2.
- Automatic handling of Gzip/Deflate compression.
- Expontential backoff and retry in the presence of error.
Node.js Support
This CloudFlare API client supports Node.js v4 and greater.
Usage
Creating a Client
var CFClient = require('cloudflare');
var client = new CFClient({
email: 'you@example.com',
key: 'deadbeef'
});Zones
Zone
- API Reference: Zone properties
A normalized representation of a CloudFlare Zone. Properties that were
snake_cased have been aliased to camelCased. TODO: document all the known
properties.
Zone.create(properties): Zone
- properties: The properties to set on the new
Zoneobject. - Returns: A new
Zoneobject.
Creates a new Zone object with the provided properties. The returned object
can be used with the below methods that accept a Zone object.
Zone.is(z): boolean
- z: The other object that may, or may not, be a
Zoneobject. - Returns:
trueif the parameter is aZoneobject, otherwisefalse.
browseZones([query, [options]]): Promise<PaginatedResponse<Zone[]>>
- query: An object to pass filter and sorting parameters to the API
- options: see Request Options
- Returns: A Promise that resolves to a list of
Zoneobjects wrapped in aPaginatedResponse - API Reference: List zones
Retrives the list of Zone objects, optionally filtered and sorted by query options.
readZone(z_id, [options]): Promise<Zone>
- z_id: The string Zone id
- options: see Request Options
- Returns: A Promise that resolves to a
Zone - API Reference: Zone details
Retrives the Zone for the zone identifier z_id.
editZone(z, [options]): Promise<Zone>
- z:
Zoneobject - options: see Request Options
- Returns: A Promise that resolves to a
Zone. - API Reference: Edit Zone Properties
Saves the modifications to the Zone object.
Note: The CloudFlare API currently doesn't support patching multiple properties at once. This method executes the modifications in series, but if an error occurs, there are no guarantees which properties would have been applied.
addZone(z, [jumpstart, [options]]): Promise<Zone>
- z:
Zoneobject - jumpstart:
trueto automatically fetch existing DNS records (default).falseto disable this behavior. - options: see Request Options
- API Reference: Create a zone
Add a zone to an account or organization.
checkZoneActivation(z): Promise<{id: string}>
- z:
Zoneobject - API Reference: Initiate another zone activation check
Initiate another zone activation check.
deleteZone(z, [options]): Promise<{id: string}>
- z:
Zoneobject or string zone id - options: see Request Options
- Returns: A Promise that resolves to a tombstone stub
- API Reference: Delete a zone
Deletes the Zone from CloudFlare. A tombstone stub is returned.
deleteCache(z, query, [options]): Promise<bool>
- z:
Zoneobject or string zone id - query: The (required) purge options for the API:
purge_everything: Delete all of the zone's content from the CloudFlare cache. Note: This may cause an increase in connections to your server after performing this action.files: An array of URLs that should be removed from cache.tags: Removes assets from cache that were served with a Cache-Tag header that matches a string in this array.
- options: see Request Options
- Returns: A Promise that resolves to
true. - API Reference: Purge all files and Purge individual files by URL and Cache-Tags
Purges content from CloudFlare's cache. Please note that query is required for
this API call.
DNS
The CloudFlare API client makes it easy to manage DNS records for domains on CloudFlare.
DNSRecord
- API Reference: DNS Records for a Zone
A normalized representation of a CloudFlare DNS Record type. Properties that
were snake_cased have been aliased to be camelCased.
DNSRecord.create(properties): DNSRecord
- properties: The properties to set on the new
DNSRecordobject. - Returns: A new
DNSRecordobject.
Creates a new DNSRecord object with the provided properties. The returned
object can be used with the below methods that accept a DNSRecord object.
DNSRecord.is(rr): boolean
- rr: The other object that may, or may not, be a
DNSRecordobject. - Returns:
trueif the parameter is aDNSRecordobject, otherwisefalse.
browseDNS(z, [query, [options]]): Promise<PaginatedResponse<DNSRecord[]>>
- z:
Zoneobject or string zone id - query: An object to pass filter and sorting parameters to the API
- options: see Request Options
- Returns: A Promise that resolves to a list of
DNSRecordobjects wrapped in aPaginatedResponse - API Reference: List DNS Records
Retrives the listing of DNSRecord objects for a Zone (or zone id).
readDNS(dns_id, z, [options]): Promise<DNSRecord>
- dns_id: The string DNS record id
- z:
Zoneobject or string zone id - options: see Request Options
- Returns: A Promise that resolves to a
DNSRecord - API Reference: DNS record details
Retrive the DNSRecord for an identifier did from Zone (or zone id).
editDNS(d, [options]): Promise<DNSRecord>
- d: The
DNSRecordto be saved - options: see Request Options
- Returns: A Promise that resolves to a new
DNSRecord - API Reference: Update DNS record
Save the modifications to the DNSRecord.
addDNS(d, [options]): Promise<DNSRecord>
- d: The
DNSRecordto be added - options: see Request Options
- Returns: A Promise that resolves to a new
DNSRecord - API Reference: Create DNS record
Create a DNS Record corresponding to the provided DNSRecord. A new DNSRecord
with an id field is returned.
deleteDNS(d, [options]): Promise<{id: string}>
- d: The
DNSRecordto be deleted - options: see Request Options
- Returns: A Promise that resolves to a tombstone stub
- API Reference: Delete DNS record
Deletes the DNSRecord from the DNS. A tombstone stub is returned.
CloudFlare IPs
IPRanges
- API Reference: CloudFlare IPs properties
Normalized representation of the CloudFlare IP Ranges.
IPRanges{
IPv4CIDRs: [
'199.27.128.0/21'
],
IPv6CIDRs: [
'2400:cb00::/32'
]
}IPRanges.is(ip): boolean
- ip: The other object that may, or may not, be an
IPRangesobject. - Returns:
trueif the parameter is aIPRangesobject, otherwisefalse.
readIPs(): Promise<IPRanges>
- Returns: A Promise that resolves to
IPRanges - API Reference: CloudFlare IPs
Retrieves the CloudFlare Edge IP addresses. These are the IP addresses used by CloudFlare to connect to your server.