Developer API Documentation

Access the Mermru Linguistic Engine via our API.

Interactive Console (Swagger UI)

Explore and test all API endpoints directly in your browser. Ideal for quick testing and debugging.

Go to Swagger UI
Full Specification (ReDoc)

Read the comprehensive, clean, single-page reference documentation. Ideal for understanding structure and architecture.

Go to ReDoc

Programmatic Access (Python Example)

You can access the API from any script or application. Access requires a three-step process:

  1. Step 1: Create an Account. Before you can get a token, you need a user account. If you don't have one, please sign up here.
  2. Step 2: Get an Auth Token. Send your new username and password to the /api/token/ endpoint. You will receive an access token (which expires in 1 year) and a refresh token.
  3. Step 3: Make Your Request. Include the access token in the Authorization header of your API requests, using the Bearer keyword.

Example Python Script (Using JWT) for example for the pronunciations api

You can use the following script to get started. Make sure you have the `requests` library installed (`pip install requests`).



import requests
import json
import getpass

# --- Configuration ---
BASE_URL = "https://mermru.com"  # The production API domain

# 1. Get credentials securely
USERNAME = input("Enter your username: ")
PASSWORD = getpass.getpass("Enter your password: ")
ACCESS_TOKEN = None

# --- Step 1: Get Authentication Token (JWT) ---
print("Attempting to get auth token...")
try:
    auth_response = requests.post(
        f"{BASE_URL}/api/token/",  # Use the new JWT endpoint
        json={"username": USERNAME, "password": PASSWORD}
    )
    auth_response.raise_for_status()  # Raise an exception for bad status codes

    # Get the ACCESS token from the response
    ACCESS_TOKEN = auth_response.json().get("access")
    # You can also get the refresh token if you need to:
    # REFRESH_TOKEN = auth_response.json().get("refresh")

    print(f"Successfully obtained access token: {ACCESS_TOKEN[:10]}...")
except requests.exceptions.RequestException as e:
    print(f"Error getting auth token: {e}")
    if auth_response.status_code == 400:
        print("Error: Bad request. Please check your username and password.")
    else:
        print(f"Response: {auth_response.text}")
    exit()

if not ACCESS_TOKEN:
    print("Could not retrieve API token. Check credentials.")
    exit()

# --- Step 2: Make an Authenticated API Request ---
try:
    search_word = "love"

    # Use the JWT 'Bearer' token scheme
    headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"}

    # Use the filter field 'word' for an exact match
    params = {"word": search_word}

    print(f"Searching for exact word: '{search_word}'")
    api_response = requests.get(
        f"{BASE_URL}/api/pronunciations/",
        headers=headers,
        params=params
    )
    api_response.raise_for_status()

    data = api_response.json()

    print("\n--- API Response (Exact Match) ---")
    print(json.dumps(data, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error making API request: {e}")
    if api_response:
        print(f"Response: {api_response.json()}")