Skip to content

Latest commit

 

History

History
221 lines (179 loc) · 5.14 KB

Safe-Places-Server.md

File metadata and controls

221 lines (179 loc) · 5.14 KB

Safe Places Server

Safe Places can be hosted by a server which implements five basic endpoints. The Redaction Tool and the Publisher support being served by such a server. They can be simply modified by changing the value of has_backend within the Javascript, then serving them to a browser. These webapps will automatically operate with the backend which implements this API.

Anyone who implements this API this is should be aware of healthcare-authorities.yaml. The output of the safe-paths.json endpoint outputs exactly the format expected by a Safe Places client and can be added to that Healthcare Authority registry.

API Endpoints

Login

This is the beginning of a user interaction with the tool page. They must be authenticated, but the authentication will be saved using a cookie for future sessions.

Credentials will be controlled and issued by the server implementor.

URL: /login
METHOD: POST
PAYLOAD: JSON
{
    "username": "<username>",
    "password": "<password>"
}
RESPONSE: JSON
{
    "token": "<session_token>",
    "maps_api_key": "<maps_api_key>"
}

The maps_api_key is a Google Maps Javascript API key.

Save Redacted

After a session of redaction, the results are saved to a database/table.

URL: /redacted_trail/
METHOD: POST
PAYLOAD: JSON
{
    "identifier":<some random identifier created by user>,
    "trail":[
        { "time": 456, "latitude": 12.34, "longitude": 12.34}
    ]
}
RESPONSE: JSON
{
  "data": {
    "identifier": "<identifier>",
    "organization_id": "<organization_id>",
    "trail": {
      "latitude": 12.34,
      "longitude": 12.34,
      "time": 123456789
    },
    "user_id": "<user_id>"
  },
  "success": true
}

Load All Redacted

Used by the publisher tool, all redaction data is loaded.

URL: /redacted_trails/
METHOD: GET
PAYLOAD: empty
RESPONSE: JSON
{
  "data": [
    {
      "identifier": <identifier>,
      "organization_id": <organization_id>,
      "trail": {
        "latitude": 12.34,
        "longitude": 12.34,
        "time": 123456789
      },
      "user_id": <user_id>
    },
    {
      "identifier": <identifier>,
      "organization_id": <organization_id>,
      "trail": {
        "latitude": 12.34,
        "longitude": 12.34,
        "time": 123456789
      },
      "user_id": <user_id>
    }
  ]
}

Publish

Used by the Publisher tool, all points are published along with extra information.

URL: /safe_paths/
METHOD: POST
PAYLOAD: JSON
{ "authority_name":  "Steve's Fake Testing Organization",
  "publish_date_utc": "1584924583",
  "info_website": "https://www.who.int/emergencies/diseases/novel-coronavirus-2019",
  "concern_points":
   [
     { "time": 123, "latitude": 12.34, "longitude": 12.34},
     { "time": 456, "latitude": 12.34, "longitude": 12.34}
   ]
}
RESPONSE: JSON
{
  "datetime_created": "Fri, 27 Mar 2020 04:32:12 GMT",
  "organization_id": <organization_id>,
  "safe_path": {
    "authority_name": "Fake Organization",
    "concern_points": [
      {
        "latitude": 12.34,
        "longitude": 12.34,
        "time": 123
      },
      {
        "latitude": 12.34,
        "longitude": 12.34,
        "time": 456
      }
    ],
    "info_website": "https://www.something.gov/path/to/info/website",
    "publish_date_utc": 1584924583
  },
  "user_id": <user_id>
}

safe-paths.json

Consumed by the Safe Paths client application. This requires no authentication.

URL: /safe_path/<organization_id>/
METHOD: GET
PAYLOAD: empty
RESPONSE: JSON
{
    "authority_name": "Fake Organization",
    "concern_points": [
      {
        "latitude": 12.34,
        "longitude": 12.34,
        "time": 1584924233
      },
      {
        "latitude": 12.34,
        "longitude": 12.34,
        "time": 1584924583
      }
    ],
    "info_website": "https://www.something.gov/path/to/info/website",
    "publish_date_utc": "1584924583"
}