Skip to content

Data API

Khor Philemon edited this page Aug 31, 2020 · 5 revisions

Get all data (COVID-19)

Gets the total active COVID-19 cases of each state and district in Malaysia.

GET https://knowyourzone.xyz/api/data/covid19/latest

Rate limit

100 requests per 15-minute window.

See the rate limit documentation for details on determining your current rate limit status.

Parameters

This endpoint doesn't have any parameters yet. (Will support query parameters in future releases)

Example Request

curl -i -X GET https://knowyourzone.xyz/api/data/covid19/latest

Example Response

If successful, this endpoint returns a 200 with a response body that follows the schema below. See here for a complete response example.

{
  "states": [
    {
      "name": "Sarawak",
      "total": 12,
      "districts": [
        {
          "name": "District with most active cases in Sarawak",
          "total": 8
        },
        {
          "name": "District with second most active cases",
          "total": 4
        },
        ...
      ]
    },
    {
      "name": "Kuala Lumpur",
      "total": 4,
      "districts": [
        {
          "name": "District with most active cases in Kuala Lumpur",
          "total": 4
        },
        {
          "name": "This district has no active cases",
          "total": 0
        },
        ...
      ]
    },
    ...
  ],
  "last_updated": 1594785600
}

If no data is available at the moment, a 404 will be returned with the following response body:

{
  "message": "Data currently unavailable"
}

Response Fields

Field Type Description
states array A list of state objects. A normal response will have 16 state objects (13 states + 3 federal territories) in its states field. In the event of missing data, a response may have fewer state objects.
last_updated timestamp The time at which the data is updated in UTC epoch seconds.

Data Objects

State

A state object encapsulates the data of a state. It contains the following 3 fields:

Field Type Description
name string The name of the state or federal territory.
total integer The number of total active COVID-19 cases in the corresponding state. It is the sum of active cases in all districts, excluding import cases.
districts array A list of district objects that describes the districts within the corresponding state.

District

A district object encapulates the data of a district that belongs to the parent state object. It contains the following 2 fields:

Field Type Description
name string The name of the district.
total integer The number of total active COVID-19 cases in the corresponding district.
Clone this wiki locally