Socrata API

Open Data / OAuth Advanced HTTPS CORS
68 C
Measured Score 0 50 100 Speed 10/30 Consistency 17/20 Security 18/20 Browser access 15/15 Transparency 8/15 TESTED 2026-08-10

Overview

Socrata is a powerful open data platform that gives you access to thousands of government and civic datasets from around the world. You can query datasets from cities, states, and federal agencies using a SQL-like query language called SoQL. While it supports OAuth for write access, many public datasets can be read without authentication—making it a great starting point for civic data projects.

Beginner Tip

Many Socrata datasets are publicly readable without OAuth—just append ?$limit=10 to the dataset URL to fetch a small sample before diving deeper. When you do need OAuth, register your app at dev.socrata.com to get client credentials.

Measurement Record

What actually happened when we called this API from our own infrastructure. Every value below was recorded by the request, not copied from the provider's documentation.

Request
GET https://data.cityofnewyork.us/resource/h9gi-nx95.json?$limit=5
Result
HTTP 200 · application/json · 3,031 bytes · compressed
Response time
330 ms (median of 3) · fastest 308 ms
Transport
TLSv1.2 · ECDHE-RSA-AES128-GCM-SHA256 · certificate issued by GlobalSign nv-sa
Browser CORS
Allowed — Access-Control-Allow-Origin: *
Served by
nginx
Recorded
2026-08-10

Fields Returned

Top-level fields present in the response we captured, with the type and value we actually received.

Field Type Value received
crash_date string (date) 2021-09-11T00:00:00.000
crash_time string 2:39
on_street_name string WHITESTONE EXPRESSWAY
off_street_name string 20 AVENUE
number_of_persons_injured string 2
number_of_persons_killed string 0
number_of_pedestrians_injured string 0
number_of_pedestrians_killed string 0
number_of_cyclist_injured string 0
number_of_cyclist_killed string 0
number_of_motorist_injured string 2
number_of_motorist_killed string 0
contributing_factor_vehicle_1 string Aggressive Driving/Road Rage
contributing_factor_vehicle_2 string Unspecified

Captured Response

Captured from a real request to https://data.cityofnewyork.us/resource/h9gi-nx95.json?$limit=5 on 2026-08-10. Long arrays and nested objects are truncated to keep the shape readable.

JSON Response · Captured
[
  {
    "crash_date": "2021-09-11T00:00:00.000",
    "crash_time": "2:39",
    "on_street_name": "WHITESTONE EXPRESSWAY",
    "off_street_name": "20 AVENUE",
    "number_of_persons_injured": "2",
    "number_of_persons_killed": "0",
    "number_of_pedestrians_injured": "0",
    "number_of_pedestrians_killed": "0",
    "number_of_cyclist_injured": "0",
    "number_of_cyclist_killed": "0",
    "number_of_motorist_injured": "2",
    "number_of_motorist_killed": "0",
    "contributing_factor_vehicle_1": "Aggressive Driving/Road Rage",
    "contributing_factor_vehicle_2": "Unspecified",
    "…": "(3 more fields)"
  }
]

Implementation Example

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "https://data.cityofnewyork.us/resource/h9gi-nx95.json?$limit=5";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "Authorization": "Bearer YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

How This API Fails

We deliberately sent this API a broken request and recorded exactly what came back on 2026-08-10. Knowing the shape of an error before you hit it makes error handling much easier to write.

HTTP 404 Requesting a path that does not exist application/json
{
  "code": "dataset.missing",
  "error": true,
  "message": "Not found",
  "data": {
    "id": "h9gi-nx95.json"
  }
}
HTTP 400 Sending an invalid value for "$limit" application/json
{
  "code": "query.compiler.malformed",
  "error": true,
  "message": "Could not parse SoQL query \"select * limit !!!invalid!!!\" at line 1 character 16: Expected an integer, but got `!'",
  "data": {
    "query": "select * limit !!!invalid!!!",
    "position": {}
  }
}

Common Errors & Troubleshooting

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

401 Unauthorized Accessing a protected dataset without proper OAuth token.
Register an app at dev.socrata.com, complete the OAuth flow, and include the bearer token in your Authorization header.
400 Bad Request with SoQL error Invalid SoQL query syntax in the $where or $select parameter.
Double-check your SoQL syntax—column names must match the dataset exactly and strings need single quotes, e.g., $where=city='New York'.
Throttling / 429 Too Many Requests Exceeding the default unauthenticated rate limit of 1,000 requests per rolling hour.
Add an app token via the X-App-Token header to raise your limit to 1,000 requests per hour per token.

Measured Score Breakdown

Live HTTP request to the API endpoint

Speed 10/30
Consistency 17/20
Security 18/20
Browser access 15/15
Transparency 8/15
Endpoint Response Time 330ms

Fully tested on Aug 10, 2026

Technical Specifications

Auth OAuth
HTTPS REQUIRED
CORS YES
Category Open Data
Difficulty Advanced
Endpoint last called: 2026-08-10

Similar APIs

View All →