CloudFlare Class
API client for the CloudFlare Client API
Constructor
CloudFlare
-
token
-
email
Parameters:
-
token
StringAPI token from the (My Account)[https://www.cloudflare.com/my-account] page
-
email
StringEmail address associated with your CloudFlare account
Item Index
Methods
addDomainRecord
-
domain
-
options
-
fn
Add a DNS record
Create a DNS record for a zone
Parameters:
-
domain
StringThe target domain
-
options
Object-
type
StringType of DNS record. Values include: A, CNAME, MX, TXT, SPF, AAAA, NS, SRV and LOC
-
name
StringName of the DNS record.
-
content
StringThe content of the DNS record, will depend on the the type of record being added
-
[ttl=1]
String optionalTTL 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
StringThe target domain
-
value
BooleanTrue will use the "automatic" async setting, False will disable
-
value!~YUIDOC_LINE~!
String- 0 = off
- a = automatic
- m = manual
- 0 = off
-
fn
Function
banIp
-
ip
-
fn
Blacklist IPs
Blacklist an IP address
Parameters:
-
ip
StringThe 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
StringThe target domain
-
level
StringThe 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
StringThe 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
StringThe target domain
-
[v="1"]
String optionalValue can only be "1". It is recommended to omit this argument to allow the default to be used.
-
fn
Function
createRequestData
-
action
-
params
Creates the request data for the provided action
Parameters:
-
action
String -
params
Object
Returns:
deleteDomainRecord
-
domain
-
id
-
fn
Edit a DNS record
Delete a record for a domain.
Parameters:
-
domain
StringThe target domain
-
id
StringDNS 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
StringThe target domain
-
enable
BooleanTrue 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
StringThe zone (domain) that statistics are being retrieved from
-
interval
StringThe 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
StringThe target domain
-
id
StringDNS Record ID. Available by using the recloadall call.
-
options
Object-
type
StringType of DNS record. Values include: A, CNAME, MX, TXT, SPF, AAAA, NS, SRV and LOC
-
name
StringName of the DNS record.
-
content
StringThe content of the DNS record, will depend on the the type of record being added
-
[ttl=1]
String optionalTTL 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
StringThe target domain
-
enable
BooleanDisable 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
StringThe 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
StringThe target domain
-
setting
BooleanFalse will disable
-
setting
StringShould 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
StringThe target domain
-
level
StringThe 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
StringThe IP address you want to unlist
-
fn
Function
whitelistIp
-
ip
-
fn
Whitelist IPs
Whitelist an IP address
Parameters:
-
ip
StringThe IP address you want to whitelist/blacklist
-
fn
Function
zoneCheck
-
zones
-
zones
-
fn
Checks for active zones and returns their corresponding zids
Parameters:
-
zones
StringList of zones separated by comma
-
zones
ArrayList 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
StringThe target domain
-
url
StringThe 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
StringID 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
StringThe target domain
-
options
Object-
[hours=24]
String optionalPast number of hours to query. Default is 24, maximum is 48.
-
[class]
String optionalRestrict the result set to a given class as given by: - "r" -- regular - "s" -- crawler - "t" -- threat
-
[geo]
String optionalOptional. 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
StringThe target domain
-
fn
Function