Search code examples
socratasoda

Chicago Data Portal API format for filter with multiple conditions


Probably very easy, however I cant find the answer in the documentation.

I have the following API url which I like to extend with additional filter condition for the "location_description". It currently filters on "residence":

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

However, I like to extend this to include "APARTMENT,RESIDENCE-GARAGE".

So When I try this format:

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

It will not work.

Tried different formats including "", () etc, but no luck.

Question: How do I format this URL correctly so that I can filter on multiple "location_description"?

Thanks for the assistance.


Solution

  • For this, it might be a bit easier to use the where statement since it'll resemble a SQL query and may be more familiar (and easier to look at general query documentation). For now, I've removed the $$app_token to simplify the 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')