CARVIEW |
-
App Developers
- App Developers
- Getting Started
- Finding Open Data
- Examples
- Data Visualization with Plotly and Pandas
- Data Analysis with Python and pandas using Jupyter Notebook
- Using R and Shiny to Find Outliers with Scatter and Box Plots
- Analyzing Open Data with SAS
- Building SMS Applications with Twilio
- Forecasting with RSocrata
- Making a heatmap with R
- Create a column chart with Highcharts
- Generating a within_box() query with Leaflet.js
- Using a jQueryUI date slider to build a SODA Query
- Data Analysis with Python, Pandas, and Bokeh
- Animated Heatmap with Heatmap.js
- Build a physical "Traffic Light"
- Google Maps Mashup
- Google Maps with KML
- Simple column chart with D3
- SDKs & Libraries
- PhpSoda
- Google Android
- .NET
- DataSync SDK (Java)
- Elixr
- ember-socrata
- go-soda
- Apple iOS
- Java
- javascript
- Julia
- PHP
- PowerShell
- Python (Dataset Management API)
- Python
- R
- Ruby
- Scala
- Swift
-
Data Publishers
- Data Publishers
- Publisher Guide
- APIs for Publishing Data
- SODA Producer API
- Dataset Management API
- Tools & Connectors
- Connectors & ETL Templates
- Pentaho Kettle
- RSocrata
- Safe FME
- Socrata Datasync
- SDKs & Libraries
- PhpSoda
- .NET
- DataSync SDK (Java)
- ember-socrata
- go-soda
- Java
- javascript
- PHP
- PowerShell
- Python (Dataset Management API)
- Python
- R
- Ruby
- Examples
- Visualizing data using the Google Calendar Chart
- Scrubbing data with Python
- Gauge Visualizations using the Google Charts library
- Pulling data from Hadoop and Publishing to Socrata
- Using Pentaho to Read data from Salesforce and Publish to Socrata
- Using a SSIS to write to a Socrata Dataset
- Pentaho Kettle ETL Toolkit
- Using a Wufoo form to write to a Socrata Dataset
- Pushing Sensor Data to Socrata
- Using the FME Socrata Writer
- Upsert via soda-ruby
-
API Docs
- Overview
- API Endpoints
- Row Identifiers
- RESTful Verbs
- Application Tokens
- Authentication
- Response Codes & Headers
- System Fields
- CORS & JSONP
- Querying
- SoQL Queries
- SoQL Function and Keyword Listing
- Data Transform Functions
- Data Formats
- JSON
- GeoJSON
- CSV
- RDF-XML
- Datatypes
- Checkbox
- Fixed Timestamp
- Floating Timestamp
- Line
- Location
- MultiLine
- MultiPoint
- MultiPolygon
- Number
- Point
- Polygon
- Text
- URL
- Other APIs
- Libraries & SDKs
Queries using SODA3
- Overview
- API Endpoints
- Row Identifiers
- RESTful Verbs
- Application Tokens
- Authentication
- Response Codes & Headers
- System Fields
- CORS & JSONP
- Querying
- SoQL Queries
- SoQL Function and Keyword Listing
- Data Transform Functions
- Data Formats
- JSON
- GeoJSON
- CSV
- RDF-XML
- Datatypes
- Checkbox
- Fixed Timestamp
- Floating Timestamp
- Line
- Location
- MultiLine
- MultiPoint
- MultiPolygon
- Number
- Point
- Polygon
- Text
- URL
- Other APIs
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), used by many relational database systems. Its paradigms should be familiar to most developers who have previously worked with SQL, and are easy to learn for those who are new to it.
Requests must be either authenticated by a user or marked with a valid application token. Developers should now use the HTTP POST method when requesting queries, as this allows for longer queries and clearer options.
The endpoints are split into two:
/query
for querying (e.g.,https://data.cityofchicago.org/api/v3/views/ydr8-5enu/query.json
) Query has more options for customizing the request so that you can fine-tune what data you want back./export
for exports (e.g.,https://data.cityofchicago.org/api/v3/views/ydr8-5enu/export.csv
) Export focuses on providing the entire dataset to be consumed by humans or Microsoft Excel or similar programs.
You can click on each option to see more information about them:
Request Option | /query | /export | Description |
---|---|---|---|
query |
available | available | The SoQL query to run |
page |
available | not available | { pageNumber: 1, pageSize: 1000 } to indicate which page (1-indexed) and how many rows per page |
parameters |
available | available | Some views require parameters to be provided by the user. Details to be provided at a later date |
timeout |
default: 600 |
default: 600 |
The number of seconds before timing out the request. Default: 600 (10 minutes) |
includeSystem |
default: true |
not available | Whether or not to include system columns |
includeSynthetic |
default: true |
not available | Whether or not to include not-explicitly-requested columns, such as system fields |
orderingSpecifier |
default: total |
default: total |
Can be set to discard if you do not care about order and just want the data. Can improve performance significantly |
serializationOptions |
not available | available | Different formats have specific customization options. |
Example
You might use the popular program cURL to make the request with the appropriate payload, or use an appropriate HTTP client library in your preferred programming language.
Query for the first 100 rows of a dataset:
curl --header 'X-App-Token: your-application-token' \
--json '{
"query": "SELECT *",
"page": {
"pageNumber": 1,
"pageSize": 100
},
"includeSynthetic": false
}' \
https://soda.demo.socrata.com/api/v3/views/4tka-6guv/query.json
Export the dataset as CSV with a byte-order mark and a separator character of TAB
:
curl --header 'X-App-Token: your-application-token' \
--json '{
"serializationOptions": {
"separator": "\t",
"bom": true
}
}' \
https://soda.demo.socrata.com/api/v3/views/4tka-6guv/export.csv