Subscribe to receive notifications of new posts:

CloudFlare Tips: 5 Frequently used CloudFlare API calls

2011-09-16

2 min read

[

](http://www.flickr.com/photos/damonbillian/3146028677/ "Sumatran Tiger: San Francisco Zoo by dbillian, on Flickr")Editor's Note: Some of you may be asking why CloudFlare is using an image of a tiger for something related to the CloudFlare API. Since Ian Pye of CloudFlare is our API lead, I asked Ian what image he would like in the blog post about the API. His response to me: "A tiger. Our API is like a tiger. Oh, and everyone likes tigers." So, now you know the story of why a tiger is in the CloudFlare API post.

As many of our Facebook fans and Twitter followers may have noticed recently, CloudFlare has been spending a fair amount of time recently asking what we can do to improve the service. One of the most startling revelationsto me was that many of our customers don't know we have a CloudFlare API that mimics many of the features found in your CloudFlare settings' page, even though we have the API fairly well documented in the CloudFlare Forums, so I thought I would put together a little "cheat sheet" for frequently used API features.

Things you need to know or get before using the API:

  1. You will need to get your API key for your account first. You can locate the API key by going to your 'My Account' page.

  2. Each zone (yourdomain.com) on CloudFlare has a unique number identifier. If you need to locate the zoneid for a domain, simply go to the "Reports and Stats' link for that domain (the zone id appears at the end with an equal sign, such as zid=xxxxxx).

  3. Your account email address.

  4. You may interface with the API via HTTPS POST or GET requests to www.cloudflare.com/api_json.html

Commonly used API features

Development ModeIf you plan on making changes to the static content CloudFlare caches on your site, it is best for you go to Development Mode first to bypass the CloudFlare cache so these changes appear immediately.

Purge CloudFlare cacheIf you want to purge your CloudFlare cache, or if you forgot to go to Development Mode when making changes to your site, you may purge your CloudFlare cache so that these changes appear. You would only want to do this when you really want to purge all the static content CloudFlare has stored in the cache for that domain. Purging is not selectively done by file extension or file name.

Pulling basic statistics for your siteOne of the most common requests we get from our users is that they would like to share their statistics with clients without providing login details to the account. While we currently don't offer a way for people to access an account with a "read only" option, you can use the API to grab basic CloudFlare statistics from your account.

Reporting spam back to CloudFlareWhile the reporting spam back to CloudFlare API option has been fairly well documented on our blog already, you would use this option if CloudFlare's data sources don't catch some sources of spam that make it through to websites (we're always looking to improve).

Since we rely on our community of websites to alert us to online threats reported to us through the API or threat control, it actually helps make our system smarter for all sites on the system and can help stop spam from hitting other sites as well.

Updating your screen capture on your challenge pageIf the look and feel of your site changes frequently, you probably want to update the image associated with your CloudFlare challenge (captcha) page on a regular basis so your visitors know that they are hitting your site.

The specific calls and parameters for using each of these API functions can be found in the CloudFlare Client Interface API.

Have a suggestion about improving the API? Please contact CloudFlare with any requests.

Cloudflare's connectivity cloud protects entire corporate networks, helps customers build Internet-scale applications efficiently, accelerates any website or Internet application, wards off DDoS attacks, keeps hackers at bay, and can help you on your journey to Zero Trust.

Visit 1.1.1.1 from any device to get started with our free app that makes your Internet faster and safer.

To learn more about our mission to help build a better Internet, start here. If you're looking for a new career direction, check out our open positions.
APIProduct NewsDevelopersBest Practices

Follow on X

Cloudflare|@cloudflare

Related posts

October 24, 2024 1:00 PM

Durable Objects aren't just durable, they're fast: a 10x speedup for Cloudflare Queues

Learn how we built Cloudflare Queues using our own Developer Platform and how it evolved to a geographically-distributed, horizontally-scalable architecture built on Durable Objects. Our new architecture supports over 10x more throughput and over 3x lower latency compared to the previous version....