Apidog

All-in-one Collaborative API Development Platform

API Design

API Documentation

API Debugging

API Mocking

API Automated Testing

How to Use Scalar for API Testing and Documentation: A Beginner’s Guide

New to APIs? This tutorial demonstrates how to use Scalar for API documentation and testing—easy setup, beautiful docs, and testing right out-of-the-box for beginners!

Ashley Goolam

Ashley Goolam

Updated on April 17, 2025

So, you’ve heard the buzz about APIs—those magical bridges that let apps talk to each other—and now you want to dive in, document them like a pro, and test them without breaking a sweat. Enter Scalar, an open-source gem that makes API documentation and testing feel like a walk in the park. In this beginner’s guide, I’m going to hold your hand through using Scalar to create stunning API docs and test endpoints, all with a vibe that’s chill and fun. No coding wizardry required—just curiosity and a laptop. Ready to make your API game shine? Let’s get rolling!

💡
Before we jump into Scalar and API goodness, let’s give a quick nod to Apidog—a total lifesaver for API lovers! This slick tool simplifies designing, testing, and documenting APIs with an interface so friendly even beginners nail it. If you’re tinkering with APIs alongside Scalar, check out apidog.com—it’s a dev’s dream come true!
button

What is Scalar? Your API Sidekick

So, what’s Scalar all about? It’s a modern, open-source platform designed to make API documentation and testing a breeze. Think of it as a stylish notebook that turns your API specs (like OpenAPI/Swagger files) into beautiful, interactive docs and a playground to test endpoints without extra tools. Scalar offers a REST API client, stunning references, and top-notch OpenAPI support, all wrapped in a package that doesn’t scream “designed in 2011.” It’s sleek, developer-friendly, and free to start.

Why use Scalar? It saves you from boring text-heavy docs, lets you test APIs right in the browser, and keeps your team happy with clear, clickable references. Whether you’re documenting a payment API or testing a to-do app, Scalar’s got your back. Let’s set it up!

Installing and Setting Up Scalar: Zero Hassle

Getting Scalar running is as easy as pie—no complicated recipes here. The docs at guides.scalar.com make it super clear, and I will walk you through the beginner-friendly way to start.

Step 1: Choose Your Setup

Scalar is flexible—you can use it as a hosted service, embed it in a project, or run it locally. For beginners, let’s go with the simplest: embedding Scalar in a basic HTML file to play with an API. You don’t need to install anything yet—just a browser and a text editor (like VS Code or Notepad).

Step 2: Create a Scalar HTML File

  1. Make a File: Open your text editor and create a new file called scalar-api.html.
  2. Add Scalar Code: Paste this snippet from the Scalar docs:
<!doctype html>
<html>
<head>
  <title>My Scalar API Reference</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
  <div id="app"></div>
  <!-- Load Scalar -->
  <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
  <!-- Initialize Scalar -->
  <script>
    Scalar.createApiReference('#app', {
      url: 'https://cdn.jsdelivr.net/npm/@scalar/galaxy/dist/latest.json',
      proxyUrl: 'https://proxy.scalar.com'
    })
  </script>
</body>
</html>

3. Save and Open: Save the file, then double-click it to open in your browser (Chrome, Firefox, whatever). Boom—you’ll see Scalar’s shiny interface with a sample API (Scalar Galaxy) loaded.

This setup uses a CDN, so no server or Node.js is needed—perfect for dipping your toes in. I tried it, and it took me less than two minutes to see a working API reference. How’s it going for you?

Step 3: Explore the Interface

Once loaded, Scalar shows a sidebar with API endpoints, a main panel with docs, and a testing area. Click around—it’s interactive! The sample Galaxy API is fun, but we’ll swap it for your own spec soon. If you want the hosted version, sign up at scalar.com for a free account to save your work.

Creating API Documentation with Scalar

Now, let’s use Scalar to document an API. Say you’re working on a to-do list API—we’ll make it look pro without writing a novel.

Step 1: Get or Create an OpenAPI Spec

Scalar loves OpenAPI (aka Swagger) files—JSON or YAML that describe your API’s endpoints, params, and responses. Got one? Great! If not, let’s whip up a simple one:

  1. Create a file called todo-api.yaml:
openapi: 3.0.2
info:
  title: To-Do List API
  version: 1.0.0
  description: A simple API to manage tasks
paths:
  /tasks:
    get:
      summary: List all tasks
      responses:
        '200':
          description: A list of tasks
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                    title:
                      type: string
    post:
      summary: Create a task
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
      responses:
        '201':
          description: Task created

2. Save it in your project folder.

This is a bare-bones spec, but Scalar will make it look amazing.

I Tested Writing OpenAPI Specification with Gemini 2.5 Pro, Here’re My Thoughts:
Discover how to craft OpenAPI specs using Gemini 2.5 Pro in this tutorial—easy steps to design APIs with AI magic!
Learn more about writing OpenAPI for FREE with Gemini 2.5 Pro

Step 2: Load Your Spec in Scalar

To use your spec:

1. Host It (Optional): For now, place todo-api.yaml in the same folder as scalar-api.html. If you have a web server (like Python’s http.server), run:

