Manage Saved Queries

Create New Queries

Method Path Description
POST baseurl/queries Create a new query. Returns object for newly created query, if successful.

Sample Request

    {
     "o": {"name":"",
     "owner":"123456",
     "spec":[{"dataSetId":"crimes",
              "filters":{"condition":"AND",
                          "rules":[{"id":"what.curr_iucr",
                                    "field":"what.curr_iucr",
                                    "type":"string",
                                    "input":"text",
                                    "operator":"equal",
                                    "value":"041A"}]
                             },
               "rendition":{"color":"%23000000",
                            "opacity":"85",
                            "size":"6"}
                        },
             {"dataSetId":"s311sr",
              "filters":{},
              "rendition":{"color":"%23CD5C5C",
                           "opacity":"85",
                           "size":"6"}
                    }
                ],
     "sharedWith":{"users":[],
                   "groups":[]
                     },
     "isCommon":false,
     "autoRefresh":false,
     "refreshInterval":"30",
     "geoFilter":{"boundaryType":"within",
                  "boundary":"police_district",
                  "value":"18TH"}
        }

Sample Response

    {
     "name":  "",
     "owner":"123456",
     "spec":[{"dataSetId":"crimes",
              "filters":{"condition":"AND",
                         "rules":[{"id":"what.curr_iucr",
                                   "field":"what.curr_iucr",
                                   "type":"string",
                                   "input":"text",
                                   "operator":"equal",
                                   "value":"041A"}]
                             },
              "rendition":{"color":"%23000000",
                           "opacity":"85",
                           "size":"6"}
                        },
             {"dataSetId":"s311sr",
              "filters":{},
              "rendition":{"color":"%23CD5C5C",
                           "opacity":"85",
                           "size":"6"}
                    }
                ],
     "sharedWith":{"users":[],
                  "groups":[]
                         },
     "isCommon":false,
     "autoRefresh":false,
     "refreshInterval":"30",
     "geoFilter":{"boundaryType":"within",
                  "boundary":"police_district",
                  "value":"18TH"}
        }
     "_id" : { "$oid" : "55df5ec39900ec81a481b0f6"}
    }

Return Single Query for User

Method Path Description
POST baseurl/queries/{query_id} Return a single query given a query’s internal id.

Sample Request

https://webapps1.chicago.gov/windygridservice/rest/queries/{"$oid":"5582f831a3db5f4190e4707a"} 

or when URL encoded:

https://webapps1.chicago.gov/windygridservice/rest/queries/%7B%22$oid%22:%5582f831a3db5f4190e4707a%22%7D

Sample Response

    [{
      "_id": { "$oid" : "5582f831a3db5f4190e4707a"},
      "name" : "Weather Records for 60601",
      "owner" : "123456", 
      "spec" : [{"dataSetId": "weather",
                 "filters": {"condition" : "AND",
                              "rules" : [{"id" : "zipcode",
                                          "field" : "zipcode",
                                          "type" : "string",
                                          "input" : "text",
                                          "operator" : "equal",
                                          "value" : "60601"}]
                                    },
                 "rendition": {"color" : "#DC143C",
                               "opacity" : 85,
                               "size" : 6
                                }
                        }],
     "sharedWith" : {"users" : [ ],
                     "groups" : [ ]
                            },
     "isCommon" : true
        }
      ]

Update a Query

Method Path Description
PUT baseurl/queries/{query_id} Update a query. Returns the updated query object, if successful.

Sample Request

https://webapps1.chicago.gov/windygridservice/rest/queries/{"$oid":"55c52cf6c4aa31b24b04d620"} 

or when URL encoded:

https://webapps1.chicago.gov/windygridservice/rest/queries/%7B%22$oid%22:%2255c52cf6c4aa31b24b04d620%22%7D

Sample Response

    {
      "name" : "Tweets on coupon",
      "owner" : "123456", 
      "spec" : [{"dataSetId" : "twitter",
                 "filters": {"condition" : "AND",
                             "rules" : [{"id" : "text",
                                         "field" : "text",
                                         "type" : "string",
                                         "input" : "text",
                                         "operator" : "contains",
                                         "value" : "coupon"
                                                }]
                                        },
                 "rendition" : {"color" : "#DC143C",
                                "opacity" : "85",
                                "size" : "6"
                                            }
                            }],
      "sharedWith" : {"users" : [ ],
                      "groups" : [ ]
                                },
      "isCommon" : false,
      "autoRefresh" : false,
      "refreshInterval" : "30",
      "_id" : {"$oid" : "55c52cf6c4aa31b24b04d620"},
      "geoFilter" : {"boundaryType" : "within",
                     "boundary" : ""
                                }
            }

Delete a Query

Method Path Description
DELETE baseurl/queries/{query_id} Delete a query given the query’s internal Id on the URL path.

Sample Request

https://webapps1.chicago.gov/windygridservice/rest/queries/{"$oid":"55cb6362c4aa475d78d4bc40"}

or when URL encoded:

https://webapps1.chicago.gov/windygridservice/rest/queries/%7B%22%24oid%22%3A%2255cb6362c4aa475d78d4bc40%22%7D 

Sample Response

No response is returned when a query is deleted.