Accessing the API

From Active911 Documentation Wiki
Jump to: navigation, search

These are the API calls available once you have an OAuth Access Token for the Active911 Developer API

Data format

All responses from the API use the JSON data format. The general structure of a response is

{
 "result": (success|error),
 "message": (error message|returned object)
}

API Collections

Agency

https://access.active911.com/interface/open_api/api/

  • This is the root of the API tree.
  • This will display the agency the token is authorized to read.
{
 "agency" : {
  "id": (Agency id number),
  "name": (Name of the agency),
  "address": (Street address of the agency),
  "city": (City agency is located in),
  "state": (State agency is location in),
  "latitude": (Latitude of agency's location),
  "longitude": (Longitude of agency's location),
  "devices": 
  [
   "id": (Device id number),
   "uri": (API URI to access the device data)
  ]
 }
}

Devices

https://access.active911.com/interface/open_api/api/devices/{id}

  • This will show information for device #{id}
  • Requires read_device scope
{
 "device": {
  "id": (Device id number),
  "name": (Name of the device),
  "latitude": (Latitude of devices's most recent location),
  "longitude": (Longitude of devices's most recent location),
  "position_accuracy": (Accuracy of devices's most recent location),
  "position_timestamp": (Timestamp of devices's most recent location update),
  "agencies": 
  [
   "id": (Agency id number),
   "uri": (API URI to access the agency data)
  ]
 }
}

API Sub-collections

Alerts

https://access.active911.com/interface/open_api/api/alerts

https://access.active911.com/interface/open_api/api/devices/{id}/alerts

  • This will show all the alerts under the current agency or under the device specified.
  • Requires read_alert scope
  • GET params:
    • alert_days - How many days of alerts to show. Default 10. Max 30.
    • alert_minutes - How many minutes of alerts to show. Will supersede alert_days if set. Optional.
{
 "alerts": [{
       "id": (Active911 Alert id number), 
       "uri": (API URI to access the alert data)
     }]

}

https://access.active911.com/interface/open_api/api/alerts/{id}

  • This will show alert #{id}
  • Requires read_alert scope
{
 "alert": (See Alert below)
}

Alert

{
   "id": (Active911 Alert id number), 
   "agency": {
     "id": (Agency id number), 
     "uri": (API URI to access the agency data)
   }, 
   "place": (Common name for the place ie Joe's Tavern),
   "address": (Street address for the alert), 
   "unit": (Subunit ie Apt G), 
   "city": (City alert is located in), 
   "state": (State alert is located in), 
   "latitude": (Latitude of the alert), 
   "longitude": (Longitude of the alert), 
   "source": (Source of the alert ie Battalion Chief 10), 
   "units": (Dispatched Units ie Truck1), 
   "cad_code": (Identifier Code given by CAD Software), 
   "priority": (Priority from CAD system), 
   "details": (Additional Notes), 
   "sent": (Time the alert was sent from our servers to Active911 devices), 
   "description": (Short description of the alert), 
   "pagegroups": [
     {
       "title": (Name of the pagegroup),
       "prefix": (Pagegroup prefix)
     }
   ], 
   "map_code": (Map Code for the alert), 
   "received": (Time the alert was received by our servers), 
   "cross_street": (Cross street of where the alert is located), 
   "responses": [
    {
      "device": {
       "id": (Device id of responder), 
       "uri": (API URI to access the device data)
      }, 
      "timestamp": (Timestamp of when the device responded with this response), 
      "response": (Name of the response action taken)
    }, 
   ]
}

Map Data

Locations

GET

https://access.active911.com/interface/open_api/api/locations

  • This will show all mapdata under agency {id}
  • Requires read_mapdata scope
  • GET params:
    • locations_page - What page to return. Default 1.
    • locations_per_page - How many locations per page to return. Default 10. Max 1000.
    • locations_coordinate_window - A set of decimal coordinates within which all locations will be returned. Optional.
      • Format: North,East,South,West
      • Example: 44.638368,-123.476136,44.621265,-123.502915
{
 "locations": [{
      "id": (Active911 Location id number), 
      "uri": (API URI to access the location data)
    }]
     
}
  • count_only - If set to 1, will return a count of the entire resultset instead of locations. Can be used with locations_coordinate_window.
{
 "locations": {
      "num_locations": (number of locations in the result set)
}

POST

https://access.active911.com/interface/open_api/api/locations

  • This will allow you to add a location to agency {id}
  • Requires write_mapdata scope
  • POST Body form-data (key/value pairs):
    • lat - Latitude
    • lon - Longitude
    • name - name/title
    • description - extended location description
    • location_type - should just be "building" for now
    • icon_color - same as the colors shown on the apps & the website, e.g. "blue|green|red|etc."
    • icon_id - same as the icons shown on the apps & the website, but using the IDs: e.g. "9|13|20|etc."

Example form data: ...

 --form lat=44.54102 \
 --form lon=-123.3438 \
 --form name=place_name \
 --form 'description=this is a place on a map' \
 --form location_type=building \
 --form icon_color=pink \
 --form icon_id=9

...

GET (by id)

https://access.active911.com/interface/open_api/api/locations/{id}

  • This will show location #{id}
  • Requires read_mapdata scope
{
 "location": {
       "id": (Active911 id for this map data point), 
       "name": (Name of this map data point), 
       "description": (Short description of this map data point), 
       "icon_id": (Active911 id of the icon used for this map data point),
       "icon_color": (Color of this map data point), 
       "latitude": (Latitude of this map data point), 
       "longitude": (Longitude of this map data point), 
       "location_type": (The type of map data point), 
       "resources": [
         "id": (Resource id of responder), 
         "uri": (API URI to access the resource data)
       ]
    }
}

Resources

https://access.active911.com/interface/open_api/api/resources/{id}

  • This will show resource #{id}
  • Requires read_mapdata scope
{
 "resource": {
     "id": (Active911 id for this resource), 
     "title": (Name of the title), 
     "filename": (Filename), 
     "extension": (File extension), 
     "size": (File size in bytes), 
     "details": (Details about the file), 
     "agency": {
      "id": (Agency id number),, 
      "uri": (API URI to access the agency data)
     }, 
     "location": {
      "id": (Location id number),
      "uri": (API URI to access the location data)
     }
 }
}