Skip to content

Latest commit

 

History

History
154 lines (113 loc) · 3.67 KB

File metadata and controls

154 lines (113 loc) · 3.67 KB

TVMaze Scraper — JavaScript / Node.js usage

Call the hosted TVMaze Scraper Actor from Node.js with the official apify-client. This client talks to the Apify platform — no scraping code runs locally.

Install

npm install apify-client

Authenticate

Get your API token from https://apify.com/account/integrations. Prefer an environment variable over hard-coding it:

import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });

Run the actor and fetch results

import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });

// Search TV shows by name
const run = await client.actor('logiover/tvmaze-scraper').call({
  mode: 'searchShows',
  query: 'breaking bad',
  maxResults: 50,
});

// Fetch dataset items
const { items } = await client.dataset(run.defaultDatasetId).listItems();

for (const show of items) {
  console.log(`${show.name} (${show.premiered}) — rating ${show.rating}`);
}

Example inputs per mode

Crawl the catalogue (showIndex)

const run = await client.actor('logiover/tvmaze-scraper').call({
  mode: 'showIndex',
  startPage: 0,
  maxResults: 5000,
});

Show details by ID batch, with cast (showDetails)

const run = await client.actor('logiover/tvmaze-scraper').call({
  mode: 'showDetails',
  showIds: ['169', '82', '83'],
  embedCast: true,
});

Every episode of a series (episodes)

const run = await client.actor('logiover/tvmaze-scraper').call({
  mode: 'episodes',
  showId: '83',
  maxResults: 2000,
});

Cast & characters (cast)

const run = await client.actor('logiover/tvmaze-scraper').call({
  mode: 'cast',
  showId: '169',
});

Daily TV schedule (schedule)

const run = await client.actor('logiover/tvmaze-scraper').call({
  mode: 'schedule',
  country: 'US',
  date: '2026-07-06',
});

People search or by ID (people)

const run = await client.actor('logiover/tvmaze-scraper').call({
  mode: 'people',
  query: 'bryan cranston',
  maxResults: 20,
});

Paginate large datasets

listItems supports offset and limit so you can stream through big result sets:

const datasetClient = client.dataset(run.defaultDatasetId);

let offset = 0;
const limit = 1000;

while (true) {
  const { items, total } = await datasetClient.listItems({ offset, limit });
  for (const item of items) {
    // process each show / episode / cast / schedule row
  }
  offset += items.length;
  if (offset >= total || items.length === 0) break;
}

Start a run without waiting (fire-and-forget)

// .start() returns immediately with the run object
const run = await client.actor('logiover/tvmaze-scraper').start({
  mode: 'showIndex',
  maxResults: 20000,
});

console.log('Run started:', run.id);

// Later, wait for it and read results:
const finished = await client.run(run.id).waitForFinish();
const { items } = await client.dataset(finished.defaultDatasetId).listItems();

Export to CSV / Excel

// Download the dataset in a specific format as a Buffer
const csvBuffer = await client.dataset(run.defaultDatasetId).downloadItems('csv');
// e.g. fs.writeFileSync('tvmaze.csv', csvBuffer);

const xlsxBuffer = await client.dataset(run.defaultDatasetId).downloadItems('xlsx');

Supported formats include json, csv, xlsx, jsonl, and xml.


▶️ Run TVMaze Scraper on Apify · 📄 Documentation only.