Reputation: 41
I am trying to use data.gov.in api in order to get the air traffic data for my area.
I am using this.
I want to know how to apply the filter and get specified city data (e.g. Noida).
Upvotes: 2
Views: 2076
Reputation: 11
If you haven't found solution yet then check below.
@techkrg is right but you just need to make minor change in that, filters must have correct field names.
e.g. filters[statename]=Gujarat&filters[districtname]=Banaskanth
Upvotes: 0
Reputation: 164
Came across this package in Python that handles data.gov.in resources perfectly - datagovindia
You can install it with pip :
pip install datagovindia
Here's a solution to your problem. (You can also query for meta-data, and other information on valid fields/ filters, etc.)
Docs are available here.
from datagovindia import DataGovIndia
YOUR_API_KEY = "579b464db66ec23bdd000001cdd3946e44ce4aad7209ff7b23ac571b"
datagovin = DataGovIndia(YOUR_API_KEY)
# Returns:
# This API key is VALID. You won't need to set it again.
# Latest API-references loaded! You may begin.
datagovin.search_by_title("Air",max_results=2)
Showing 2 of 1022 results for : `Air`
==================================================================================
Resource-ID: 3b01bcb80b144abfb6f2c1bfd384ba69
Real time Air Quality Index from various location
==================================================================================
Resource-ID: 04ef91fa63844f74b9cc5beb84f53da2
Number of Beneficiaries under Different Schemes of National Scheduled Tribes Finance and Development Corporation from 2016-17 to 2018-19 (From: Ministry of Tribal Affairs)
==================================================================================
[{"3b01bcb80b144abfb6f2c1bfd384ba69": "Real time Air Quality Index from various location"},
{"04ef91fa63844f74b9cc5beb84f53da2": "Number of Beneficiaries under Different Schemes of National Scheduled Tribes Finance and Development Corporation from 2016-17 to 2018-19 (From: Ministry of Tribal Affairs)"}
]
data = datagovin.get_data("3b01bcb80b144abfb6f2c1bfd384ba69",
num_results='all',
filters={'city':"Noida"})
data.head()
id | country | state | city | station | last_update | pollutant_id | pollutant_min | pollutant_max | pollutant_avg | pollutant_unit | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1514 | India | Uttar_Pradesh | Noida | Sector - 125, Noida - UPPCB | 16-04-2021 12:00:00 | PM2.5 | 62 | 327 | 179 | NA |
1 | 1515 | India | Uttar_Pradesh | Noida | Sector - 125, Noida - UPPCB | 16-04-2021 12:00:00 | PM10 | 190 | 431 | 288 | NA |
2 | 1516 | India | Uttar_Pradesh | Noida | Sector - 125, Noida - UPPCB | 16-04-2021 12:00:00 | NO2 | 4 | 92 | 14 | NA |
3 | 1517 | India | Uttar_Pradesh | Noida | Sector - 125, Noida - UPPCB | 16-04-2021 12:00:00 | SO2 | 2 | 8 | 5 | NA |
4 | 1518 | India | Uttar_Pradesh | Noida | Sector - 125, Noida - UPPCB | 16-04-2021 12:00:00 | OZONE | 93 | 241 | 131 | NA |
Upvotes: 1
Reputation: 219
I have used filters in different API like below to pass in querystring, &filters[state]=Gujarat&filters[district]=Banaskanth
It works perfectly.
Upvotes: 17