Blackbaud K12 “ON” API

On Thursday, I’m co-presenting at the Blackbaud K12 User Conference on using their API. Simply put, an API (Application Programing Interface) is a way for code to interact with something—in this case the website my school uses. One does not need particularly advanced knowledge of how to code in order to write useful solutions.

Recently, I wrote code to:

  • Detect inconsistencies and errors between different systems. I check if all our students in one system exist in another.  Are all their names spelled the same?
  • Automate when a student is enrolled in a class in our Student Information System to add them to an Active Directory group on our servers.
  • Compare three different lists of people to see how they overlap.
  • Generate a print directory of all employees with their photos.

For most of this, I’ve used PowerShell, a modern scripting language from Microsoft that is popular with system administrators. It makes writing code to work with an API really easy.

For example, I use the Blackbaud K12 API to retrieve a list I created within their software and open it up in Excel. From there I can analyze, chart or merge the data.

# replace my_school, my_username and my_password with values from your school
$schoolWebsite = ""
$apiUser = "my_username"
$apiPassword = "my_password"

# Authenticate to the API, and get a token to use for further calls
$response = Invoke-RestMethod "$schoolWebsite/api/authentication/login?username=$apiUser&password=$apiPassword&format=json"

# Store the token as a variable so it's handy
$token = $response.Token

# Call the list API with the ID# of the list we want
$response = Invoke-RestMethod "$schoolWebsite/api/list/49748/?t=$token&format=json"

# Convert the response (an array) to a CSV file, and write it to disk
$response | Export-CSV -NoTypeInformation -Encoding ascii -Path "C:/tmp/list.csv"

# Open up the CSV file in Excel
Invoke-Item "C:\tmp\list.csv"

I’m putting together a GitHub repository of sample code for the Blackbaud K12 API. It can be a lot easier to modify existing code rather than build something from scratch. I will post a link on this blog when it is available.

, ,

2 responses to “Blackbaud K12 “ON” API”

  1. You now need to enforce TLS 1.2 in order for this to work. Luckily, it is easy to do so by adding the following line of Powershell Code at the start of the script:

    “#Enforce TLS 1.2 (required)
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12”

Leave a Reply

Your email address will not be published. Required fields are marked *