Malaysia Air Pollution Index
Pay $2.00 for 1,000 results
This Actor may be unreliable while under maintenance. Would you like to try a similar Actor instead?
See alternative ActorsMalaysia Air Pollution Index
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
- Fetch State List: Retrieves a list of states from the EQMP API and processes the data to include only necessary fields.
- Fetch Station List: Fetches station data for a given state, filtering and structuring it appropriately.
- 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:
- State List Query:
1{ 2 "type": "statelist", 3 "data": [ 4 { 5 "STATE_ID": "1", 6 "STATE_NAME": "Johor" 7 }, 8 ... 9 ] 10}
- Station List Query:
1{ 2 "type": "stationlist", 3 "data": [ 4 { 5 "STATION_ID": "CA29J" 6 }, 7 ... 8 ] 9}
- 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
-
get_statelist()
- Fetches state list data and removes unnecessary fields.
-
get_stationlist(stateid: str)
- Fetches station list for a specific state.
- Query Parameter:
stateid
-
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
- The Actor initializes and reads the input.
- Depending on the
query
type, it calls one of the three functions:get_statelist
get_stationlist
get_query
- The response data is processed, structured, and pushed to the Apify dataset.
Requirements
- Python 3.7+
- Apify SDK
- HTTPX
How to Run Locally
- Clone the repository.
apify pull <actor_id>
- Install dependencies:
pip install -r requirements.txt
- Run the script:
apify run
API References
Notes
- Use
verify=False
inAsyncClient
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.
Actor Metrics
1 monthly user
-
0 No stars yet
Created in Dec 2024
Modified 3 days ago