Packages

Client

A typed HTTP client for the Scrape Admin team API.

@scrape-admin/client wraps the team-scoped REST API from Scrape Admin Web so scripts and other workspace apps can run profiles and manage saved profiles and collections without hand-writing HTTP requests.

Create a client

The package is currently private to this pnpm workspace. Add it as a workspace dependency in the consuming package:

{
  "dependencies": {
    "@scrape-admin/client": "workspace:*"
  }
}

Create an HTTP adapter with the target web app URL, team ID, and a team API key:

import { createHttpAdapter } from '@scrape-admin/client'

const client = createHttpAdapter({
  baseURL: 'http://localhost:3000',
  teamId: 'your-team-id',
  apiKey: 'your-team-api-key',
})

The API key is sent as Authorization: Api-Key <apiKey>. Team-scoped endpoints require a valid key. Keep the key private and avoid including it in browser code or source control.

Run a profile

run executes a profile immediately without saving it. Its result is typed as unknown by default; provide a result type when the shape is known:

const run = await client.run<{ title: string }>({
  url: 'https://example.com',
  elements: [{ name: 'title', selector: 'h1' }],
})

console.log(run.id, run.result.title)

Manage profiles and collections

The profiles and collections clients each provide list, getById, create, update, and delete methods. Their request and response types come from @scrape-admin/web-schema.

const profiles = await client.profiles.list()
const profile = await client.profiles.getById('profile-id')
const createdProfile = await client.profiles.create({ name: 'Example', elements: [] })
const updatedProfile = await client.profiles.update(profile.id, { name: 'Updated example' })
await client.profiles.delete(profile.id)

const collections = await client.collections.list()
const collection = await client.collections.create({ name: 'Example collection' })

Calls use the team's /api/teams/{teamId}/profiles and /api/teams/{teamId}/collections endpoints. Non-success HTTP responses reject with an error from ofetch; handle failures with try/catch as needed.

Copyright © 2026