Cloudflare
Constructs and returns a new Cloudflare API client with the specified authentication.
Parameters
auth (Object)
The API authentication for an account
Name |
Description |
auth.email string
|
The account email address
|
auth.key string
|
The account API key
|
auth.token string
|
The account API token
|
Properties
zones (Zones)
: Zones instance
user (User)
: User instance
DNSRecords
DNSRecords represents the /zones/:zoneID/dns_records API endpoint.
new DNSRecords()
Extends
Resource
Instance Members
▸
edit(zone_id, id, record)
edit allows for modification of the specified DNS Record
Parameters
id (string)
The DNS record ID being modified
record (Object)
The modified dns record object
Returns
Promise<Object>
:
The DNS record object.
browse allows for listing all DNS Records for a zone
Parameters
Returns
Promise<Object>
:
The DNS browser response object.
export retrieves all of a zone's DNS Records in BIND configuration format.
Parameters
Returns
Promise<Object>
:
The DNS browser response object.
del allows for deleting the specified DNS Record
Parameters
id (string)
The DNS record ID to delete
Returns
Promise<Object>
:
The deleted DNS record object.
read allows for retrieving the specified DNS Record
Parameters
Returns
Promise<Object>
:
The DNS record object.
add allows for creating a new DNS record for a zone.
Parameters
record (Object)
The new DNS record object
Returns
Promise<Object>
:
The created DNS record object.
EnterpriseZoneWorkersScripts represents the accounts/:accountId/workers/scripts API endpoint.
new EnterpriseZoneWorkersScripts()
Extends
Resource
Instance Members
EnterpriseZoneWorkersRoutes
EnterpriseZoneWorkersRoutes represents the zones/:zoneId/workers/routes API endpoint.
new EnterpriseZoneWorkersRoutes()
Extends
Resource
Instance Members
browse allows for listing all of a zone's workers routes
Parameters
Returns
Promise<Object>
:
The route browse response object.
del allows for removing a workers routes
Parameters
id (string)
The route ID to delete
Returns
Promise<Object>
:
The custom route response object.
add allows for creating a workers route
Parameters
config (Object)
The new route object
Returns
Promise<Object>
:
The custom route response object.
▸
edit(zone_id, id, config)
edit allows for modifying a specific zone's workers
Parameters
config (Object)
The modified route object
Returns
Promise<Object>
:
The custom hostname response object.
read allows for retrieving a specific zone's workers route
Parameters
Returns
Promise<Object>
:
The route response object.
EnterpriseZoneWorkersKVNamespaces
EnterpriseZoneWorkersKVNamespaces represents the accounts/:accountId/storage/kv/namespaces API endpoint.
new EnterpriseZoneWorkersKVNamespaces()
Extends
Resource
Instance Members
▸
edit(account_id, id, config)
edit allows for renaming a workers namespace
Parameters
account_id (string)
The account ID
config (Object)
The namespace object
Returns
Promise<Object>
:
The namespace response object.
browse allows for listing all of a zone's workers namespaces
Parameters
account_id (string)
The account ID
Returns
Promise<Object>
:
The namespace response object.
▸
add(account_id, config)
add allows for creating a workers namespace
Parameters
account_id (string)
The account ID
config (Object)
The namespace object
Returns
Promise<Object>
:
The namespace response object.
del allows for deleting a workers namespace
Parameters
account_id (string)
The account ID
Returns
Promise<Object>
:
The namespace response object.
EnterpriseZoneWorkersKV
EnterpriseZoneWorkersKV represents the accounts/:accountId/storage/kv/namespaces API endpoint.
new EnterpriseZoneWorkersKV()
Extends
Resource
Instance Members
▸
browse(account_id, namespace_id)
browse allows for listing all the keys of a namespace
Parameters
account_id (string)
The account ID
namespace_id (string)
The namespace ID
Returns
Promise<Object>
:
The KV response object.
▸
add(account_id, namespace_id, value)
add allows for creating a key-value pair in a namespace
Parameters
account_id (string)
The account ID
namespace_id (string)
The namespace ID
value (string)
The value to store
Returns
Promise<Object>
:
The KV response object
▸
read(account_id, namespace_id, key_name)
read allows for reading the contents of key in a namespace
Parameters
account_id (string)
The account ID
namespace_id (string)
The namespace ID
key_name (string)
The key name
Returns
Promise<Object>
:
The KV response object
▸
del(account_id, namespace_id, key_name)
del allows for deleting a key and its contents in a namespace
Parameters
account_id (string)
The account ID
namespace_id (string)
The namespace ID
key_name (string)
The key name
Returns
Promise<Object>
:
The KV response object
▸
addMulti(account_id, namespace_id, data)
addMulti allows for creating multiple key-value pairs in a namespace
Parameters
account_id (string)
The account ID
namespace_id (string)
The namespace ID
data (Array<Object>)
An array containing key-vaue pair Objects to add
Returns
Promise<Object>
:
The KV response object
▸
delMulti(account_id, namespace_id, data)
delMulti allows for deleting multiple key-value pairs in a namespace
Parameters
account_id (string)
The account ID
namespace_id (string)
The namespace ID
Returns
Promise<Object>
:
The KV response object
IPs
IPs represents the /ips API endpoint.
new IPs()
Extends
Resource
Instance Members
browse returns a Promise of the current Cloudflare IPv4 and IPv6 addresses.
Returns
Promise<Object>
:
The IPv4 and IPv6 addresses
Example
cf.ips.browse(console.log)
PageRules represents the /zones/:zoneID/pagerules API endpoint.
new PageRules()
Extends
Resource
Instance Members
Zones
Zones represents the /zones API endpoint.
new Zones()
Extends
Resource
Instance Members
activationCheck initiates another zone activation check
Parameters
Returns
Promise<Object>
:
The response object
del allows for removing a new zone
Parameters
id (string)
The zone ID to delete
Returns
Promise<Object>
:
The zone response object.
add allows for creating a new zone
Parameters
zone (Object)
The new zone object
Returns
Promise<Object>
:
The zone response object.
edit allows for modifying a specific zone
Parameters
zone (Object)
The modified zone object
Returns
Promise<Object>
:
The zone response object.
read allows for retrieving a specific zone
Parameters
Returns
Promise<Object>
:
The zone response object.
▸
purgeCache(id, params?)
purgeCache purges files from Cloudflare's cache
Parameters
params (Object?)
Parameters to restrict purges
Name |
Description |
params.files (Array<string> | Array<Object>)?
|
Files to purge from the Cloudflare cache
|
params.tags Array<string>?
|
Purge files served with these Cache-Tag headers
|
params.hosts Array<string>?
|
Purge files that match these hosts
|
Returns
Promise<Object>
:
The response object
browse allows for listing all the zones
Returns
Promise<Object>
:
The zone browse response object.
ZoneSettings
ZoneSettings represents the /zones/:zoneID/settings API endpoint.
new ZoneSettings()
Extends
Resource
Instance Members
read retrieves a single zone setting
Parameters
setting (string)
= The setting name
Returns
Promise<Object>
:
The zone settings response object.
▸
edit(id, setting, value)
edit modifies a single zone setting
Parameters
setting (string)
= The setting name
Returns
Promise<Object>
:
The zone settings response object.
editAll allows for editing of all the zone settings at once
Parameters
settings (Object)
The modified zone settings
Returns
Promise<Object>
:
The response object
browse allows for listing all the zone settings
Parameters
Returns
Promise<Object>
:
The zone settings response object.
ZoneCustomHostNames
ZoneCustomHostNames represents the /zones/:zoneID/custom_hostnames API endpoint.
new ZoneCustomHostNames()
Extends
Resource
Instance Members
browse allows for listing all of a zone's custom hostanames
Parameters
Returns
Promise<Object>
:
The custom hostname browse response object.
read allows for retrieving a specific custom hostname
Parameters
id (string)
The custom hostname ID
Returns
Promise<Object>
:
The custom hostname response object.
▸
edit(zone_id, id, config)
edit allows for modifying a specific zone
Parameters
id (string)
The custom hostname ID
config (Object)
The modified custom hostname object
Returns
Promise<Object>
:
The custom hostname response object.
add allows for creating a new zone
Parameters
config (Object)
The new custom hostname object
Returns
Promise<Object>
:
The custom hostname response object.
del allows for removing a new zone
Parameters
id (string)
The custom hostname ID to delete
Returns
Promise<Object>
:
The custom hostname response object.
ZoneWorkers
ZoneWorkers represents the /zones/:zoneId/workers API endpoint.
new ZoneWorkers()
Extends
Resource
Instance Members
▸
validate(zoneId, script)
validate allows for validating a workers script
Parameters
script (string)
The worker script
Returns
Promise<Object>
:
The validate response object.
ZoneWorkersScript represents the /zones/:zoneID/workers/script API endpoint.
new ZoneWorkersScript()
Extends
Resource
Instance Members
ZoneWorkersRoutes
ZoneWorkersRoutes represents the zones/:zoneId/workers/filters API endpoint.
new ZoneWorkersRoutes()
Extends
Resource
Instance Members
browse allows for listing all of a zone's workers routes
Parameters
Returns
Promise<Object>
:
The route browse response object.
▸
edit(zone_id, id, config)
edit allows for modifying a specific zone's workers route
Parameters
config (Object)
The modified route object
Returns
Promise<Object>
:
The custom hostname response object.
read allows for retrieving a specific zone's workers route
Parameters
Returns
Promise<Object>
:
The route response object.
add allows for creating a workers route
Parameters
config (Object)
The new route object
Returns
Promise<Object>
:
The custom route response object.
del allows for removing a workers route
Parameters
id (string)
The route ID to delete
Returns
Promise<Object>
:
The custom route response object.
User
User represents the /user API endpoint.
new User()
Extends
Resource
Instance Members
read returns the current user object
Returns
Promise<Object>
:
The user object
edit allows for modification of the current user
Parameters
user (Object)
The modified user object
Returns
Promise<Object>
:
The user object
Stream
Stream represents the /accout/:id/stream API endpoint.
new Stream()
Extends
Resource
Instance Members
ListVideos retrieves all of a account's videos.
Parameters
accountId (string)
The account ID
Returns
Promise<Object>
:
The response object
▸
videoDetails(accountId, id)
VideoDetails retrieves details of a account's single video.
Parameters
accountId (string)
The account ID
Returns
Promise<Object>
:
The response object
▸
deleteVideo(accountId, id)
DeleteVideo deletes a account's single video.
Parameters
accountId (string)
The account ID
Returns
Promise<Object>
:
The response object