{"id":13,"date":"2016-07-13T03:12:31","date_gmt":"2016-07-13T03:12:31","guid":{"rendered":"http:\/\/duff.io\/?p=13"},"modified":"2016-07-13T03:12:31","modified_gmt":"2016-07-13T03:12:31","slug":"blackbaud-k12-on-api","status":"publish","type":"post","link":"https:\/\/duff.io\/?p=13","title":{"rendered":"Blackbaud K12 &#8220;ON&#8221; API"},"content":{"rendered":"<p>On Thursday, I&#8217;m co-presenting at the <a href=\"http:\/\/k12hub.blackbaud.com\/h\/c\/219543-blackbaud-k-12-user-conference-2016\">Blackbaud K12 User Conference<\/a> on using their API. Simply put, an API (Application Programing Interface) is a way for code to interact with something&mdash;in this case the website my school uses.\u00a0One does not need particularly advanced knowledge of how to code in order to write useful solutions.<\/p>\n<p>Recently, I wrote code to:<\/p>\n<ul>\n<li>Detect inconsistencies and errors between different\u00a0systems. I check if all our students in one system exist in another. \u00a0Are all their names spelled the same?<\/li>\n<li>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.<\/li>\n<li>Compare three\u00a0different lists of people to see how they overlap.<\/li>\n<li>Generate a print directory of all employees with their photos.<\/li>\n<\/ul>\n<p>For most of this, I&#8217;ve used <a href=\"https:\/\/msdn.microsoft.com\/powershell\">PowerShell<\/a>, a modern scripting language from Microsoft that is popular with system administrators. It makes writing code to work with an API really easy.<\/p>\n<p>For example, I use the <a href=\"http:\/\/on-api.developer.blackbaud.com\/\">Blackbaud K12 API<\/a> 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.<\/p>\n<pre class=\"brush: powershell\">\n# replace my_school, my_username and my_password with values from your school\n$schoolWebsite = \"https:\/\/my_school.myschoolapp.com\"\n$apiUser = \"my_username\"\n$apiPassword = \"my_password\"\n\n# Authenticate to the API, and get a token to use for further calls\n$response = Invoke-RestMethod \"$schoolWebsite\/api\/authentication\/login?username=$apiUser&password=$apiPassword&format=json\"\n\n# Store the token as a variable so it's handy\n$token = $response.Token\n\n# Call the list API with the ID# of the list we want\n$response = Invoke-RestMethod \"$schoolWebsite\/api\/list\/49748\/?t=$token&format=json\"\n\n# Convert the response (an array) to a CSV file, and write it to disk\n$response | Export-CSV -NoTypeInformation -Encoding ascii -Path \"C:\/tmp\/list.csv\"\n\n# Open up the CSV file in Excel\nInvoke-Item \"C:\\tmp\\list.csv\"\n<\/pre>\n<p>I&#8217;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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On Thursday, I&#8217;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&mdash;in this case the website my school uses.\u00a0One does not need particularly advanced knowledge of how to code in order to write useful solutions. Recently, I [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6,7],"tags":[],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-blackbaudk12","category-powershell","category-programing"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13"}],"version-history":[{"count":0,"href":"https:\/\/duff.io\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions"}],"wp:attachment":[{"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/duff.io\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}