我在不同的 API 中使用了过滤器,如下所示,以传递查询字符串, &filters[state]=Gujarat&filters[district]=Banaskanth它工作得很好。示例: https: //api.data.gov.in/resource/9ef84268-d588-465a-a308-a864a43d0070 ?api-key=579b464db66ec23bXXXXXXXXXXXXXXXXX40c1435e88575ea73c1b&format=json&state=Gujarat&offset=0&limit=20=&Gujafilters&strict]
在 Python 中遇到了这个包,它可以完美地处理 data.gov.in 资源 - datagovindia您可以使用 pip 安装它:pip install datagovindia这是您的问题的解决方案。(您还可以查询元数据,以及有关有效字段/过滤器等的其他信息)文档可在此处获得。进口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: 3b01bcb80b144abfb6f2c1bfd384ba69Real time Air Quality Index from various location==================================================================================Resource-ID: 04ef91fa63844f74b9cc5beb84f53da2Number 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国家状态城市车站最后更新污染物编号污染物_min最大污染物污染物_avg污染物单位01514印度北方邦诺伊达部门 - 125,诺伊达 - UPPCB16-04-2021 12:00:00PM2.562327179那11515印度北方邦诺伊达部门 - 125,诺伊达 - UPPCB16-04-2021 12:00:00PM10190431288那21516印度北方邦诺伊达部门 - 125,诺伊达 - UPPCB16-04-2021 12:00:00二氧化氮49214那31517印度北方邦诺伊达部门 - 125,诺伊达 - UPPCB16-04-2021 12:00:00二氧化硫285那41518印度北方邦诺伊达部门 - 125,诺伊达 - UPPCB16-04-2021 12:00:00臭氧93241131那