D4H API

The D4H API (Application Programmer Interface) is a powerful way to access and interoperate with your organization’s D4H data, and enhance your organization’s D4H usage of it with your own developments.

For example you can create your own mobile application for D4H (in additional to the D4H mobile applications, that use the API.) That, or you can craft your own simple scripts, e.g. to provide a custom quiz to your users via the whiteboard.

The simplest way to get started is:

A more flexible (but marked as experimental, and quite likely soon changing) approach is to implement a user “login”, to gather a token on demand. Note: This isn’t quite as simple as it first appears, it is two step not one. ( When we log in to D4H first with an account it is second our membership in an organization/team that we then use for most API calls, and some accounts are members of multiple teams. ) The authentication API grants an account token, and to call the main APIs one needs to use the account token to acquire a membership token from that account token. (The generated token above – from the team website – is already a membership token.)

Once you have a working token you can access most of the team data; and update some.

  • Activities (past and future)
  • Duty records
  • Member records
  • Groups
  • Equipment (and more)
  • Tasks
  • … and more

What do you want your D4H data to do?

You might want to create a simple an app or webpage to allow your membership to submit maintenance reports your way, or you might want to display call statistics or some recent incident information (or available tasks) on a display in your building. The D4H API allows you to decide what is important to you, and enhance D4H towards that goal. (I’d love to hear your thoughts and ideas. Let me know.)

Powerful, but still ‘Work In Progress’, I hope…

Much as the D4H API is very powerful, the API is incomplete in a few key areas: incident updating, qualifications, tags, custom fields, and more.

Hopefully those will be coming because without them activities can be created, but not updated in any way (not adding a location, a tag, a description, nothing.) This limits any field-based tools for incidents.

No access to qualifications means we cannot create our own qualification reminder systems, and qualifications (we have many tens for every member) are a key challenge for our membership.

D4H Whiteboard

The D4H whiteboard is a great way to get information out to the members of your organization. Some might not check email, and maybe you don’t wish to “spam” by sending to all, but adding a whiteboard message gets to people who log in to D4H on a regular basis. (We used it recently to remind about our annual SCBA mask fit testing.)

Adding a message (marked important or not) is a great way to get to the top of the D4H dashboard:

When we don’t have more pressing postings to make, we’ve chosen to offer quiz questions on our whiteboard as a fun way to keep content fresh in mind, and keep our membership engaged. We (with we being Coal Creek Canyon Fire Rescue) provide response for structure fire, wildland fire, rescue (including automobile), medical (as a BLS agency), hazardous materials, and (as we learned in 2013) other incidents, such as floods. We also assist with search and rescue (having mountainous state parks in our district.) We have a lot to remember, and quizzes are a good way to keep things top of mind.

We used a spreadsheet to gather questions and a simple ruby script (run automatically daily against the D4H APIs) to post the questions and answers. The script takes the day of the year and combines that with the number of quiz questions to pick today’s quiz question and yesterday’s answer, and posts both.

 #
 #  A snippet of the script, to add a whiteboard entry...
 #
 wuri = URI('https://api.d4h.org/v2/team/whiteboard')
 areq = Net::HTTP::Post.new(wuri)
 areq['Authorization'] = 'Bearer ___________'
 
 areq.set_form_data({'text' => formatted_question, 'enddate' => question_days_ahead_formatted}, '&')
        
 ares = Net::HTTP.start(wuri.hostname, 
                   wuri.port, 
                   :use_ssl => true) {|http|
   http.request(areq)
 }

You can view the Whiteboard in D4H’s MyD4H mobile application. Additionally, here is how the Whiteboard looks in Response Utilities for D4H