Skip to content

Vakya API (Example Sentences)

The Vakya API provides example sentences showing words used in context. This is useful for language learning applications and understanding word usage.

Endpoints

Method Endpoint Description
GET /api/v1/dictionary/vakya?q={word} Get example sentences for a word
GET /api/v1/dictionary/vakya/{word} Get example sentences (path parameter)
POST /api/v1/dictionary/vakya/random Get random example sentences

Get Sentences for a Word

Retrieve example sentences that use a specific word.

Request

GET /api/v1/dictionary/vakya?q={word}
Parameter Type Required Description
q string Yes The word to find examples for

Example Request

curl "https://sabdasakha.com/api/v1/dictionary/vakya?q=औतार"
import requests

response = requests.get(
    "https://sabdasakha.com/api/v1/dictionary/vakya",
    params={"q": "औतार"}
)
result = response.json()

for sentence in result["example_sentences"]:
    print(sentence)
const response = await fetch(
  "https://sabdasakha.com/api/v1/dictionary/vakya?q=औतार"
);
const result = await response.json();

result.example_sentences.forEach(sentence => {
  console.log(sentence);
});

Success Response (200)

{
  "word": "औतार",
  "example_sentences": [
    {
      "word": "औतार",
      "example_sentence": "तँ त शिवकै औतार रहिछस्",
      "raw_definition": "१. वैष्णव धारणाअनुसार विष्णु भगवान्ले पृथ्वीमा लिएका विभिन्न जन्म..."
    }
  ],
  "count": 1
}
Field Type Description
word string The queried word
example_sentences array List of example sentence objects
example_sentences[].word string The word in the example
example_sentences[].example_sentence string The example sentence
example_sentences[].raw_definition string Full definition from dictionary
count integer Number of sentences returned

Not Found Response (404)

When no examples exist for a word:

{
  "error": "'घर' शब्दका लागि कुनै उदाहरण वाक्य फेला परेन।",
  "word": "घर",
  "example_sentences": [],
  "count": 0
}

Get Random Sentences

Retrieve random example sentences from the dictionary. Useful for "word of the day" features or learning activities.

Request

POST /api/v1/dictionary/vakya/random
Content-Type: application/json
Field Type Required Default Description
limit integer No 2 Number of sentences to return (1-10)

Example Request

curl -X POST "https://sabdasakha.com/api/v1/dictionary/vakya/random" \
  -H "Content-Type: application/json" \
  -d '{"limit": 2}'
response = requests.post(
    "https://sabdasakha.com/api/v1/dictionary/vakya/random",
    json={"limit": 2}
)
result = response.json()

for item in result["example_sentences"]:
    print(f"{item['word']}: {item['example_sentence']}")
const response = await fetch(
  "https://sabdasakha.com/api/v1/dictionary/vakya/random",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ limit: 2 })
  }
);
const result = await response.json();

result.example_sentences.forEach(item => {
  console.log(`${item.word}: ${item.example_sentence}`);
});

Success Response (200)

{
  "example_sentences": [
    {
      "word": "औतार",
      "example_sentence": "तँ त शिवकै औतार रहिछस्",
      "raw_definition": "१. वैष्णव धारणाअनुसार विष्णु भगवान्ले पृथ्वीमा लिएका विभिन्न जन्म..."
    },
    {
      "word": "रत्ती",
      "example_sentence": "अँ मैले भनेको रत्ती मान्दैन",
      "raw_definition": "१. लाल, रती; रातीगेडी; लालगेडी। क्रि.वि. २. अलिकति; अत्यन्त थोरै..."
    }
  ],
  "count": 2
}
Field Type Description
example_sentences array List of word-sentence pairs
example_sentences[].word string The featured word
example_sentences[].example_sentence string Example sentence using the word
example_sentences[].raw_definition string Full definition text from dictionary
count integer Number of sentences returned

Use Cases

Word of the Day

Display a random interesting word with its usage:

response = requests.post(
    "https://sabdasakha.com/api/v1/dictionary/vakya/random",
    json={"limit": 1}
)
wotd = response.json()["example_sentences"][0]

print(f"Word of the Day: {wotd['word']}")
print(f"Example: {wotd['example_sentence']}")

# Also fetch the definition
definition = requests.get(
    f"https://sabdasakha.com/api/v1/dictionary/word/{wotd['word']}"
).json()
print(f"Meaning: {definition['definitions'][0]['text']}")

Vocabulary Quiz

Generate quiz questions from example sentences:

response = requests.post(
    "https://sabdasakha.com/api/v1/dictionary/vakya/random",
    json={"limit": 5}
)

for item in response.json()["example_sentences"]:
    # Replace word with blank in sentence
    question = item["example_sentence"].replace(item["word"], "_____")
    print(f"Fill in the blank: {question}")
    print(f"Answer: {item['word']}\n")

Learning Context

Help users understand word usage in context:

def learn_word(word):
    # Get definition
    defn = requests.get(
        f"https://sabdasakha.com/api/v1/dictionary/word/{word}"
    ).json()

    # Get examples
    examples = requests.get(
        "https://sabdasakha.com/api/v1/dictionary/vakya",
        params={"q": word}
    ).json()

    print(f"Word: {word}")
    print(f"Meaning: {defn['definitions'][0]['text']}")
    print("Examples:")
    for sentence in examples["example_sentences"]:
        print(f"  - {sentence}")

Best Practices

  1. Cache random sentences - Refresh periodically, not on every page load
  2. Combine with dictionary - Show definitions alongside examples
  3. Highlight the word - Make the target word visually distinct in sentences
  4. Handle empty results - Some words may not have example sentences