Your First API Call

Talk about utilizing the CCB API. Feel free to share your code so others can take advantage of your enhancements!
Post Reply
User avatar
ccbug_admin
Member
Posts: 106
Joined: Wed Oct 14, 2015 8:06 pm

Your First API Call

Post by ccbug_admin » Mon Nov 02, 2015 1:41 pm

Prerequisites
Instructions

Lets start by connecting to the API and finding out how many API calls we have available and how many we have used for today.
  1. Open a command prompt.
  2. Type: curl -u api_user:api_password "https://yourchurch.ccbchurch.com/api.php?srv=api_status"
  3. Press enter.
You should see a response something like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ccb_api>
     <request>
          <parameters>
               <argument value="api_status" name="srv"/>
          </parameters>
     </request>
     <response>
          <last_run_date>2015-11-02</last_run_date>
          <daily_limit>10000</daily_limit>
          <counter>3</counter>
     </response>
</ccb_api>

Note in the above you have to replace api_user with the username you created in the API Key article above and the password with the password created at the same time. Your CCB username and password are not the same as your API Key username and password.

Command Explanation
  • cURL is the program we are using to make the request.
  • -u tells cURL to expect a username (api_user) and a password, separated by a colon (if there wasn't a colon cURL wouldn't know where the username ended and the password began).
  • Lastly we have the URL that tells CCB exactly what we are asking for - in this case the api_status.
Result Explanation


The CCB API replies with XML. You can learn about XML here.

The meat of things is found within the <response></response> element.
  • last_run_date shows us the last day we made a call to the API.
  • daily_limit shows the maximum number of calls you can make to the API on a daily basis.
  • counter shows how many API calls you have made today.
Any questions?
Last edited by ccbug_admin on Mon Nov 02, 2015 2:37 pm, edited 1 time in total.

Post Reply