# The Socrata Open Data APIs

## Every dataset, on every Socrata data site
GET https://data.seattle.gov/resource/fire-911.json?$where=datetime > '2012-08-22 15:45'
[
{
"address": "1402 E Pike St",
"longitude": "-122.314118",
"latitude": "47.614121",
"incident_number": "F120079189",
"datetime": 1345675560,
"type": "Motor Vehicle Accident",
"report_location": {
"longitude": "-122.314118",
"latitude": "47.614121"
}
}
]
## Finding Data
* [hackforchange.org/datasets](http://hackforchange.org/datasets)
* [communities.socrata.com](https://communities.socrata.com)
* [http://www.data.gov/developers/page/developer-data](http://www.data.gov/developers/page/developer-data)
## API Endpoints
Format:
https://$domain/resource/$identifier.ext
## API Endpoints
Example: [Electric Consumption by Zip Code](https://data.city.gov/Environmental-Sustainability/Electric-Consumption-by-ZIP-Code-2010/abcd-1234)
https://data.city.gov/envir.../elec.../abcd-1234
... becomes ...
https://data.city.gov/resource/abcd-1234.json
## Simple Filters
/resource/abcd-1234.json?source=ConEd
[ {
"zipcode" : "10001",
"source" : "ConEd",
"location" : {
"longitude" : "-73.99688630375988",
"latitude" : "40.75025902143676",
},
"building_type" : "Commercial",
"kwh" : "23328498"
}, ... ]
## SoQL Queries
/resource/abcd-1234.json?
$where=kwh > 80000
For more details see dev.socrata.com
## Aggregating Data
/resource/abcd-1234.json?
$select=source, sum(kwh)
&$group=source
[ {
"source" : "ConEd",
"sum_kwh" : "49469570957"
}, {
"source" : "Long Island Power Authority",
"sum_kwh" : "445333629"
}, ... ]
## Limiting Output
/resource/abcd-1234.json?
$limit=5
## Paging Through Data
/resource/abcd-1234.json?
$limit=50
&$offset=100
## Application Tokens
1. Register at [http://dev.socrata.com/register](http://dev.socrata.com/register)
2. Include as:
- X-App-Token: $token
HTTP Header or ...
- The $$app_token=$token
parameter
3. Profit!!! (from more API requests)