For developers

Langrit developer reference

Build your own tutor, bot or script on the learner memory: a standard MCP server, OAuth 2.1, personal tokens and a REST API.

Overview

Two ways in, one memory. Every call reads or writes the same learner record the Langrit app uses, so reviews, streaks and levels stay in sync.

MCP serverhttps://langrit.com/mcp
REST APIhttps://langrit.com/api/v1

Quick start

Connect an MCP client

terminal
claude mcp add --transport http langrit https://langrit.com/mcp
JSON-RPC
curl https://langrit.com/mcp \
  -H "Authorization: Bearer lgr_…" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call",
       "params":{"name":"whats_due","arguments":{"limit":5}}}'

Call the REST API with a personal token

REST
curl https://langrit.com/api/v1/due?limit=5 \
  -H "Authorization: Bearer lgr_…"

Authentication

Send a bearer token on every request. Use OAuth 2.1 when people connect from your app, or a personal token for your own scripts.

OAuth 2.1

Clients find the authorization server through discovery, starting from the WWW-Authenticate header of a 401 on /mcp. Dynamic client registration and client ID metadata documents are supported, so most clients need no setup.

401
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://langrit.com/.well-known/oauth-protected-resource/mcp"
OAuth 2.1
GET https://langrit.com/.well-known/oauth-protected-resource/mcp
GET https://langrit.com/.well-known/oauth-authorization-server

authorize  https://langrit.com/oauth/authorize
token      https://langrit.com/oauth/token
register   https://langrit.com/oauth/register
revoke     https://langrit.com/oauth/revoke
  • Authorization code with PKCE (S256) only. The redirect carries code, state and iss.
  • Access tokens last one hour. Refresh tokens last 60 days and rotate on every use; an old refresh token stops working.
  • Redirect URIs: https, http on localhost (any port) or a private app scheme.

Scopes

readProfile, due reviews, patterns, export
writeAlso save mistakes and grade reviews (includes read)

Personal tokens

Create up to five in Settings, API access. A token is shown once and can be revoked at any time.

MCP server

Streamable HTTP, stateless, JSON responses. POST every JSON-RPC message; GET returns 405 because there is no server stream.

Tools

ToolScopeInputReturns
learner_profileread{}Languages, level, plan, due count
whats_duereadlimit?Due cards with mode, prompt and choices
my_patternsreadwindow? 7d | 30d | 90dPatterns with counts and examples
remember_mistakewritewrong, correct, rule?, context? | items[≤20]Created or merged cards, pattern, hint
grade_reviewwritecard_id, answer, mode, elapsed_ms?Correct, expected answer, next review, ladder

Prompts and resources

Prompts today, quiz, my-mistakes and write open a study session in the learner's languages. The resource langrit://me returns the profile as JSON.

Question modes

recognition comes with choices and the expected answer; typed and translate never reveal the answer before grading.

REST API

The same memory over HTTPS. JSON in and out.

EndpointWhat it does
GET /api/v1/meYour profile, plan and due count
POST /api/v1/mistakesSave one mistake or up to 20 (write)
GET /api/v1/dueDue reviews with the question mode
POST /api/v1/reviewsGrade an answer (write)
GET /api/v1/patternsMistake patterns for 7, 30 or 90 days
GET /api/v1/exportCards, mistakes and reviews as JSON, CSV or Anki

Example

mistakes
POST /api/v1/mistakes
Idempotency-Key: 6f1c…

{ "wrong": "de huis", "correct": "het huis", "rule": "huis is a het-word" }

201 -> { "created": 1, "merged": 0,
         "cards": [{ "id": 812, "pattern": "article_de_het", "pattern_label": "de vs het",
                     "merged": false, "l1_hint": "…" }] }
reviews
POST /api/v1/reviews
{ "card_id": 812, "answer": "het huis", "mode": "typed" }

200 -> { "correct": true, "expected": "het huis", "explanation_l1": null,
         "next_due_at": "2026-11-08T09:00:00Z", "interval_days": 4,
         "ladder": { "before": 1, "after": 2 }, "streak": 12 }

Errors

Errors are JSON with error, message and hint. The hint is written for a model to act on; pass it through.

StatusMeaning
401Missing, invalid or expired token
402No active plan or trial (profile and export still work)
403The token lacks the needed scope
404Unknown card or route
422The body did not validate
429Rate limit or daily AI grading budget reached
402
402 -> { "error": "subscription_required",
         "message": "The Langrit subscription for this account is not active.",
         "url": "https://langrit.com/pricing?ref=api",
         "hint": "Tell the learner their Langrit trial or subscription has ended and give them the url." }

Limits

60 requests a minute per token on the REST API and 120 on MCP. POST requests accept an Idempotency-Key header; a repeat within 24 hours returns the first response.

Data export

GET /api/v1/export returns everything as JSON. Add format=csv with table=cards, mistakes or reviews, or format=anki for an Anki import file. Works on an ended plan too.