The beauty of a living thing is not the atoms that go into it, but the way those atoms are put together.
Idea Transcript
Queries using SODA Overview
The Socrata APIs provide rich query functionality through a query language we call the “Socrata Query Language” or “SoQL”. As its name might suggest, it borrows heavily from Structured Query Language (SQL)
API Endpoints
(http://en.wikipedia.org/wiki/Sql), used by many relational database systems. Its paradigms should be familiar to
(/docs/endpoints.html)
most developers who have previously worked with SQL, and are easy to learn for those who are new to it.
Filtering & Querying Simple Filters (/docs/filtering.html) SoQL Queries (/docs/queries/) Paging Through Data (/docs/paging.html) SoQL Function Listing (/docs/functions/)
Data Formats (/docs/formats/) JSON (/docs/formats/json.html) GeoJSON
SoQL Clauses SoQL statements are broken into “parameters” similar to clauses in SQL statements. Each clause can be expressed either directly as a URL parameter or as a SoQL statement. If a parameter is not specified, then the default is used. Click each parameter name for more details: Parameter
Description
Default
$select The set of columns to be returned, All columns, equivalent to $select=* (/docs/queries/select.html) similar to a SELECT in SQL $where Filters the rows to be returned, No filter (/docs/queries/where.html) similar to WHERE $order Column to order results on, similar to Unspecified order (/docs/queries/order.html) ORDER BY in SQL $group Column to group results on, similar to No grouping (/docs/queries/group.html) GROUP BY in SQL $having Filters the rows that result from an No filter (/docs/queries/having.html)aggregation, similar to HAVING $limit 1000 (2.0 endpoints: maximum of 50,000; Maximum number of results to return 2.1: unlimited » (/docs/endpoints.html)) (/docs/queries/limit.html) $offset Offset count into the results to start 0 (/docs/queries/offset.html) at, used for paging Performs a full text search for a $q (/docs/queries/q.html) No search value. $query A full SoQL query string, all as one N/A (/docs/queries/query.html) parameter $$bom Prepends a UTF-8 Byte Order Mark false (/docs/queries/bom.html) to the beginning of CSV output
In $query SELECT WHERE ORDER BY GROUP BY HAVING LIMIT OFFSET N/A N/A N/A
Note that for equality comparisons, the $where clause can be replaced with using the column name as the query parameter. See filtering (/docs/filtering.html) for more details. These parameters can then be directly added to the API endpoint. For example, here is how you would query the USGS Earthquakes datasets for quakes of greater than 3.0 on the Richter scale:
Line (/docs/datatypes/line.html) Location (/docs/datatypes/location.html) Money (/docs/datatypes/money.html) MultiLine (/docs/datatypes/multiline.html) MultiPoint (/docs/datatypes/multipoint.html) MultiPolygon (/docs/datatypes/multipolygon.html) Number (/docs/datatypes/number.html) Point (/docs/datatypes/point.html) Polygon (/docs/datatypes/polygon.html) Text (/docs/datatypes/text.html)
Other APIs Discovery (http://docs.socratadiscovery.apiary.io/) Open Performance (http://docs.openperformance.apiary.io/) OData (/odata/)
(http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US) Licensed by Socrata (http://socrata.com) under CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US). Learn how you can contribute! (/contributing.html)