Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cloudflare4

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudflare4

CloudFlare V4 API wrapper

  • 0.2.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

NPM version Downloads

CloudFlare API v4

The Cloudflare4 module allows you to communicate with the CloudFlare V4 API from node.js in a promise friendly manner.

It also supports automatic request retries.

Installation

This module is published in NPM:

npm install cloudflare4 --save

The --save tells NPM to automatically add it to your package.json file

Usage

// Import a module
var CloudFlareAPI = require('cloudflare4');

// Create an instance with your API V4 credentials
var api = new CloudFlareAPI({email: 'email@domain.com', key: 'my_key'});

// Get things done
api.userFirewallAccessRuleGetAll().then(function (rules) {
	console.log(rules);
});

Config

new CloudFlareAPI({
	email: 'email@domain.com',
	key: 'my_key',
	itemsPerPage: 100, // default=100
	maxRetries: 5, // default=5
	raw: false // default=false,
	autoPagination: false, // default=false
	autoPaginationConcurrency: 1 // default=1
});

Pagination

you can pass pagination params into any method that has a body or query argument.

api.userFirewallAccessRuleGetAll({per_page: 1, page: 2}).then(function (rules) {
	console.log(rules);
});

or with auto-pagination

api.userFirewallAccessRuleGetAll({auto_pagination: true, auto_pagination_concurrency: 1}).then(function (rules) {
	console.log(rules);
});

Note: if you use auto_pagination for a GetAll the raw argument is no longer respected

Raw

if you set raw it will return the full response body including pagination details

api.userGet(true)

would return

{
	result: { 
		id: 'dc19c3231tds452eb4ebc123d6eb4c99',
		email: 'email@domain.com',
		username: 'username',
		first_name: 'Foo',
		last_name: 'Bar',
		telephone: '5555555555',
		country: null,
		zipcode: null,
		two_factor_authentication_enabled: false,
		two_factor_authentication_locked: false,
		created_on: '2014-09-29T13:21:56.807670Z',
		modified_on: '2015-10-04T00:02:50.855108Z',
		organizations: null,
		has_pro_zones: true,
		has_business_zones: false,
		has_enterprise_zones: false
	},
	success: true,
	errors: [],
	messages: []
}

and with raw set to false (the default), it would return

{ 
	id: 'dc19c3231tds452eb4ebc123d6eb4c99',
	email: 'email@domain.com',
	username: 'username',
	first_name: 'Foo',
	last_name: 'Bar',
	telephone: '5555555555',
	country: null,
	zipcode: null,
	two_factor_authentication_enabled: false,
	two_factor_authentication_locked: false,
	created_on: '2014-09-29T13:21:56.807670Z',
	modified_on: '2015-10-04T00:02:50.855108Z',
	organizations: null,
	has_pro_zones: true,
	has_business_zones: false,
	has_enterprise_zones: false
}

Debugging

we use the debug module so you can debug the http requests by doing the following

DEBUG=http node myfile.js

also all methods enforce type checking so invalid usage would result in errors like this

Debug Example

Methods

All methods follow the official API documentation.

User

User Billing Profile

User Billing History

App Subscription

Zone Subscription

User-level Firewall access rule

User's Organizations

User's Invites

Zone

Zone Plan

Worker Script

Zone Settings

DNS Records for a Zone

Railgun connections for a Zone

Zone Analytics

Railgun

Custom Pages for a Zone

Custom SSL for a Zone

Keyless SSL for a Zone

Firewall access rule for a Zone

WAF Rule Packages

WAF Rule Groups

WAF Rules

Organizations

Organization Members

Organization Invites

Organization Roles

Organization-level Firewall access rule

Page rules for a Zone

Keywords

FAQs

Package last updated on 05 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc