Quick Classy live fundraising chart

Want to project a live status chart on your conference room wall? It’s easy with the Classy API + Power BI Online. Also key: it’s quicker than the docs make you believe!

With a little bit of code, you can watch this chart update in almost-real-time!

What is Classy?

Classy is an online fundraising platform for nonprofits. It offers crowdfunding, peer-to-peer, and event-based campaigns. A key component is the Classy API. The API, at its heart, is a way to get information in and out of the Classy platform.

What is Power BI?

Power BI a powerful “business intelligence” platform that makes it relatively easy to create advanced charts, graphs, maps, and data tables. It’s particularly useful for mashing up datasets from different sources. Crucially for this project, it also has an API. However, it also has what is, as far as I can tell, an undocumented API, that makes it super simple to push data into a dataset. The basic version is free.

Why would you do this?

You might like to have a chart that updates every minute or so with your current fundraising totals. You also very much might not. You can also access the dashboard on your phone, so it’s an easy way to see exactly where you are at any given moment.

What you need:

  • PowerBI account (free)
  • Classy account
  • Minimal experience with Node.js
  • A computer or server to run a Node app on. (See my article on how to get free Azure services for nonprofits, which includes a Node web app service.) This app needs to run all the time in order to grab the data from Classy and push it to Power BI. This app needs to access web URI’s, but does not need to run a public-facing server.

Putting it together

I’m not going to go into code line-by-line. But I will point you in the right directions.

Start with Power BI

This part tripped me up and kept me from doing this project for a long time. If you go to the Power BI documentation, you’ll find a section that details creating an app registration in Azure AD, getting an authentication token, creating a dataset, adding rows to that dataset, and finally, six pages later, adding data to your dataset. No. You don’t need to do that. You just need to create a streaming dataset: Workspace > Create > Streaming Dataset > API.

All you need is a streaming dataset — no complicated API configuration

It is very important how you set up your streaming dataset, because as far as I can tell you can’t add fields to it later. Each row will include several fields, and each row represents a point in time. Key fields to include are:

  • Campaign Name
  • Date/time
  • Total Amount Raised

Others you might want to include are

  • Donors count
  • Fundraisers count
  • Transactions count
  • Any other statistics that you want to plot over time

As you enter your fields in Power BI, you’ll get an example JSON document with all the fields and example values. Copy it when you are done so you can reference it later in your Node app.

Finally, make sure you enable “Historic data analysis” or only the most recent data will be saved. Once enabled, the system will keep the most recent 200,000 rows. (Keep this in mind for deciding how often to push an update to Power BI.)

Click create, and then copy the Push URL and the “raw” JSON payload. You’ll need those for the Node.js app.

Get your Classy API key and secret, and campaign ID

You can do this through your Classy dashboard. Create a new key and secret for this project so you can disable access later. Since Classy doesn’t let you specify permissions for API keys, and since you can do basically anything in your account with an API key, it is particularly important to keep it secret.

Your campaign ID might be harder to find — Classy doesn’t display it anywhere. However it is in the URL for most campaign admin screens. Mine are five-digit numbers.

Write a Node.js app

This is probably one of the simplest Node.js apps you can write. Create a function that will

  1. Grab the campaign overview (or other relevant information) from Classy (Use the classy-node library)
  2. Create a JSON object modeled on the example you copied from Power BI, but filled with data returned from Classy. Only include fields defined in the Power BI dataset, or it will return an error.
  3. POST that JSON document to the Power BI Push URL you copied earlier.

Use a timer call that function every so often. I would recommend 30 seconds. You can probably get away with five minutes. Remember that you can only store 200,000 rows in Power BI using this system. Multiply that times your interval (in seconds) to find out how many seconds of data you can store:

200,000 x 30 seconds = 6,000,000 seconds = 69.4 days
200,000 x 5 seconds = 1,000,000 seconds = 11.6 days

Build a Power BI dashboard

Once you have a dataset, you can easily build a report by selecting visualizations and dragging the fields into position. Those visualizations can be pinned onto a dashboard, and that dashboard will update as new information comes in.

Tip: if you’re using a Card (single-number) visualization, choose to display the Maximum instead of the Sum. The sum will show you the sum of all the fundraising totals in the dataset, which of course will make no sense.

Choose to show the Maximum instead of the Sum.

Once you’ve fiddled a bit, you should be able to end up with a dashboard like this. The chart is a Line Chart with the date/time as the axis, the event name as the legend, and the total raised as the values:

After a couple days, your chart might look something like this.

A couple things to note

You can’t retroactively add data historic data. You also can’t change the dataset definition in Power BI once you create it. So if you want to add another field (say you forgot to push the Classy fees amount and now you really need it), your charts will have to start from the current point in time. Kinda a bummer, so think ahead.

You can send data on multiple events to the dashboard. This way you can chart them against each other. Note that having two events requires two rows for every time period, so you reduce how long you keep the data by half.

What will you build?

What might you build with these tools? What would take it to the next level?