# Load job postings data into Node.js

> Stream job posts in Node.js with built-in fetch and an async generator - no dependencies.

Page: https://jobdataapi.com/integrations/nodejs/
Category: Programming languages
You need: Node.js 18+, API key in the JOBDATA_API_KEY environment variable and a jobdata API key (https://jobdataapi.com/accounts/pricing/).

## Steps

1. Save the script as jobs.mjs (top-level await needs an ES module).
2. Pass any filters to fetchJobs(); pagination is handled for you.
3. Replace the console.log with your own storage or indexing step.

## Code

```javascript
const API_KEY = process.env.JOBDATA_API_KEY;

async function* fetchJobs(params) {
  let url = 'https://jobdataapi.com/api/jobs/?' +
    new URLSearchParams({ page_size: 1000, ...params });
  while (url) {
    const res = await fetch(url, { headers: { Authorization: `Api-Key ${API_KEY}` } });
    if (!res.ok) throw new Error(`HTTP ${res.status}`);
    const data = await res.json();
    yield* data.results;
    url = data.next;
  }
}

for await (const job of fetchJobs({ max_age: 1, has_remote: 'true' })) {
  console.log(job.id, job.title, job.company.name, job.application_url);
}
```

## Notes

- Keep requests sequential, as in the generator above; see the optimization guide for throughput tips.
- Run it daily with max_age=1 to pick up new job posts; on access lite, drop max_age - the feed covers the past 90 days and upserting by id keeps it free of duplicates.

## Related docs

- [Optimizing API Requests: A Guide to Efficient jobdata API Usage](https://jobdataapi.com/c/optimizing-api-requests-a-guide-to-efficient-jobdata-api-usage/)
- [Jobs API Ingestion Guide: Reliable Historical Backfills and Incremental Syncs](https://jobdataapi.com/c/jobs-api-ingestion-guide-reliable-historical-backfills-and-incremental-syncs/)
- [Date, ID, and Age Slicing Parameters Documentation](https://jobdataapi.com/c/date-id-and-age-slicing-parameters-documentation/)

