datagovsg / datagovsg-datasets

A repository to track dataset request, issues and suggestions.
88 stars 25 forks source link

API for Realtime Weather Readings across Singapore appears to be broken #1535

Open mariofrei opened 1 year ago

mariofrei commented 1 year ago

Describe the bug When requesting air temperatures for dates after Jan 1, 2023, the API returns no temperature information but maintains health status as 'healthy'. The main issue is that no real-time temperature readings are accessible. The secondary issue is that the health status appears to be inaccurate.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'https://data.gov.sg/dataset/realtime-weather-readings'
  2. Click on 'Try it out'
  3. Enter date, e.g., "2023-01-04" for Jan 4, 2023
  4. Click 'Execute'
  5. Review the returned data or lack thereof:
    "api_info": {
    "status": "healthy"
    },
    "metadata": {
    "stations": [
      {
        "id": "string",
        "device_id": "string",
        "name": "string",
        "location": {
          "longitude": 0,
          "latitude": 0
        }
      }
    ],
    "reading_type": "string",
    "reading_unit": "string"
    },
    "items": [
    {
      "timestamp": "2023-01-04T04:11:33.695Z",
      "readings": [
        {
          "station_id": "string",
          "value": 0
        }
      ]
    }
    ]
    }

Expected behavior The API still appears to be working for dates until and including Jan 1, 2023:

  1. Go to 'https://data.gov.sg/dataset/realtime-weather-readings'
  2. Click on 'Try it out'
  3. Enter date, e.g., "2023-01-01" for Jan 1, 2023
  4. Click 'Execute'
  5. Review the returned data:
    {
    "metadata": {
    "stations": [
      {
        "id": "S109",
        "device_id": "S109",
        "name": "Ang Mo Kio Avenue 5",
        "location": {
          "latitude": 1.3764,
          "longitude": 103.8492
        }
      },
      {
        "id": "S50",
        "device_id": "S50",
        "name": "Clementi Road",
        "location": {
          "latitude": 1.3337,
          "longitude": 103.7768
        }
      },
      {
        "id": "S107",
        "device_id": "S107",
        "name": "East Coast Parkway",
        "location": {
          "latitude": 1.3135,
          "longitude": 103.9625
        }
      },
      {
        "id": "S43",
        "device_id": "S43",
        "name": "Kim Chuan Road",
        "location": {
          "latitude": 1.3399,
          "longitude": 103.8878
        }
      },
      {
        "id": "S108",
        "device_id": "S108",
        "name": "Marina Gardens Drive",
        "location": {
          "latitude": 1.2799,
          "longitude": 103.8703
        }
      },
      {
        "id": "S44",
        "device_id": "S44",
        "name": "Nanyang Avenue",
        "location": {
          "latitude": 1.34583,
          "longitude": 103.68166
        }
      },
      {
        "id": "S121",
        "device_id": "S121",
        "name": "Old Choa Chu Kang Road",
        "location": {
          "latitude": 1.37288,
          "longitude": 103.72244
        }
      },
      {
        "id": "S106",
        "device_id": "S106",
        "name": "Pulau Ubin",
        "location": {
          "latitude": 1.4168,
          "longitude": 103.9673
        }
      },
      {
        "id": "S111",
        "device_id": "S111",
        "name": "Scotts Road",
        "location": {
          "latitude": 1.31055,
          "longitude": 103.8365
        }
      },
      {
        "id": "S102",
        "device_id": "S102",
        "name": "Semakau Landfill",
        "location": {
          "latitude": 1.189,
          "longitude": 103.768
        }
      }, ...

    Desktop (please complete the following information):

    • OS: Windows
    • Browser Chrome
    • Version 108.0.5359.125

Additional context While this issue described above is for the example on the website, the same issue persists if the API is called using Python and the Python module 'Requests'

kucinta commented 1 year ago

looks like all weather is affected. No data since 2023-01-02. please look into this.

zmlee-sg commented 1 year ago

weather forecasts are also affected. coincidentally, webapp data flow seems to be intact

liangleslie commented 1 year ago

Data.gov APIs are too unreliable. It goes down for weeks a few times a year.

Scraping from NEA or weather.sg website is much more reliable, sadly.

kucinta commented 1 year ago

looks like it is finally up after 10 days! however, https://api.data.gov.sg/v1/environment/relative-humidity is still not available.

kucinta commented 1 year ago

hum... PM25 also not working! https://api.data.gov.sg/v1/environment/pm25 as it also does not return any item.

Kayden-lolasery commented 1 year ago

I dont think anyone maintains this repo

liangleslie commented 1 year ago

For anyone working in python, I've decided to write a scraper/wrapper that uses data from nea.gov.sg and weather.gov.sg to simulate the json responses of the various weather endpoints, so that it is somewhat easy to replace any existing code that depends on the data.gov.sg weather APIs.

https://github.com/liangleslie/weathersg

Caveat: nea.gov.sg and weather.gov.sg are probably not intended to be queried like this, so I can't speak for the reliability, or what the server rate limits are. so please bear this in mind for whatever use case you might have

Usage

Weather().api.json --> simulated json output in the same format as data.gov.sg. Dict keys map to endpoint pathinfo, i.e. simulated json output of https://api.data.gov.sg/v1/environment/24-hour-weather-forecast can be returned with weathersg.Weather().api.json['24-hour-weather-forecast']

Example

from weathersg import Weather

weather = Weather()
simulated_resp = weather.api.json['24-hour-weather-forecast']