Retrieving the total attendance for multiple events using CCB’s API.

Today, I’m back with a simple tutorial that expounds upon on a previous tutorial: Retrieving the total attendance for a specific event using CCB’s API.

We’ve successfully mastered retrieving total attendance for a specific event, but what if I have more than one event?

Of course, the straightforward answer would be to repeat the same call until you’ve retrieved all events.

And although it is one way of answering the question, it’s quite expensive to make so many calls.

If you’re a church with a hand full or not many events, then it may make sense to perform such these calls.

However, if you’re a church with more than 10 events, then today’s tutorial will show you how to get all events and their respective total attendance.

I won’t go into the nitty-gritty details of the inner works. Feel free to read the previous tutorial.

Minor changes made to this tutorial is the use of the following:

  • Use of attendance_profiles instead of attendance_profile
  • Required start and end dates when making CCB API call
  • Use of //events/event as the XPATH query expression

Again, it would be quite expensive to execute this script without the dates. That stated, be mindful not to execute this script with start dates dating back to the first event ever entered into CCB.

In most cases, I would imagine that you’re likely going to use this script to report weekly, monthly and quarterly total attendance for each event occurrence.

With a bit of elbow grease, one could modify this script to use dropdowns displaying a list of events and another displaying date range. And don’t forget to add in some filters or auto complete search for events.

You achieve the aforementioned ideas and you’ll be well on your way to a reporting engine, and answering the questions of how many attendees an event had registered or how many spaces remain available for an event.

That’s it for today’s tutorial. Drop me a comment or question below should you have any ideas or encounter any challenges.


Please comment if this tutorial has helped you.