Skip to main content

Full-coverage CLI for the Typesense search API

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.3.tar.gz (24.1 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.3-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: typesense_rest_cli-0.1.3.tar.gz
  • Upload date:
  • Size: 24.1 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.3.tar.gz
Algorithm Hash digest
SHA256 4be13019b511403228ffbe18851ef9a9a38560e5cf05a789b47504552c83d11d
MD5 af3ca2f0260c64450f5ced764b7f583e
BLAKE2b-256 dca06b77c56c0fbbf5db7086eced70eede2f2847b6809baccf5ad12cf98343b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typesense_rest_cli-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6ac4b60250ab1903913a1c8518dd0b03d77cee2c3d17d686cec35c74b164c2fc
MD5 e9137104095f0788e699d78748e3e462
BLAKE2b-256 5081e060f06982b2114a427e8e1fef202baaedaf44571e1fe38f00b00a2b41a5

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