Skip to content

Serving Dictionaries

odict serve starts a local JSON API for lookup, search, split, and tokenization. It is useful when an application in another language needs dictionary access without embedding a native binding.

Terminal window
odict serve animals.odict -p 8080

The server exposes each dictionary by file stem. For animals.odict, the route prefix is /animals.

You can serve multiple dictionaries or every .odict file in a directory:

Terminal window
odict serve animals.odict plants.odict -p 8080
odict serve ./dictionaries -p 8080

All successful responses are JSON.

EndpointParametersUse it for
GET /{name}/lookupq, follow, splitExact headword lookup. Use commas in q for multiple terms.
GET /{name}/searchq, limitFull-text search across definitions.
GET /{name}/splitq, follow, min_lengthCompound splitting without first trying the whole query.
GET /{name}/tokenizetext, followLanguage-aware tokenization and dictionary matching.
Terminal window
curl "http://localhost:8080/animals/lookup?q=cat,dog"
curl "http://localhost:8080/animals/lookup?q=kitty&follow=true"
curl "http://localhost:8080/animals/search?q=domesticated&limit=5"
curl "http://localhost:8080/animals/split?q=catdog&min_length=3"
curl "http://localhost:8080/animals/tokenize?text=the+cat+and+the+dog"

The server keeps recently used dictionaries in memory. Use --capacity to control how many dictionaries stay cached:

Terminal window
odict serve ./dictionaries --capacity 10

Use --level to set the log level:

Terminal window
odict serve animals.odict --level debug