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 revelations
to 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:
- 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.
- 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).
- Your account email address.
- You may interface with the API via HTTPS POST or GET requests to www.cloudflare.com/api_json.html
Commonly used API features
If 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 cache
If 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 site
One 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 CloudFlare
While 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 page
If 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.