Scalar Import
![Discord](https://img.shields.io/discord/1135330207960678410?style=flat&color=5865F2)
Pass an URL to an OpenAPI document, a Swagger document, a Postman collection, a Scalar API reference, a Scalar Sandbox link … basically anything, and retrieve an OpenAPI document.
Installation
npm install @scalar/import
Usage
Find any OpenAPI/Swagger document URL in any content:
import { resolve } from '@scalar/import'
const result = await resolve(
'https://github.com/outline/openapi/blob/main/spec3.yml',
)
Features
- Resolves URLs to OpenAPI specifications from various sources
- Supports JSON and YAML formats (
.json
, .yaml
, .yml
) - Extracts OpenAPI specification URLs from HTML content, including:
- Scalar API Reference
<script>
tags - Redoc HTML and JavaScript implementations
- Works with different quote styles and data attribute formats
- Robust error handling for various HTML structures
- Transforms GitHub URLs to raw file URLs
- Handles Scalar Sandbox URLs
Examples
We are API nerds. You too? Let’s chat on Discord: https://discord.gg/scalar
License
The source code in this repository is licensed under MIT.