npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@elastic/schemas

v0.6.0

Published

Request and response schemas for all Elastic APIs

Readme

Elastic Schemas

@elastic/schemas Build status

Schema definitions for all Elastic APIs, including Elasticsearch, Kibana, and Cloud. Available in multiple forms:

  • Zod schemas
  • plain JSON schemas
  • a tool registry optimized for LLM-based agents

Also includes basic utilities for building HTTP API requests from inputs that match one of the provided schemas.

Installation

Install from npm:

npm install @elastic/schemas

Optional dependencies

Zod is an optional dependency. If you only need JSON schemas or the tool registry, you don't need to install Zod. If you want to use Zod schemas, install it explicitly:

npm install zod

Usage

JSON schemas

Static JSON Schema files are available for each API's request and response. Namespaced APIs are named {namespace}.{name}.request.json; top-level (global) APIs are named {name}.request.json.

import searchRequest from '@elastic/schemas/es/json/search.request.json' with { type: 'json' }
import searchResponse from '@elastic/schemas/es/json/search.response.json' with { type: 'json' }
import findRulesRequest from '@elastic/schemas/kibana/json/find_rules.request.json' with { type: 'json' }
import createApiKeyRequest from '@elastic/schemas/cloud/json/create_api_key.request.json' with { type: 'json' }

The schemas can be used directly with any JSON Schema validator, e.g. Ajv:

import Ajv from 'ajv'
import searchRequest from '@elastic/schemas/es/json/search.request.json' with { type: 'json' }

const ajv = new Ajv()
const validate = ajv.compile(searchRequest)

const valid = validate({ index: 'my-index', query: { match_all: {} } })
if (!valid) console.error(validate.errors)

Zod schemas

If you have Zod installed, import individual schemas by their module path and use them like any Zod schema:

import { SearchRequest } from '@elastic/schemas/es/schemas/search.js'

const result = SearchRequest.safeParse({
  index: 'my-index',
  query: { match: { title: 'elasticsearch' } },
  size: 10,
})

if (!result.success) {
  console.error(result.error.issues)
}

Tool registry

Load a tool definition by API ID and build a ready-to-send HTTP request:

import { esRegistry } from '@elastic/schemas/es/tools/index.js'

const api = await esRegistry.loadApi('search')

const request = api.buildRequest({
  index: 'my-index',
  query: { match: { title: 'elasticsearch' } },
  size: 10,
})
// { method: 'GET', path: '/my-index/_search', body: { query: ..., size: 10 } }

Browse available API IDs via esRegistry.manifest (an array of { id, name, namespace, description } entries).

Tool manifests

Each product exposes a manifest: a lightweight array of ApiRegistryMeta objects describing every available API ({ id, name, namespace, description, namespaceFile }). You can import a manifest directly without loading any schema code:

import { kibanaManifest } from '@elastic/schemas/kibana/tools/manifest.js'
import { esManifest } from '@elastic/schemas/es/tools/manifest.js'
import { cloudManifest } from '@elastic/schemas/cloud/tools/manifest.js'
import { serverlessManifest } from '@elastic/schemas/serverless/tools/manifest.js'

The ApiRegistryMeta type is exported from the main entry point:

import type { ApiRegistryMeta } from '@elastic/schemas'

Available exports

:warning: Importing all the schemas as a single object is going to consume a lot of memory, so we encourage you to use the exact path to the schema you need:

import { SearchRequest } from '@elastic/schemas/es/schemas/search.js'

However, if you do need a full export as one object, the following exports are provided:

| Export | Description | |--------|-------------| | ElasticsearchSchemas | Zod schemas for all ES APIs | | ElasticsearchTools | ES tool registry + esRegistry | | KibanaSchemas | Zod schemas for all Kibana APIs | | KibanaTools | Kibana tool registry + kibanaRegistry | | CloudSchemas | Zod schemas for all Cloud APIs | | CloudTools | Cloud tool registry + cloudRegistry | | ServerlessSchemas | Zod schemas for all Serverless APIs | | ServerlessTools | Serverless tool registry + serverlessRegistry | | ApiRegistryMeta | Shared type for manifest entries |

Version support

The schemas in this package reflect the API specifications for the latest Elasticsearch Serverless release of Elasticsearch and Kibana only, as well as the latest stable release of the Elastic Cloud control plane API. Support for other versions of the Elastic stack is coming!