TL;DR
NYC Open Data is one of the largest municipal open data portals in the world, with over 2,000 datasets covering everything from 311 service complaints and tree census data to film permits, restaurant inspection grades, and school quality reports. The data is powered by the Socrata platform, which provides a comprehensive REST API with SQL-like queries (SoQL), geospatial filtering, and CSV/JSON/GeoJSON export. Datasets are updated in real-time or on regular schedules depending on the source agency.
Quick start: https://data.cityofnewyork.us/resource/nwxe-4ae8.json
No API key needed — just make a request!
How to Use This API
1. Tree Census Data
The example dataset (nwxe-4ae8) is the 2015 Street Tree Census — every tree in NYC:
https://data.cityofnewyork.us/resource/nwxe-4ae8.json?$limit=5
2. 311 Complaints
https://data.cityofnewyork.us/resource/erm2-nwe9.json?$where=created_date>'2026-01-01'&$limit=10
3. JavaScript — Query Trees by Species
fetch('https://data.cityofnewyork.us/resource/nwxe-4ae8.json?spc_common=American%20elm&$limit=5')
.then(r => r.json())
.then(trees => {
trees.forEach(t => {
console.log(t.tree_id, t.spc_common, t.latitude, t.longitude);
});
});
4. Python — SoQL Query
import requests
# Get counts of trees by borough
resp = requests.get(
'https://data.cityofnewyork.us/resource/nwxe-4ae8.json',
params={'$select': 'boroname, count(tree_id)', '$group': 'boroname'}
)
for row in resp.json():
print(f"{row['boroname']}: {row['count_tree_id']} trees")
https://data.cityofnewyork.us/resource/nwxe-4ae8.json?$limit=3
API Details
- API URL
https://data.cityofnewyork.us/resource- Documentation
- opendata.cityofnewyork.us
- Category
- Government
- Authentication
- Not Required (basic queries)
- Geographic Coverage
- USA — New York City five boroughs
Frequently Asked Questions
- Do I need an API key for NYC Open Data?
- No, all datasets are publicly accessible without authentication. An application token (free) provides higher rate limits if needed.
- How do I find the right dataset ID?
- Browse the portal at
data.cityofnewyork.usand find the four-letter dataset identifier (likenwxe-4ae8for trees). Each dataset page shows its API endpoint. - What is SoQL?
- Socrata Query Language — similar to SQL. Supports
$select,$where,$order,$group,$limit,$offset, and$q(full-text search). - Can I query by geographic area?
- Yes, datasets with location columns support
$within_boxand$within_circleparameters for bounding box and radius queries. - What output formats are available?
- Add
.json,.csv,.xml, or.geojsonto the dataset endpoint. JSON is default. - How often is the data updated?
- Update frequency varies by dataset — 311 data is updated in near real-time, while the tree census is updated periodically. Each dataset page lists its update schedule.
What You Can Build
- NYC tree map showing species distribution by neighborhood
- Restaurant health inspection grade lookup by address
- 311 complaint heatmap for city planning
- Film permit calendar showing street closures
- School quality dashboard comparing districts