Getting Started
Reading this guide helps you to get started with our CLI. We have dozens of commands around API Docs rendering (Markdown + MDX), OpenAPI bundling & linting, pushing to our cloud for governance+hosting & much more!
Quick StartCopied!
npx @scalar/cli help
InstallationCopied!
If you really want to become friends you should install the CLI:
npm -g install @scalar/cli
Otherwise just prefix all commands with npx @scalar/cli
instead of scalar
. That’s fine, too.
Conflict: EXIST: file already existsCopied!
There’s another scalar
CLI, which is bundled with git
. If you run into naming conflicts, but never use the other CLI anyway, you can replace it like this:
npm -g --force install @scalar/cli
Or, if you want to keep using the other scalar
CLI, you can just stick to npx
(or pnpm dlx
):
# Execute without installation (npm)
npx @scalar/cli help
# Execute without installation (pnpm)
pnpm dlx @scalar/cli help
CommandsCopied!
- scalar CLI to work with OpenAPI files, Markdown/MDX, Scalar Platform
- auth Manage authorization on Scalar platform
- document Manage local openapi files
- project Manage Scalar docs project
- registry Manage your Scalar registry
- team Manage user teams
- help Display help for command
AuthenticationCopied!
To authenticate with the Scalar platform you can do the following:
Web LoginCopied!
This opens a web portal which will authenticate, typical for local dev machine workflows
scalar auth login
Now you can interact with all the wonderful authorization endpoints
Token/Machine BasedCopied!
Typical if you want to use in CI workflows or programatically you need to:
- Visit https://dashboard.scalar.com
- Create an account or Login
- Navigate to User -> API Keys https://dashboard.scalar.com/user/api-keys
- Generate an API Key
- Store the token in a safe place!
scalar auth login --token 1234secrettoken5678
Now you can interact with all the wonderful authorization endpoints with just a token! Perfect for GitHub actions or scripts.
GitHub ActionsCopied!
To validate your OpenAPI file in GitHub Actions, add this workflow:
# .github/workflows/validate-openapi-file.yml
name: Validate OpenAPI File
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Validate OpenAPI File
# Replace `./my-openapi-file.yaml` with the correct path and filename for your project.
# Or: run `npx @scalar/cli init` and add the config file to your repository.
run: npx @scalar/cli validate ./my-openapi-file.yaml