首页 > 解决方案 > 芝加哥数据门户 API 格式,用于具有多个条件的过滤器

问题描述

可能很容易,但是我在文档中找不到答案。

我有以下 API url,我想用“location_description”的附加过滤条件来扩展它。它目前过滤“住所”:

https://data.cityofchicago.org/resource/6zsd-86xi.json ?$$app_token=xxxxxxxxx&primary_type=BURGLARY&location_description=RESIDENCE

但是,我喜欢将其扩展为包括“公寓,住宅车库”。

所以当我尝试这种格式时:

https://data.cityofchicago.org/resource/6zsd-86xi.json ?$$app_token=xxxxxxxxx&primary_type=BURGLARY&location_description=RESIDENCE,APARTMENT,RESIDENCE-GARAGE

不起作用。

尝试了不同的格式,包括“”,()等,但没有运气。

问题:如何正确格式化此 URL,以便可以过滤多个“location_description”?

感谢您的帮助。

标签: socratasoda

解决方案


为此,使用该where语句可能会更容易一些,因为它类似于 SQL 查询并且可能更熟悉(并且更容易查看一般查询文档)。现在,我删除了$$app_token以简化 URL:

https://data.cityofchicago.org/resource/6zsd-86xi.json?$where=primary_type='BURGLARY' AND (location_description='RESIDENCE' OR location_description='APARTMENT' OR location_description='RESIDENCE-GARAGE')

推荐阅读