Shobdo Logo

Data Models

The Shobdo API is designed for simplicity and speed. Rather than exposing complex, deeply-nested linguistic graph databases directly to the client, the API aggregates and flattens data into easy-to-consume models.

There are two primary data structures you will work with: the SearchResult (for lists and autocomplete) and the FullEntry (for retrieving the complete contents of a specific word).

All responses are wrapped in a standard API envelope.


The Standard API Response

Every endpoint returns a consistent JSON envelope to make error handling and pagination predictable.

interface ApiResponse<T> {
  ok: boolean;
  data: T;
  meta?: {
    total?: number;
    limit?: number;
    offset?: number;
    took_ms?: number;
  };
  error?: string;
}
  • ok: A boolean indicating success or failure. Check this first.
  • data: The actual payload (e.g., an array of SearchResult objects or a single FullEntry).
  • meta: Pagination details and performance metrics.
  • error: A human-readable error message, present only if ok is false.

SearchResult Object

The SearchResult object is returned by the /search, /autocomplete, and /examples endpoints. It is intentionally lightweight, containing just enough information to render a list of results, a preview, and audio controls.

FieldTypeDescription
idstringThe unique identifier for this specific dictionary entry.
wordstringThe headword (e.g., "hello").
previewstringA plain-text snippet of the primary definition for UI previews.
sourceLangstringThe ISO 639-1 language code of the headword (e.g., "en", "bn").
targetLangstring | nullFor bilingual dictionaries, the translation language code.
dictionaryIdstringThe internal ID of the dictionary this result belongs to.
dictionaryNamestringThe human-readable name of the dictionary.
partOfSpeechstringThe grammatical category (e.g., "noun", "verb"). Optional.
phoneticstringThe IPA pronunciation (e.g., /həˈloʊ/). Optional.
hasAudiobooleanTrue if a high-quality human audio recording is available for this entry.

FullEntry Object

The FullEntry object is returned by the /entry/{source}/{id} and /entry/{source}/word/{word} endpoints. It contains the complete, unabridged dictionary entry.

Unlike many dictionary APIs that force you to traverse complex arrays of senses, sub-senses, and grammatical notes, the Shobdo API handles the heavy lifting on the backend. The htmlContent field provides pre-rendered, semantically correct HTML that preserves the original dictionary's typography (italics, bolding, lists) perfectly.

FieldTypeDescription
idstringThe unique identifier for this entry.
wordstringThe headword.
htmlContentstringThe complete, richly-formatted HTML dictionary article. Ready to be injected into the DOM.
plainTextstringA stripped version of htmlContent containing only the raw text definitions.
sourceLangstringThe source language code.
targetLangstring | nullThe target language code (if bilingual).
dictionaryIdstringThe ID of the dictionary.
dictionaryNamestringThe human-readable name of the dictionary.
partOfSpeechstringThe primary part of speech. Optional.
phoneticstringThe IPA pronunciation. Optional.
synonymsArray<string>A list of related words with similar meanings. Optional.
antonymsArray<string>A list of related words with opposite meanings. Optional.
examplesArray<string>A list of usage sentences. Optional.
hasAudiobooleanTrue if audio is available.
audioUrlstringA direct, pre-signed URL to the MP3/OGG file on our edge CDN. Optional.

Note on htmlContent

The htmlContent field is sanitized and safe to render using standard framework mechanisms (e.g., dangerouslySetInnerHTML in React, or v-html in Vue). It utilizes standard semantic tags (<b>, <i>, <ul>, <li>, <span>) without relying on proprietary CSS classes, ensuring it inherits your application's typography automatically.

Putting it all together

Here is an example of a complete response when fetching a FullEntry for the word "hello":

{
  "ok": true,
  "data": {
    "id": "12345",
    "word": "hello",
    "htmlContent": "<b>1.</b> an expression of greeting.<br><b>2.</b> used to express surprise.",
    "plainText": "1. an expression of greeting. 2. used to express surprise.",
    "sourceLang": "en",
    "targetLang": null,
    "dictionaryId": "shobdo_mono_en_1",
    "dictionaryName": "English Advanced Dictionary",
    "partOfSpeech": "noun",
    "phonetic": "/həˈləʊ/",
    "synonyms": ["hi", "greetings", "salutations"],
    "antonyms": ["goodbye", "farewell"],
    "examples": ["Hello, how are you?", "She said hello to the crowd."],
    "hasAudio": true,
    "audioUrl": "https://api.shobdo.me/api/v1/audio/shobdo_mono_en_1/12345"
  },
  "meta": {
    "took_ms": 12
  }
}

Assistant

Hi! I'm the Shobdo Assistant.
Ask me anything about the documentation.