Overview

Scalar API

TypeScript SDK#

For TypeScript, we provide a SDK that makes using our API even easier.

Install#

npm add @scalar/sdk

Get a Scalar API key#

Create an API key in your Scalar account:

SCALAR_API_KEY=your_personal_token

Exchange your API key for an access token#

The personal token is not an access token. Exchange it first with postv1AuthExchange.

If you use the personal token directly for authenticated API calls, the API returns 401 Invalid authentication token.

import { Scalar } from '@scalar/sdk'
 
const scalar = new Scalar()
 
const exchange = await scalar.auth.postv1AuthExchange({
  personalToken: process.env.SCALAR_API_KEY!,
})
 
const accessToken = exchange.accessToken

Use the access token#

Construct a second client with bearer auth. Use this authenticated client for API calls.

import { Scalar } from '@scalar/sdk'
 
const scalar = new Scalar()
 
const exchange = await scalar.auth.postv1AuthExchange({
  personalToken: process.env.SCALAR_API_KEY!,
})
 
const authedScalar = new Scalar({
  bearerAuth: exchange.accessToken,
})

Notes#

  • The exchange request itself can be made from a client constructed with no arguments (new Scalar()).
  • The exchanged access token is valid for 12 hours.
  • Timestamps are Unix seconds.

Read more#

Base URL: https://access.scalar.com

Every page below is generated from the OpenAPI document, so it describes the API that is running right now.

Updated

Was this page helpful?