python -m http.server 8000

Then your spec’s at http://localhost:8000/todo-api.yaml.

2. Update HTML: Change the url in your scalar-api.html:

Scalar.createApiReference('#app', {
  url: './todo-api.yaml', // or http://localhost:8000/todo-api.yaml
  proxyUrl: 'https://proxy.scalar.com'
})

3. Reload: Open scalar-api.html again. Voilà—Scalar renders your to-do API with a clean sidebar, endpoint details, and example responses.

The docs are now interactive—click /tasks to see GET and POST details. Scalar auto-generates code samples in Python, JavaScript, and more. I was blown away by how polished my janky YAML looked!

Step 3: Customize Your Docs

Want flair? Tweak Scalar’s config:

Scalar.createApiReference('#app', {
  url: './todo-api.yaml',
  proxyUrl: 'https://proxy.scalar.com',
  theme: 'purple', // Try 'kepler' or 'moon'
  customCss: 'body { background-color: #f0f0f0; }'
})

Refresh, and your docs pop with a new vibe. Hosted users can save these on docs.scalar.com.

Testing APIs with Scalar

Here’s where Scalar gets extra cool—it’s not just for docs. Its built-in API client lets you test endpoints right in the interface, no Postman needed.

Step 1: Set Up a Testable API

For testing, you need a live API. If you don’t have one, use a public test API like reqres.in. Update your scalar-api.html:

Scalar.createApiReference('#app', {
  url: 'https://reqres.in/api/openapi.yaml',
  proxyUrl: 'https://proxy.scalar.com'
})

Reload, and Scalar loads ReqRes’s API spec.

Step 2: Test Endpoints

  1. In Scalar, find an endpoint like GET /api/users.
  2. Click the “Try it” button (looks like a play icon).
  3. Fill in params (e.g., page: 2) or leave defaults.
  4. Hit “Send.” Scalar fires the request via its proxy to avoid CORS issues and shows the response—status code, headers, and JSON data.

I tested GET /api/users and got a neat JSON list of users in seconds. If you’re using your to-do API, host it locally (say, with Node.js) and test POST /tasks with a body like {"title": "Learn Scalar"}.

Step 3: Debug and Iterate

See a 404? Double-check your API URL or headers in Scalar’s request panel. The client shows errors clearly, so you can tweak and retry fast. Add auth tokens or query params in the UI—no code needed.

Why Scalar is a Beginner’s Dream

Scalar shines for newbies because:

  • Easy Setup: One HTML file, and you’re live.
  • Gorgeous Docs: Turns messy YAML into clickable beauty.
  • Testing Built-In: No extra tools for quick checks.
  • Community Buzz: X posts praise its “dynamic playground” for APIs.

Compared to Swagger UI, Scalar feels fresher and less clunky, with better testing flow. It’s like the cool cousin who makes everything fun.

Pro Tips for Scalar Success

  • Start Small: Use a simple spec to learn Scalar’s flow.
  • Join Discord: Chat with API nerds at discord.gg/scalar.
  • Validate Specs: Paste your YAML in editor.swagger.io to catch errors before loading.
  • Go Hosted: Sign up at scalar.com for collaboration and subdomains.

Conclusion: Your Scalar API Adventure Begins

Congrats—you’re now a Scalar superstar! From spinning up interactive API docs to testing endpoints like a pro, you’ve unlocked a tool that makes APIs less scary and way more fun. Try documenting a pet store API next or test a public one like JSONPlaceholder. The Scalar docs are packed with more tricks, and the community’s buzzing on Discord. What’s your first API project? A game? A blog backend? Oh, and for that extra API polish, swing by apidog.com.

button

How to Use Cursor Tab Completion FeatureViewpoint

How to Use Cursor Tab Completion Feature

This tutorial will guide you through understanding, using, and mastering Cursor Tab, transforming it from a neat feature into an indispensable part of your coding arsenal.

Mark Ponomarev

April 18, 2025

How to Use Google Gemini 2.5 Pro with Open Codex CLI (Open Codex CLI)Viewpoint

How to Use Google Gemini 2.5 Pro with Open Codex CLI (Open Codex CLI)

Open Codex CLI is an open-source tool that brings the power of large language models (LLMs) directly into your terminal workflow. This guide focuses specifically on leveraging one of the most advanced models available today – Google's Gemini 2.5 Pro – within the Open Codex CLI environment. Open Codex CLI is a fork of the original OpenAI Codex CLI, maintaining its core functionality but significantly expanding its capabilities by adding support for multiple AI providers, including Google Gemini.

Emmanuel Mumba

April 18, 2025

How to Use Google Gemini 2.5 Flash via APIViewpoint

How to Use Google Gemini 2.5 Flash via API

Google's advancements in artificial intelligence continue to accelerate, and the introduction of Gemini 2.5 Flash marks another significant step. This model, available in preview, builds upon the speed and efficiency of its predecessor (2.0 Flash) while integrating powerful new reasoning capabilities. What makes 2.5 Flash particularly compelling for developers is its unique hybrid reasoning system and the introduction of a controllable "thinking budget," allowing fine-tuning of the balance betwe

Ashley Innocent

April 18, 2025