# Schools API - US School Directory & District Lookup (`martin10291/us-schools-api`) Actor

Official US K-12 school directory as JSON, no API key: 102,274 public and 22,510 private schools from NCES (2023-24) with NCES id, district, address, lat/lon, locale, grades, enrollment, teachers and student-teacher ratio. Search by name, city, state or ZIP, schools near a point or ZIP within N mile

- **URL**: https://apify.com/martin10291/us-schools-api.md
- **Developed by:** [Martin Petrov](https://apify.com/martin10291) (community)
- **Categories:** Business, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.70 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Schools API - US School Directory & District Lookup

**Problem:** your real-estate app needs "schools near this home", your edtech CRM needs a clean list of every school in a district, your relocation site or AI agent needs enrollment, grades and student-teacher ratio for a school by name. Rating sites forbid scraping, and the official NCES files are shapefiles and 100,000-row CSVs with coded columns.

**This API:** one JSON call, no API key, answers from a maintained copy of the official NCES school directory (EDGE locations + CCD characteristics, school year 2023-24): **102,274 public and 22,510 private schools, 19,637 districts**.

- **search:** by `name` (part of it), `city`, `state` (`CA` or `California`), `zip`, `district`; filter by `level` (elementary, middle, high ...) and `schoolType` (public, private, all).
- **near:** schools within `radiusMiles` (0.1-50) of `lat`/`lon` or a `zip`, sorted by `distanceMiles`.
- **school:** up to 50 schools by NCES id (`ncesIds`).
- **district:** every school of a district (NCES LEAID or name) plus a summary row: school count, total enrollment, teachers, charter schools, schools by level.
- **bulk:** up to 50 queries in one call; a bad query returns an error row, the others still answer.
- **Fields:** NCES id, district id and name, address, county, lat/lon, locale (City: Large ... Rural: Remote), metro area, congressional district, level, grades low/high, enrollment, teachers (FTE), student-teacher ratio, free/reduced lunch eligible, charter, virtual, status.
- **Monitor:** `onlyNew` + `monitorId` returns only schools not returned before (new schools, changed enrollment).

### Example (API)

```bash
curl -X POST "https://api.apify.com/v2/acts/martin10291~us-schools-api/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode": "near", "zip": "78701", "radiusMiles": 1}'
```

Output row (measured 2026-11-14):

```json
{"rowType": "school", "ncesId": "480147313991", "name": "UNIVERSITY OF TEXAS AT AUSTIN H S", "schoolType": "public",
 "districtId": "4801473", "street": "2901 N IH 35", "city": "AUSTIN", "state": "TX", "zip": "78722", "county": "Travis County",
 "lat": 30.279356, "lon": -97.742885, "localeLabel": "City: Large", "congressionalDistrict": "TX-37", "level": "High",
 "gradeLow": "09", "gradeHigh": "12", "enrollment": 788, "teachersFte": 28.0, "studentTeacherRatio": 28.14,
 "distanceMiles": 0.4, "schoolYear": "2023-2024", "source": "NCES EDGE/CCD 2023-24, U.S. public domain"}
```

More inputs:

- `{"mode": "search", "name": "Lincoln", "state": "CA"}` -> 68 schools named Lincoln in California.
- `{"mode": "district", "district": "0622710"}` -> Los Angeles Unified: 785 schools, 418,503 students, plus every school.
- `{"mode": "search", "city": "Austin", "state": "texas", "level": ["high"]}` -> high schools in Austin.
- `{"mode": "bulk", "queries": [{"mode": "near", "zip": "10001", "radiusMiles": 1}, {"mode": "school", "ncesIds": ["060177000049"]}]}`

### Use from agents (MCP)

Add the Apify MCP server (`https://mcp.apify.com?tools=martin10291/us-schools-api`) to Claude, Cursor or any MCP client and ask: "Which public high schools are within 3 miles of ZIP 94110, and what is their student-teacher ratio?".

### Data source

U.S. Department of Education, National Center for Education Statistics (NCES): EDGE public and private school locations and Common Core of Data (CCD) characteristics, school year 2023-24, via the official NCES ArcGIS services. U.S. government work, public domain; the source is named on every row. No scraping, no ratings, no personal data (no staff names, e-mails or phones).

### Schedule it

Run it from your app on demand, or schedule it on Apify (Schedules -> every week) with `onlyNew: true` and a `monitorId` per area to get only new schools and changed enrollment. Chain it with an integration (webhook, Google Sheets, Zapier, Make) to push results into your CRM.

### FAQ

- **How fresh is the data?** NCES publishes the directory once a year; this API serves school year 2023-24 (the newest year with both public and private schools) and re-checks the source daily. `schoolYear` is on every row; if NCES is down the last copy is served with `"stale": true`.
- **Limits:** up to 5,000 rows per call (`limit`, default 100), radius 0.1-50 miles, 50 NCES ids or 50 bulk queries per call.
- **Errors:** an unknown state, ZIP or district or a bad radius returns a clear `invalid input` message; in bulk mode only that query becomes an error row.
- **Ratings or test scores?** No: only official NCES data (no GreatSchools/Niche ratings, no staff names or contacts).
- **Private schools:** location fields only (NCES does not publish enrollment by private school in this layer).

### Pricing

$1.00 per 1,000 rows. A `school` call for one NCES id = 1 row.

# Actor input Schema

## `mode` (type: `string`):

search = filter by name/city/state/ZIP/district; near = schools within radiusMiles of lat/lon or a ZIP; school = one or more schools by NCES id; district = all schools of a district (LEAID or name) plus a summary row; bulk = up to 50 queries in one call.

## `name` (type: `string`):

Part of the school name, case-insensitive (search mode), e.g. Lincoln.

## `city` (type: `string`):

City name (search mode), e.g. Austin.

## `state` (type: `string`):

2-letter code or full name, e.g. CA or California.

## `zip` (type: `string`):

5-digit ZIP. search: schools in this ZIP; near: centre of the radius.

## `lat` (type: `number`):

near mode: centre latitude (use with lon instead of zip).

## `lon` (type: `number`):

near mode: centre longitude.

## `radiusMiles` (type: `number`):

near mode: 0.1-50 miles, default 5. Rows are sorted by distanceMiles.

## `district` (type: `string`):

District NCES LEAID (7 digits) or district name (search and district modes), e.g. 0622710 (Los Angeles Unified).

## `ncesIds` (type: `array`):

school mode: up to 50 NCES school ids (12-digit public NCESSCH or 8-character private PPIN).

## `schoolType` (type: `string`):

public (default), private or all.

## `level` (type: `array`):

Public schools only: elementary, middle, high, secondary, prekindergarten, other.

## `queries` (type: `array`):

bulk mode: up to 50 objects, each one an input of another mode, e.g. {"mode":"near","zip":"10001","radiusMiles":1}. A failing query returns an error row; the others still answer.

## `limit` (type: `integer`):

1-5000, default 100.

## `onlyNew` (type: `boolean`):

Return only rows not returned before for the same Monitor ID. Schedule the run to get changes only.

## `monitorId` (type: `string`):

Name of this monitor; each ID keeps its own memory of rows already returned.

## Actor input object example

```json
{
  "mode": "search",
  "name": "Lincoln",
  "state": "CA",
  "radiusMiles": 5,
  "schoolType": "public",
  "limit": 100,
  "onlyNew": false
}
```

# Actor output Schema

## `results` (type: `string`):

One row per school (search, near, school, district modes) with NCES id, district, address, coordinates, locale and CCD characteristics; district mode adds a districtSummary row; bulk rows carry the query index.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "search",
    "name": "Lincoln",
    "state": "CA"
};

// Run the Actor and wait for it to finish
const run = await client.actor("martin10291/us-schools-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "search",
    "name": "Lincoln",
    "state": "CA",
}

# Run the Actor and wait for it to finish
run = client.actor("martin10291/us-schools-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "search",
  "name": "Lincoln",
  "state": "CA"
}' |
apify call martin10291/us-schools-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,martin10291/us-schools-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/tGaErf83GhjvcAJqK/builds/UuqUbAvxovMAqbXlm/openapi.json
