# Real Time APIs

## Example Request For Real Time API

The full list of Realtime APIs are available at: <https://data.gov.sg/datasets?formats=API>

## PM 2.5

> \*\*\[<https://api-open.data.gov.sg/v2/real-time/api/pm25]\\(https://api-open.data.gov.sg/v2/real-time/api/pm25)\\*\\*\\>
> \
> \<br/>\
> \
> \- Updated hourly from NEA.\
> \- Readings are provided for each major region in Singapore\
> \
> \<br/>\
> \
> \- Filter for specific date or date-time by providing \`date\` in query parameter.\
> &#x20; \- use YYYY-MM-DD format to retrieve all of the readings for that day\
> &#x20; \- use YYYY-MM-DDTHH:mm:ss to retrieve the latest readings at that moment in time\
> &#x20; \- example: \`?date=2024-07-16\` or \`?date=2024-07-16T23:59:00\`\
> \
> \<br/>\
> \
> \- If \`date\` is not provided in query parameter, API will return the latest reading\
> \
> \<br/>\
> \
> \- The \`region\_metadata\` field in the response provides longitude/latitude information for the regions. You can use that to place the readings on a map.\
> \<br/>\
> \- Unit of measure for readings is \`µg/m3\`.

```json
{"openapi":"3.0.3","info":{"title":"Real-time API weather services","version":"1.0.11"},"tags":[{"name":"Air Quality","description":"Air quality data API."}],"servers":[{"url":"https://api-open.data.gov.sg/v2/real-time/api"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key"}}},"paths":{"/pm25":{"get":{"tags":["Air Quality"],"summary":"PM 2.5","description":"**[https://api-open.data.gov.sg/v2/real-time/api/pm25](https://api-open.data.gov.sg/v2/real-time/api/pm25)**\n\n<br/>\n\n- Updated hourly from NEA.\n- Readings are provided for each major region in Singapore\n\n<br/>\n\n- Filter for specific date or date-time by providing `date` in query parameter.\n  - use YYYY-MM-DD format to retrieve all of the readings for that day\n  - use YYYY-MM-DDTHH:mm:ss to retrieve the latest readings at that moment in time\n  - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`\n\n<br/>\n\n- If `date` is not provided in query parameter, API will return the latest reading\n\n<br/>\n\n- The `region_metadata` field in the response provides longitude/latitude information for the regions. You can use that to place the readings on a map.\n<br/>\n- Unit of measure for readings is `µg/m3`.","parameters":[{"in":"query","name":"date","description":"SGT date for which to retrieve data (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS)","schema":{"type":"string"}},{"in":"query","name":"paginationToken","description":"Pagination token for retrieving subsequent data pages (only exists when there is a next page available for requests with date filters)","schema":{"type":"string"}}],"responses":{"200":{"description":"PM 2.5 Information","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer","description":"Response status code (always 0 for success)"},"errorMsg":{"type":"string","description":"Error message (empty string for success)"},"data":{"type":"object","properties":{"regionMetadata":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","description":"Region name"},"labelLocation":{"type":"object","properties":{"latitude":{"type":"number","description":"Latitude coordinate of the region label"},"longitude":{"type":"number","description":"Longitude coordinate of the region label"}}}}}},"items":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string","description":"SGT date of the reading (YYYY-MM-DD format)"},"updatedTimestamp":{"type":"string","description":"SGT timestamp of last updated"},"timestamp":{"type":"string","description":"SGT timestamp of the reading"},"readings":{"type":"object","description":"Overall and regional PSI data including pollutant concentrations and sub-indices","properties":{"pm25_one_hourly":{"type":"object","properties":{"national":{"type":"integer","description":"Reading for national reporting stations"},"east":{"type":"integer","description":"Reading for east region"},"west":{"type":"integer","description":"Reading for west region"},"north":{"type":"integer","description":"Reading for north region"},"south":{"type":"integer","description":"Reading for south region"},"central":{"type":"integer","description":"Reading for central region"}}}}}}}},"paginationToken":{"type":"string","description":"Token to retrieve next page if exists"}}}}}}}},"400":{"description":"Invalid HTTP request body","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"number"},"name":{"type":"string"},"data":{"type":"object"},"errorMsg":{"type":"string","enum":["Invalid date format. Date format must be YYYY-MM-DD (2024-06-01) or YYYY-MM-DDTHH:mm:ss (2024-06-01T08:30:00).","Invalid pagination token."]}}}}}},"404":{"description":"Weather data not found","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"number"},"name":{"type":"string"},"data":{"type":"object"},"errorMsg":{"type":"string"}}}}}}}}}}}
```
