schooldistrictrfp (Node.js)
A Node.js module for the SchoolDistrictRFP REST API. It turns school board approvals, contract end dates and Texas Form 1295 filings into plain JavaScript objects that a cron script, an Express route or a CRM sync job can read.
The module has no runtime dependencies. It talks to the API with the built-in https module, runs on Node.js 14 and newer, and ships its own TypeScript definitions in index.d.ts.
Contents
- Install
- Five lines to a first answer
- The sales problem behind this module
- Methods
- Passing filters
- Walking through pages
- CSV output
- When a request fails
- Rate limits and response headers
- Recipes
- Client options
- TypeScript
- FAQ
- Links
Install
npm install schooldistrictrfp
Every request except the index needs an API key. Keys are issued together with a paid data licence; you ask for a quote through the form on the website, and the key arrives once the licence is active. A key starts with sdr_live_ and is followed by 32 letters and digits.
Keep the key out of source control. The client reads SCHOOLDISTRICTRFP_API_KEY from the environment when you do not pass one, which suits systemd units, container secrets and CI variables equally well.
export SCHOOLDISTRICTRFP_API_KEY=sdr_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Five lines to a first answer
const { Client } = require('schooldistrictrfp');
const sdr = new Client(); // key from SCHOOLDISTRICTRFP_API_KEY
(async () => {
const page = await sdr.renewals({ within_days: 90, category: 'transportation' });
for (const c of page.data) {
console.log(c.end_date, c.district, c.amount_text, c.renewal_options);
}
console.log(`${page.meta.total} contracts end in the next 90 days`);
})();
The output is one line per contract item, ordered by end date, which is the default sort for renewals:
2026-12-01 HOUSTON ISD $1,000,000 two optional one-year renewals
2026-12-15 KATY ISD $250,000 null
...
73 contracts end in the next 90 days
Supplier names sit in c.suppliers as an array of { id, name } objects, because one board item can award several companies at once. In the examples on this page we print them as █████ Inc.
The sales problem behind this module
A district that signs a three year transportation contract will not look at another bus vendor for three years. The date that matters to a seller is the end of that term, or the point where the board must decide on a renewal option. Most teams learn that date too late, when the bid notice is already out.
The API stores those dates as fields. Each contract item approved by a Texas school board carries start_date, end_date, term, renewal_options and a computed days_to_end, next to the supplier, the amount and a link to the board agenda where it was approved. A seller can therefore plan outreach around the month when a district is likely to buy again.
The other data sets fill in the picture around that date:
- 136,000+ Form 1295 certificates filed for school district contracts since January 2021, which show who signed with whom and when;
- 35,000+ suppliers linked across contract items and certificates;
- 19,700+ US school districts with NCES IDs, enrollment and FY2023 spending;
- 860,000+ agenda items from 36,000+ board meetings in 43 states.
There are 42,000+ contract items in total, sorted into 23 categories, and the data is refreshed every week.
Methods
All methods return promises. List methods resolve to a Page; record methods resolve to the record object itself.
| Method |
Endpoint |
Resolves to |
index() |
GET / |
API name, version, endpoint list and counts; works without a key |
districts(params) |
GET /districts |
Page of districts |
district(leaid) |
GET /districts/{leaid} |
one district with top suppliers, top categories, upcoming renewals, recent contracts and meetings |
districtContracts(leaid, params) |
GET /districts/{leaid}/contracts |
Page of contract items for one district |
contracts(params) |
GET /contracts |
Page of contract items |
contract(id) |
GET /contracts/{id} |
one contract item, ids like C001819 |
renewals(params) |
GET /renewals |
Page of contract items ending inside within_days |
certificates(params) |
GET /certificates |
Page of Form 1295 certificates |
certificate(id) |
GET /certificates/{id} |
one certificate, ids like 2026-1457357 |
suppliers(params) |
GET /suppliers |
Page of suppliers |
supplier(id) |
GET /suppliers/{id} |
one supplier with districts served, upcoming end dates and recent records |
supplierContracts(id, params) |
GET /suppliers/{id}/contracts |
Page of contract items for one supplier |
categories() |
GET /categories |
Page with the 23 categories and their counts |
meetings(params) |
GET /meetings |
Page of board meetings; at least one filter |
meeting(id) |
GET /meetings/{id} |
one meeting with its agenda items in order and its contracts |
agendaItems(params) |
GET /agenda-items |
Page of agenda items; at least one filter |
usage(days) |
GET /usage |
your key's limits, today's counts, daily history and calls per endpoint |
Three helpers sit on top of those: iterate(pathOrMethod, params), csv(pathOrMethod, params) and downloadCsv(pathOrMethod, params, file). They accept either a path such as '/renewals' or the camelCase method name such as 'agendaItems'.
A leaid is the seven digit district ID from the NCES Common Core of Data, so Houston ISD is 4823640 and Katy ISD is 4825170. Path IDs are URL escaped by the client, so a value with a slash or a space cannot change the route.
Passing filters
Filters are a plain object whose keys match the API's parameter names exactly. The client turns each value into query text with four rules:
null and undefined are left out, so you can spread optional form input without cleaning it first;
true and false become the strings true and false;
- arrays are joined with commas, which the API reads as OR inside one filter;
Date objects become YYYY-MM-DD.
await sdr.contracts({
district: ['4823640', '4816230'], // Houston ISD OR Dallas ISD
category: ['cybersecurity', 'networks-telecom'],
has_renewal_options: true,
cooperative: false,
min_value: 100000,
end_from: new Date('2027-01-01'),
sort: '-amount',
q: req.query.q || null, // dropped when empty
});
The server rejects parameters it does not know with a 400 unknown_parameter error, which catches typos such as catagory on the first run instead of returning silently unfiltered data. The table lists the filters for contract items, which also apply to renewals, districtContracts and supplierContracts with the small exceptions noted in the API reference.
| Filter |
Meaning |
state, district, district_name |
where the board sits; district takes up to 50 leaids |
category |
one or more of the 23 category IDs |
supplier, supplier_name |
supplier IDs (up to 20) or a name search |
q |
words in the agenda text |
min_value, max_value, has_amount |
contract value in USD |
multi_award, has_renewal_options, cooperative |
booleans |
meeting_from, meeting_to |
when the board approved the item |
end_from, end_to, ending_within_days |
when the contract ends (1 to 1825 days) |
sort |
meeting_date, end_date, amount or district, with - for descending |
Certificates filter by from and to on the acknowledged date. Suppliers filter by min_districts, and districts by enrollment range, has_contracts and has_agendas.
Walking through pages
A list page holds 25 records by default and up to 100 when you set per_page. The Page object exposes exactly what the API returned plus parsed headers:
const page = await sdr.suppliers({ category: 'food-nutrition', per_page: 50 });
page.data; // array of supplier objects
page.meta; // { page, per_page, total, pages, sort }
page.links; // { self, next, prev }, next is null on the last page
page.hasNext; // boolean
page.rate; // { limit, remaining, reset, quotaRemaining, requestId }
To read every record, use the async generator. It asks for 100 records per request and keeps going while links.next is set:
for await (const cert of sdr.iterate('certificates', { district: '4825170', from: '2025-07-01' })) {
console.log(cert.acknowledged, cert.contract_no, cert.categories.join('|'));
}
Because it is a generator, a break stops the loop and no further pages are requested. That keeps a quick look at the first few hundred rows cheap in requests and in daily row allowance.
CSV output
Every list endpoint also answers in CSV with format=csv. Lists inside a record, such as supplier names or categories, are joined with a pipe character, and the response carries X-Total-Count and a Link header with rel="next". The format follows RFC 4180, so spreadsheet tools and csv-parse read it directly.
csv() returns one page as a string. downloadCsv() writes all pages into one file, keeps a single header row, and resolves to the number of data rows written:
const rows = await sdr.downloadCsv('renewals', { within_days: 365, category: 'custodial' }, './custodial-renewals.csv');
console.log(`${rows} rows`);
CSV pages default to 1,000 rows in this helper, which is the server maximum, so a year of renewals in one category usually takes one or two requests. The CSV splitter in the client respects quoted line breaks, so a long agenda title with a newline does not break the header logic.
When a request fails
Every failure is an instance of SchoolDistrictRfpError. The subclass tells you what kind of failure it is, and the properties carry the API's own error body.
| Class |
HTTP status |
Typical code |
KeyFormatError |
none, raised before sending |
key missing or not matching the sdr_ pattern |
AuthenticationError |
401, 403 |
missing_api_key, invalid_api_key, key_revoked, key_expired |
InvalidRequestError |
400, 405 |
invalid_parameter, unknown_parameter, missing_parameter, method_not_allowed |
NotFoundError |
404 |
not_found |
RateLimitError |
429 |
rate_limited, daily_quota_exceeded, too_many_failed_attempts |
ServerError |
500, 503 |
internal_error, unavailable |
Each error has status, code, message, param (for parameter errors), requestId and documentation. A RateLimitError also has retryAfter in seconds. Socket failures, DNS failures and timeouts are wrapped in the base class with the original error on cause.
const { NotFoundError, InvalidRequestError } = require('schooldistrictrfp');
try {
await sdr.contracts({ end_from: '01/02/2027' });
} catch (err) {
if (err instanceof InvalidRequestError) {
console.error(`bad ${err.param}: ${err.message} (request ${err.requestId})`);
} else if (err instanceof NotFoundError) {
console.error('no such record');
} else {
throw err;
}
}
The key never appears in an error message, in JSON.stringify(client) or in a log line written by the module. Quote the requestId when you write to us about a failed request; it lets us find the exact request without the key.
Rate limits and response headers
Limits belong to the key and depend on the licence. The API sends them on every response, and the client copies them into page.rate:
| Header |
page.rate field |
X-RateLimit-Limit |
limit, requests allowed per minute |
X-RateLimit-Remaining |
remaining in the current minute |
X-RateLimit-Reset |
reset, unix time when the minute window resets |
X-Quota-Requests-Remaining |
quotaRemaining for today |
X-Request-Id |
requestId |
A 429 with code rate_limited means the per minute window is full. The client waits for the number of seconds in Retry-After (at most 60, two when the header is missing) and repeats the request, up to maxRetries times. A 503 is retried the same way; RFC 6585 describes the 429 status and the header that goes with it.
A 429 with daily_quota_exceeded is different: waiting a few seconds does not help, so the client throws straight away. Check usage() at the start of a long job if you want to stop early instead of failing halfway.
const u = await sdr.usage(7);
console.log(u.limits.requests_per_day, u.today.requests_remaining, u.today.rows_remaining);
Recipes
The examples/ folder holds four runnable scripts. The snippets below are shortened versions.
Weekly renewal sheet from cron
A Monday morning job that writes every Texas contract in one category ending within 120 days. Point a shared drive or an email step at the file afterwards.