Skip to main content

A full-coverage CLI for the Typesense search engine REST API, generated from the official OpenAPI spec

Project description

typesense-rest-cli

A full-coverage CLI for the Typesense search engine REST API. Every endpoint in Typesense's OpenAPI spec, exposed as a typed command. Generated from Typesense's official OpenAPI spec using openapi-cli-gen.

Why

Typesense has client libraries for most popular languages, but no REST CLI. For shell scripts, CI automation, index bootstrapping, and ad-hoc admin tasks, most people hand-roll curl with their API key in a header and hope they spelled the JSON right.

This CLI gives you the entire Typesense REST surface as typed shell commands — collections, documents, searches, aliases, keys, stopwords, analytics, conversations — no SDK, no boilerplate. When Typesense adds endpoints, a regeneration picks them up.

Install

pipx install typesense-rest-cli

# Or with uv
uv tool install typesense-rest-cli

Setup

Point it at your Typesense instance (default is http://localhost:8108):

export TYPESENSE_REST_CLI_BASE_URL=http://localhost:8108

Authentication — important

Typesense uses an API key header (X-TYPESENSE-API-KEY), which this CLI maps to:

export TYPESENSE_REST_CLI_API_KEY=your-api-key

Note the env var name — it's _API_KEY, not _TOKEN. Typesense's spec uses an apiKey security scheme (not bearer), so the convention matches.

Quick Start

All commands below have been verified against a live Typesense instance.

# Server health
typesense-rest-cli health health

# Create a collection with a typed schema
typesense-rest-cli collections create \
  --name books \
  --fields '[
    {"name": "title",  "type": "string"},
    {"name": "author", "type": "string", "facet": true},
    {"name": "year",   "type": "int32"}
  ]' \
  --default-sorting-field year

# List all collections
typesense-rest-cli collections get-collections

# Get a specific collection's schema + doc count
typesense-rest-cli collections get-collection --collection-name books

# Index a document (use --root for the JSON body)
typesense-rest-cli documents index --collection-name books --root '{
  "id": "1",
  "title": "The Pragmatic Programmer",
  "author": "Hunt and Thomas",
  "year": 1999
}'

# Index another
typesense-rest-cli documents index --collection-name books --root '{
  "id": "2",
  "title": "Clean Code",
  "author": "Robert Martin",
  "year": 2008
}'

# Search — note that `q` is a single-char flag, so use -q (short form)
typesense-rest-cli documents search-collection \
  --collection-name books \
  -q code \
  --query-by title,author

# Delete the collection
typesense-rest-cli collections delete --collection-name books

The -q vs --q gotcha

Typesense's search endpoint uses a single-character query parameter q. Python's argparse treats single-character flags as short-form options, so you invoke it as -q code (one dash), not --q code. The --help output shows [-q str] — follow that.

Discover All Commands

# Top-level groups
typesense-rest-cli --help

# Commands in a group
typesense-rest-cli collections --help

# Flags for a specific command
typesense-rest-cli documents search-collection --help

documents search-collection exposes all ~70 search parameters as individual flags (--query-by, --filter-by, --sort-by, --facet-by, --include-fields, etc.).

Output Formats

Every command accepts --output-format:

typesense-rest-cli collections get-collections --output-format table
typesense-rest-cli collections get-collections --output-format yaml
typesense-rest-cli collections get-collections --output-format raw

Command Groups

Group What it covers
health Liveness probe
collections Full CRUD for collections + aliases (blue/green indexing)
documents Index, upsert, get, delete, search, import, multi-search
analytics Analytics rules + events (click / search tracking)
keys API key creation + scoping
curation-sets Override / promote search results
synonyms Per-collection synonym sets
stopwords Stopword management
presets Reusable search parameter presets
conversations Conversational search models
nl-search-models Natural-language search models
stemming Stemming dictionaries
operations Snapshot, vote, re-elect leader, cache, slow-request log
debug Debug info

Passing Complex JSON Bodies

Most documents write endpoints take raw documents whose schema is user-defined — the generator can't produce typed flags for them. Use --root with a JSON string:

typesense-rest-cli documents index --collection-name books --root '{"id":"1", ...}'
typesense-rest-cli documents update-document --collection-name books --document-id 1 --root '{"year":2024}'

Flat endpoints (like collections create) take typed flags directly.

How It Works

This package is a thin wrapper:

  • Embeds the Typesense OpenAPI spec (spec.yaml)
  • Delegates CLI generation to openapi-cli-gen at runtime
  • Default base URL: http://localhost:8108

Since it's spec-driven, new Typesense endpoints show up automatically on regeneration.

License

MIT. Not affiliated with Typesense — this is an unofficial community CLI built on top of their public OpenAPI spec.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typesense_rest_cli-0.1.1.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typesense_rest_cli-0.1.1-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file typesense_rest_cli-0.1.1.tar.gz.

File metadata

  • Download URL: typesense_rest_cli-0.1.1.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for typesense_rest_cli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0ffa711afba95a028c18459d966fb5270adbcb41162b6bc5a75ed32bbe5390cf
MD5 59c4822fbd180cf7a43c7032b89006ae
BLAKE2b-256 bc78010c053b04665d10e3c1a42562b3fe45de5abf655ad0d32b9fabc2293bec

See more details on using hashes here.

File details

Details for the file typesense_rest_cli-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for typesense_rest_cli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 594afeffb3164924e4d175b54fd1593a99aeaec01f1fb674f3c1fdb998005f64
MD5 4094440e4dcc26308a181bb6261d4e56
BLAKE2b-256 35a89141e67d087c252e2975995cacf3ae7c2972f22581a583cc50b6ca6e2855

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page