API Docs for:
Show:

CloudFlare Class

Defined in: lib/cloudflare.js:34

API client for the CloudFlare Client API

Constructor

CloudFlare

(
  • token
  • email
)

Parameters:

  • token String

    API token from the (My Account)[https://www.cloudflare.com/my-account] page

  • email String

    Email address associated with your CloudFlare account

Methods

addDomainRecord

(
  • domain
  • options
  • fn
)

Add a DNS record

Create a DNS record for a zone

Parameters:

  • domain String

    The target domain

  • options Object
    • type String

      Type of DNS record. Values include: A, CNAME, MX, TXT, SPF, AAAA, NS, SRV and LOC

    • name String

      Name of the DNS record.

    • content String

      The content of the DNS record, will depend on the the type of record being added

    • [ttl=1] String optional

      TTL of record in seconds. Value must be in between 120 and 4,294,967,295 seconds. A value of 1 is the default "automatic"

    • prio String

      [MX/SRV only] MX record priority.

    • service String

      [SRV only] Service for SRV record

    • srvname String

      [SRV only] Service Name for SRV record

    • protocol String

      [SRV only] Protocol for SRV record. Values include: [tcp/udp/_tls].

    • weight String

      [SRV only] Weight for SRV record.

    • port String

      [SRV only] Port for SRV record

    • target String

      [SRV only] Target for SRV record

  • fn Function

async

(
  • domain
  • value
  • value!~YUIDOC_LINE~!
  • fn
)

Set Rocket Loader

Changes Rocket Loader setting

Parameters:

  • domain String

    The target domain

  • value Boolean

    True will use the "automatic" async setting, False will disable

  • value!~YUIDOC_LINE~! String
    • 0 = off
      • a = automatic
      • m = manual
  • fn Function

banIp

(
  • ip
  • fn
)

Blacklist IPs

Blacklist an IP address

Parameters:

  • ip String

    The IP address you want to whitelist/blacklist

  • fn Function

cacheLevel

(
  • domain
  • level
  • fn
)

Set the cache level

This function sets the Caching Level to Aggressive or Basic.

Parameters:

  • domain String

    The target domain

  • level String

    The cache level: * "agg" -- Aggressive * "basic" -- Basic

  • fn Function

checkIp

(
  • ip
  • fn
)

Check threat score for a given IP

Find the current threat score for a given IP. Note that scores are on a logarithmic scale, where a higher score indicates a higher threat.

Parameters:

  • ip String

    The target IP

  • fn Function

clearCache

(
  • domain
  • [v="1"]
  • fn
)

Clear CloudFlare's cache

This function will purge CloudFlare of any cached files. It may take up to 48 hours for the cache to rebuild and optimum performance to be achieved so this function should be used sparingly.

Parameters:

  • domain String

    The target domain

  • [v="1"] String optional

    Value can only be "1". It is recommended to omit this argument to allow the default to be used.

  • fn Function

createRequestData

(
  • action
  • params
)
Object protected

Creates the request data for the provided action

Parameters:

  • action String
  • params Object

Returns:

Object:

deleteDomainRecord

(
  • domain
  • id
  • fn
)

Edit a DNS record

Delete a record for a domain.

Parameters:

  • domain String

    The target domain

  • id String

    DNS Record ID. Available by using the recloadall call.

  • fn Function

devmode

(
  • domain
  • enable
  • fn
)

Toggling Development Mode

This function allows you to toggle Development Mode on or off for a particular domain. When Development Mode is on the cache is bypassed. Development mode remains on for 3 hours or until when it is toggled back off.

Parameters:

  • domain String

    The target domain

  • enable Boolean

    True to enable, False to disable

  • fn Function

domainStats

(
  • domain
  • interval
  • fn
)

Retrieve domain statistics for a given time frame

Retrieve the current stats and settings for a particular website. This function can be used to get currently settings of values such as the security level.

For these values, the latest data is from one day ago

  • 20 = Past 30 days
  • 30 = Past 7 days
  • 40 = Past day

The values are for Pro accounts

  • 100 = 24 hours ago
  • 110 = 12 hours ago
  • 120 = 6 hours ago

Parameters:

  • domain String

    The zone (domain) that statistics are being retrieved from

  • interval String

    The time interval for the statistics denoted by these values:

  • fn Function

editDomainRecord

(
  • domain
  • id
  • options
  • fn
)

Edit a DNS record

Edit a DNS record for a zone. The record will be updated to the data passed through arguments here.

Parameters:

  • domain String

    The target domain

  • id String

    DNS Record ID. Available by using the recloadall call.

  • options Object
    • type String

      Type of DNS record. Values include: A, CNAME, MX, TXT, SPF, AAAA, NS, SRV and LOC

    • name String

      Name of the DNS record.

    • content String

      The content of the DNS record, will depend on the the type of record being added

    • [ttl=1] String optional

      TTL of record in seconds. Value must be in between 120 and 4,294,967,295 seconds. A value of 1 is the default "automatic"

    • prio String

      [MX/SRV only] MX record priority.

    • service String

      [SRV only] Service for SRV record

    • srvname String

      [SRV only] Service Name for SRV record

    • protocol String

      [SRV only] Protocol for SRV record. Values include: [tcp/udp/_tls].

    • weight String

      [SRV only] Weight for SRV record.

    • port String

      [SRV only] Port for SRV record

    • target String

      [SRV only] Target for SRV record

  • fn Function

ipv46

(
  • domain
  • enable
  • fn
)

Toggle IPv6 support

Toggles IPv6 support

Parameters:

  • domain String

    The target domain

  • enable Boolean

    Disable with false, enable with true

  • fn Function

listDomainRecords

(
  • domain
  • fn
)

Retrieve DNS Records of a given domain

Lists all of the DNS records from a particular domain in a CloudFlare account

Parameters:

  • domain String

    The domain that records are being retrieved from

  • fn Function

listDomains

(
  • fn
)

Retrieve the list of domains

This lists all domains in a CloudFlare account along with other data.

Parameters:

  • fn Function

minify

(
  • domain
  • setting
  • setting
  • fn
)

Set Minification

Changes minification settings

Parameters:

  • domain String

    The target domain

  • setting Boolean

    False will disable

  • setting String

    Should be one of the following: - 0 = off - 1 = JavaScript only - 2 = CSS only - 3 = JavaScript and CSS - 4 = HTML only - 5 = JavaScript and HTML - 6 = CSS and HTML - 7 = CSS, JavaScript, and HTML

  • fn Function

secLvl

(
  • domain
  • level
  • fn
)

Set the security level

This function sets the Basic Security Level to:

  • "help" -- I'm under attack!
  • "high" -- High
  • "med" -- Medium
  • "low" -- Low
  • "eoff" -- Essentially Off

Parameters:

  • domain String

    The target domain

  • level String

    The security level: * "help" -- I'm under attack! * "high" -- High * "med" -- Medium * "low" -- Low * "eoff" -- Essentially Off

  • fn Function

unlistIp

(
  • ip
  • fn
)

Unlist IPs

Remove an IP from both the whitelist and ban list

Parameters:

  • ip String

    The IP address you want to unlist

  • fn Function

whitelistIp

(
  • ip
  • fn
)

Whitelist IPs

Whitelist an IP address

Parameters:

  • ip String

    The IP address you want to whitelist/blacklist

  • fn Function

zoneCheck

(
  • zones
  • zones
  • fn
)

Checks for active zones and returns their corresponding zids

Parameters:

  • zones String

    List of zones separated by comma

  • zones Array

    List of zones

  • fn Function

zoneFilePurge

(
  • domain
  • url
  • fn
)

Purge a single file in CloudFlare's cache

This function will purge a single file from CloudFlare's cache.

Parameters:

  • domain String

    The target domain

  • url String

    The full URL of the file that needs to be purged from Cloudflare's cache. Keep in mind, that if an HTTP and an HTTPS version of the file exists, then both versions will need to be purged independently

  • fn Function

zoneGrab

(
  • options
  • fn
)

Update the snapshot of site for CloudFlare's challenge page

Tells CloudFlare to take a new image of your site.

Parameters:

  • options Object
    • zid String

      ID of zone, found in zone_check

  • fn Function

zoneIps

(
  • domain
  • options
  • fn
)

Pull recent IPs visiting site

Returns a list of IP address which hit your site classified by type.

Parameters:

  • domain String

    The target domain

  • options Object
    • [hours=24] String optional

      Past number of hours to query. Default is 24, maximum is 48.

    • [class] String optional

      Restrict the result set to a given class as given by: - "r" -- regular - "s" -- crawler - "t" -- threat

    • [geo] String optional

      Optional. Set to 1 to add longitude and latitude information to response

  • fn Function

zoneSettings

(
  • domain
  • fn
)

List all current setting values

Retrieves all current settings for a given domain.

Parameters:

  • domain String

    The target domain

  • fn Function