OCHA Integration - Research Summary
This is a detailed summary of initial research on how to integrate the systems. See child pages for documentation of actual implementation.
OCHA API's information
Documentation
Detailed documentation is available here: api.hpc.tools/docs/v1/
This documentation is intended for users of the HPC Service public API, which provides data in JSON or XML formats.
For the API v2 endpoints (currently only data for Chad 2018 is available).
Old OPS API does not provide any documentation.
Authorization
Access to API is public, however there is limit to 1 request per second. Logged users does not have this limitation. API is using HTTP Basic Authentication.
External ID
Synced models should be updated with additional fields, to document their origin. This is achieved using a dedicated base model class.
Column
Type
external_id
integer
external_source
choice - HPC or OPS
Exception should be made for some simple tables (such as Country, etc.)
All further mappings includes those fields by default.
Response Plan API
List of available Response Plans
Endpoint get a list of current Response Plans in given country:
https://api.hpc.tools/v1/public/plan/country/<COUNTRY_ISO>
Example: https://api.hpc.tools/v1/public/plan/country/UKR
Field mapping
PRP Response Plan
HPC Plan
title
name
workspace
emergencies[0] if present else use locations[0]
start
startDate
end
endDate
plan_type
categories -> name
Sample JSON outputs
OCHA provided sample JSON outputs for some plans:
https://www.dropbox.com/sh/ogk4lrg4qyieyj7/AADlWxjBLyZHF5aszeCUrlwpa?dl=0
Response Plan Details
To get details of response plan, another endpoint is required:
https://api.hpc.tools/v1/public/rpm/plan/id/<plan_id>
Example: https://api.hpc.tools/v1/public/rpm/plan/id/514
Same endpoints returns different values depends on content parameter:
content: required (one of basic, entities, measurements)Specify the detail level for the content of the API response:
basic : only basic content for a plan.
entities : plan structure with entities and attachments.
measurements : plan structure with monitoringPeriods, entities, attachments and measurements.
In summary - to get plan structure with monitoringPeriods, entities, attachments and measurements, endpoint looks like: https://api.hpc.tools/v1/public/rpm/plan/id/514?format=json&content=measurements
Within the API output, there is a parentID
within the Clusters Objectives or Cluster Activities linking them back to the Cluster (the parent).
If the Cluster Objectives or Activities support a particular Strategic or Cluster Objective then the parameter to look for is the value.support
.
Clusters
There is a global cluster list, but then plans/responses can have their own cluster names sometimes as well.
However same Cluster name contains different ID's for different plans, example:
https://api.hpc.tools/v1/public/rpm/plan/id/641?format=json&content=entities
https://api.hpc.tools/v1/public/rpm/plan/id/475?format=json&content=entities
Endpoint for access global Clusters list:
https://api.hpc.tools/v1/public/global-cluster
Field mapping
https://api.hpc.tools/v1/public/rpm/plan/id/{id}?content=entities
PRP Cluster model fields
RPM Plan API fields
type
governingEntities -> name
(1)
response_plan
id
(1) where value->name->en->singular is Cluster
Cluster activity
To retrieve cluster activities it has to be used content=entities parameter:
https://api.hpc.tools/v1/public/rpm/plan/id/<plan_id>?content=entities
Field mapping
PRP Cluster Activity model fields
RPM Plan API fields
title
planEntities -> value -> description
(1)
cluster_objective
support
(2)
locations
attachments
(3)
reportables
attachments
(4)
(1) where planEntities -> value -> name -> en -> singular = "Cluster Activity"
(2) There's either relation to Strategic Objective (SO) or Cluster Objective (CO) (In PRP both will be treated as Cluster Objective), activity can link to multiple objectives - due to schema limitations only the first objective can be currently linked
(3) iterate over all Indicators in: attachments -> value -> metrics -> values -> disaggregated -> locations
and "type": "indicator"
(4) indicators are stored in attachments with "type": "indicator"
Cluster objectives
To retrieve cluster objectives it has to be used content=entities parameter:
https://api.hpc.tools/v1/public/rpm/plan/id/<plan_id>?content=entities
In some case the 3 layer structure of strategic objectives > cluster objectives > cluster activities
is not always followed. Cluster activity can link to strategic objective. Strategic objectives are multi-cluster.
Field mapping
PRP Cluster Objective model fields
RPM Plan API fields
title
planEntities -> value -> description
(1)
cluster
parent -> parentId
(2)
locations
attachments
(3)
reportables
attachments
(4)
(1) where planEntities -> value -> name -> en -> singular = "Cluster Objective"
(2) parentId
points to Cluster ID - might be empty, need to resolve in PRP
(3) iterate over all Indicators in: attachments -> value -> metrics -> values -> disaggregated -> locations
and "type": "indicator"
(4) indicators are stored in attachments with "type": "indicator"
Indicators and Disaggregation data
To retrieve disaggregation data it has to be used content=measurements parameter:
https://api.hpc.tools/v1/public/rpm/plan/id/<plan_id>?content=measurements
Field mapping
PRP Reportable model fields
RPM Plan API fields