Malaysia Air Pollution Index avatar

Malaysia Air Pollution Index

Under maintenance
Try for free

Pay $2.00 for 1,000 results

Go to Store
This Actor is under maintenance.

This Actor may be unreliable while under maintenance. Would you like to try a similar Actor instead?

See alternative Actors
Malaysia Air Pollution Index

Malaysia Air Pollution Index

jackhax1/malaysia-air-pollution-index
Try for free

Pay $2.00 for 1,000 results

Scrape Air Pollution Index data from eqms.doe.gov.my

README for Apify Actor: Environmental Query Module

Overview

This Apify Actor is designed to interact with the Environmental Quality Monitoring Program (EQMP) API provided by the Malaysian Department of Environment. It fetches data such as state lists, station lists, and specific air quality readings. The module is built with Python, leveraging the Apify SDK and HTTPX for asynchronous HTTP requests.


Features

  1. Fetch State List: Retrieves a list of states from the EQMP API and processes the data to include only necessary fields.
  2. Fetch Station List: Fetches station data for a given state, filtering and structuring it appropriately.
  3. Fetch Air Quality Data: Queries specific air quality data for a given state, station, and timestamp.

Actor Input

The Actor supports three types of queries:

1. State List Query

Retrieves a list of states.

Input:

1{
2  "query": "statelist"
3}

2. Station List Query

Fetches a list of stations for a specified state.

Input:

1{
2  "query": "stationlist",
3  "stateid": "1"
4}
  • stateid (optional): The ID of the state. Defaults to "1".

3. Air Quality Data Query

Queries air quality data for a specified state, station, and timestamp.

Input:

1{
2  "query": "query",
3  "stateid": "1",
4  "stationid": "CA29J",
5  "datetime": 1708981200
6}
  • stateid (optional): The ID of the state. Defaults to "1".
  • stationid (optional): The ID of the station. Defaults to "CA29J".
  • datetime (optional): UNIX timestamp. Defaults to the current time.

Actor Output

The Actor returns JSON data in the following format:

  1. State List Query:
1{
2  "type": "statelist",
3  "data": [
4    {
5      "STATE_ID": "1",
6      "STATE_NAME": "Johor"
7    },
8    ...
9  ]
10}
  1. Station List Query:
1{
2  "type": "stationlist",
3  "data": [
4    {
5      "STATION_ID": "CA29J"
6    },
7    ...
8  ]
9}
  1. Air Quality Data Query:
1{
2  "type": "api_table_hourly",
3  "data": [
4    {
5      "STATION_ID": "CA29J",
6      "API": "40",
7      "PARAM_SYMBOL": "*"
8    },
9    ...
10  ]
11}

Implementation Details

Functions

  1. get_statelist()

    • Fetches state list data and removes unnecessary fields.
  2. get_stationlist(stateid: str)

    • Fetches station list for a specific state.
    • Query Parameter: stateid
  3. get_query(stateid: str, stationid: str, date_time: str)

    • Fetches air quality data for a specific state, station, and time.
    • Query Parameters: stateid, stationid, datetime

Workflow

  1. The Actor initializes and reads the input.
  2. Depending on the query type, it calls one of the three functions:
    • get_statelist
    • get_stationlist
    • get_query
  3. The response data is processed, structured, and pushed to the Apify dataset.

Requirements

  • Python 3.7+
  • Apify SDK
  • HTTPX

How to Run Locally

  1. Clone the repository.
    apify pull <actor_id>
  2. Install dependencies:
    pip install -r requirements.txt
  3. Run the script:
    apify run

API References

Notes

  • Use verify=False in AsyncClient for bypassing SSL verification. Avoid this in production.
  • Ensure timestamps are in UNIX format for the datetime parameter.
  • Customize and optimize as per your specific use case.

License

This project is licensed under the MIT License. Feel free to modify and use it as per your needs.

Developer
Maintained by Community

Actor Metrics

  • 1 monthly user

  • 0 No stars yet

  • Created in Dec 2024

  • Modified 3 days ago