npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gal-scraper

v0.1.0

Published

TypeScript SDK for docs-scraper API

Readme

gal-scraper

TypeScript SDK for the docs-scraper API.

Installation

npm install gal-scraper

Requirements

  • Node.js 18+ (uses native fetch)

Usage

Basic Example

import { DocsScraperClient } from 'gal-scraper';

const client = new DocsScraperClient({
  baseUrl: 'https://your-docs-scraper-instance.com',
  apiSecret: 'your-api-secret',
});

// Submit a scrape job
const { jobId } = await client.scrape({
  url: 'https://docs.example.com/page',
});

// Check job status
const job = await client.getJob(jobId);
console.log(job.status); // 'queued' | 'processing' | 'blocked' | 'completed' | 'failed' | 'cancelled'

// Get results when completed
if (job.status === 'completed') {
  const { job: completedJob } = await client.getResults(jobId);
  console.log(completedJob.result?.signedUrl);
}

Handling Blocked Jobs

When a scrape job encounters authentication or other blocking requirements:

const job = await client.getJob(jobId);

if (job.status === 'blocked' && job.blockingReason) {
  console.log(job.blockingReason.type); // 'auth' | 'captcha' | 'custom'
  console.log(job.blockingReason.fields); // Fields that need to be filled

  // Provide the required data with type safety
  await client.update<{ email: string; password: string }>({
    jobId,
    data: {
      email: '[email protected]',
      password: 'password123',
    },
  });
}

Providing Data Upfront

You can provide authentication data upfront when submitting a scrape job:

interface LoginCredentials {
  username: string;
  password: string;
}

const { jobId } = await client.scrape<LoginCredentials>({
  url: 'https://protected-docs.example.com/page',
  data: {
    username: 'user',
    password: 'pass',
  },
});

Session Management

Sessions allow reusing browser state across scrape jobs:

// List all sessions
const { sessions } = await client.listSessions();

// Use an existing session
const { jobId } = await client.scrape({
  url: 'https://docs.example.com/another-page',
  sessionId: sessions[0].id,
});

// Delete a session
await client.deleteSession(sessionId);

// Clear all sessions
await client.clearSessions();

Job Management

// List jobs with pagination
const { jobs, total, page, limit } = await client.listJobs({
  page: 1,
  limit: 20,
});

// Cancel a job
const cancelledJob = await client.cancelJob(jobId);

// Delete a job
await client.deleteJob(jobId);

Health Check

// No authentication required
const health = await client.health();
console.log(health.status); // 'ok'

Error Handling

import {
  DocsScraperClient,
  AuthenticationError,
  NotFoundError,
  ValidationError,
  ConflictError,
  NetworkError,
  TimeoutError,
} from 'gal-scraper';

try {
  await client.getJob('non-existent-job');
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log('Job not found');
  } else if (error instanceof AuthenticationError) {
    console.log('Invalid API secret');
  } else if (error instanceof ValidationError) {
    console.log('Invalid request:', error.message);
  } else if (error instanceof ConflictError) {
    console.log('Conflict:', error.message);
  } else if (error instanceof NetworkError) {
    console.log('Network error:', error.message);
  } else if (error instanceof TimeoutError) {
    console.log('Request timed out');
  }
}

Configuration Options

const client = new DocsScraperClient({
  // Required
  baseUrl: 'https://your-instance.com',
  apiSecret: 'your-secret',

  // Optional
  timeout: 60000, // Request timeout in ms (default: 30000)
  fetch: customFetch, // Custom fetch implementation
});

API Reference

Client Methods

Scrape

  • scrape<TData>(options) - Submit a new scrape job
  • update<TData>(options) - Update a blocked job with provided data
  • getResults(jobId) - Get the results of a scrape job

Jobs

  • listJobs(options?) - List all jobs with pagination
  • getJob(jobId) - Get a specific job by ID
  • cancelJob(jobId) - Cancel a job
  • deleteJob(jobId) - Delete a job

Sessions

  • listSessions() - List all sessions
  • deleteSession(sessionId) - Delete a specific session
  • clearSessions() - Clear all sessions

Health

  • health() - Check API health (no auth required)

Types

All types are exported from the package:

import type {
  Job,
  JobStatus,
  JobResult,
  BlockingReason,
  BlockingField,
  Session,
  ScrapeOptions,
  UpdateOptions,
  ClientOptions,
  // ... and more
} from 'gal-scraper';

License

MIT