API
1. Subscription Data
Start by checking from which Content Producers you have access to retrieve risk assessment data. This is done via the subscriptions API.
[GET] – Subscriptions
http://api.safeture.com/contentproducer/subscriptions
Response example:
"data": [ {
"contentproducerid": "SAFETURE",
"contenttypeid": "RISK_ASSESSMENT",
"allowcontentoverride": false,
"rebrandable": true
} ]
Copy
For now, ‘allowcontentoverride’ and ‘rebrandable’ can be ignored. But in the example above, we see that the risk assessment data comes from Safeture.
2. Risk Assessment Data from Content Producer
The next step is to get Safeture’s (or which risk assessment content producer you have access to) risk levels and risk categories. To do that we use:
[GET] – Risk levels
http://api.safeture.com/riskassessment/{contentproducerid}/risklevels
Response example:
"data": [
{
"contentproducerid": "SAFETURE",
"riskleveluuid": "0607d9a0-d7ef-11eb-bda3-43553f393972",
"risklevelid": "NEGLIGIBLE",
"risklevelvalue": 1,
"risklevelname": "Negligible",
"risklevelcolor": "#8CC740"
},
{
"contentproducerid": "SAFETURE",
"riskleveluuid": "0607ed3c-d7ef-11eb-bda3-2fbb431431f2",
"risklevelid": "LOW",
"risklevelvalue": 2,
"risklevelname": "Low",
"risklevelcolor": "#D2E038"
}
]
Copy
[GET] – Risk categories
http://api.safeture.com/riskassessment/{contentproducerid}/riskcategories
Response example:
"data": [
{
"contentproducerid": "SAFETURE",
"riskcategoryuuid": "060833dc-d7ef-11eb-bda3-cb4da9f8902b",
"riskcategoryid": "CIVIL UNREST",
"riskcategoryname": "Civil Unrest",
"description": "",
"icon": "data:image/png;base64,iVBORw0KSUhEU…..",
"weight": 1
},
{
"contentproducerid": "SAFETURE",
"riskcategoryuuid": "06081618-d7ef-11eb-bda3-6f44ef9e558f",
"riskcategoryid": "CRIME",
"riskcategoryname": "Crime",
"description": "",
"icon": "data:image/png;base64,iVBORw0KSUhEU…",
"weight": 1
}
]
Copy
3. Region Risk Assessment Data
The next step is to get the country risk assessment.
Here you can choose between two options:
(Viable for most API users) Read data from your predefined content producer for risk information that is set up in the platform. (If you have multiple subscriptions from different content producers that provides risk assessment and want to get the risk assessment data for your official provider). Then use the API call below.
[GET]
http://api.safeture.com/regionriskassessment/region/{regionid}
If you subscribe to multiple risk providers use below api call to get specific data from subscribed content producer:
[GET]
http://api.safeture.com/regionriskassessment/{contentproducerid}/region/{regionid}
Response example:
"data": {
"producername": "Safeture",
"contentproducerid": "SAFETURE",
"regionid": "Sweden",
"regionname": "Sweden",
"iso3166_1": "SE",
"description": "",
"trend": 0,
"trendprojection": 0,
"riskleveluuid": "0607ed3c-d7ef-11eb-bda3-2fbb431431f2",
"risk_assessment": [
{
"riskcategoryuuid": "060833dc-d7ef-11eb-bda3-cb4da9f8902b",
"riskleveluuid": "0607ed3c-d7ef-11eb-bda3-2fbb431431f2",
"riskassessmentbasic": "<p>Sweden experiences p>",
"trend": 0,
"trendprojection": 0
},
{
"riskcategoryuuid": "06081618-d7ef-11eb-bda3-6f44ef9e558f",
"riskleveluuid": "0607d9a0-d7ef-11eb-bda3-43553f393972",
"riskassessmentbasic": "<p>Major tourist attractions, urban centres</p>",
"trend": 0,
"trendprojection": 0
],
"trendinfo": {
"showtrend": 0,
"showtrendprojection": 0,
"trenddescription": "The general direction or trend in which.",
"trendprojectiondescription": "The projected trend is a prediction of future."
}
}
Copy
Both API calls will return the same data structure. The only difference is the data it contains.
4. Read Compiled Region Card
The country risk assessment data is also present in the read compiled region card. In the response call under the param “tree”
[GET]
http://api.safeture.com/regioncard/getcompiled?language={language}®ionid={regionid}
Response example:
{
"regioncard": {
"region": {
...
},
"providers": [
...
],
"tree": [
...
],
"viewid": "…",
"structure": [
...
]
}
}
Copy
In the object with the heading id “safetureSafety”, the parameter’s children will contain the new risk assessment object with a heading id “safetyAndSecurity-Risk Assessment”. Inside the data parameter, the same risk assessment structure as mentioned under the section above country risk assessment data will be found.
Note that your risk assessment data might be structured under a different heading id than safetureSafety, but the general structure will be the same.
An example of what it can look like is shown below:
"regioncard": {
"region": {
...
},
"providers": [
...
],
"tree": [
{
"headingid": "safetureSafety",
"payloadtype": "text/html",
"vieworder": 2,
"title": "Safety",
"children": [
{
"headingid": "safetyAndSecurity-Risk Assessment",
"payloadtype": "application/json,gws/risk-assesments",
"vieworder": 1,
"title": "Risk Assessment",
"data": [
{
"producername": "Safeture",
"contentproduceruuid": "060789aa-d7ef-11eb-bda3-3b48e708c2e5",
"regionid": "Sweden",
"regionname": "Sweden",
"iso3166_1": "SE",
"description": "",
"trend": 0,
"trendprojection": 0,
"riskleveluuid": "0607ed3c-d7ef-11eb-bda3-2fbb431431f2",
"risk_assessment": [
...
],
"trendinfo": {
"showtrend": 0,
"showtrendprojection": 0,
"trenddescription": "",
"trendprojectiondescription": ""
}
}
]
},
{
"headingid": "safetyAndSecurity-Threat Assessment",
"payloadtype": "application/json,gws/threat-assesments",
"vieworder": 1,
"title": "Threat Assessment",
"data": [
...
]
},
{
...
}
]
},
{
"headingid": "safetureAlerts",
"payloadtype": "application/json,gws/events",
"vieworder": 3,
"title": "Alerts",
"data": [
...
]
}
],
"structure": [
...
]
}
}
Copy
5. Mapping the UUIDs
Now that we have the needed data, it is time to map it correctly. The data we got from risk level and risk categories API will be added to the risk assessment object. The reason for doing so is not to have to send the same data repeatedly. Instead, we append the risk level data and risk category data to the region risk assessment object.
Use X uuid & Y uuid respectively for matching risk level and risk category as explained below:
Firstly, get all the content producer’s risk levels and categories. We already have them saved and cached.
Check that you have all the data to start the mapping.
Make a dictionary of the risk levels with UUID and the same with risk categories for a quicker look-up.
Add the risk level data to the region risk assessment with the risk level UUID.
Note that this is built dynamically, meaning that the risk level or risk categories can potentially be removed by the content producer at any time. Therefore, a check if data mapping is possible is needed every time.
Check that the region has risk assessments added to it. Your content producer might have made risk assessments for subregions within a country or the country as a whole.
Loop the risk assessment array with a filter so we will not return it to the final array if we can’t map the data. Because Showing UUID is not readable for the user.
Override the new, mapped risk assessment.
Finally, return the regionriskassessemnt object with the mapped data.