@scalar/pre-post-request-scripts
v0.4.34
Published
Execute pre-request and post-response scripts in the Scalar API Client
Readme
Scalar Scripts
Post-response scripts for your OpenAPI documents.
Scalar is an open-source API platform for teams who want beautiful developer interfaces without vendor lock-in.
- API References — Interactive API documentation from OpenAPI and AsyncAPI specs.
- Developer Docs — Write in Markdown/MDX, generate API references, sync with two-way Git.
- SDK Generator — Type-safe SDKs and CLIs in TypeScript, Python, Go, PHP, Java, and Ruby.
- API Client — Open-source, offline-first Postman alternative built on OpenAPI.
20M+ monthly npm installs · 15,500+ GitHub stars · MIT licensed · scalar.com
Scripts are executed with the official Postman sandbox runtime (postman-sandbox), so the pm API behavior follows Postman semantics.
Note: This is intended to be used as a plugin with @scalar/api-client.
Installation
npm install @scalar/pre-post-request-scriptsUsage
import { createApiClientWeb } from '@scalar/api-client/layouts/Web'
import { postResponseScriptsPlugin } from '@scalar/pre-post-request-scripts'
import '@scalar/api-client/style.css'
createApiClientWeb(
document.getElementById('app'),
{
proxyUrl: 'https://proxy.scalar.com',
// Load the plugin
plugins: [
postResponseScriptsPlugin()
],
},
)Script Runtime
- Uses the official Postman sandbox package: https://github.com/postmanlabs/postman-sandbox
- Scripts run as Postman
testscripts, sopm.response,pm.test, andpm.expectare provided by Postman - Script results are surfaced in the Tests panel via the plugin
Community
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.
