Skip to main content

Official Python client for the Linguin API: multilingual dictionary lookups, reverse dictionary, translation and UI localization.

Project description

Linguin API for Python

Official Python client for the Linguin API: a multilingual dictionary and translation API. Look up any word or phrase in any language, run a reverse dictionary search, translate text and localize UI strings.

No dependencies, Python 3.8+.

Install

pip install linguin-api

Quickstart

from linguin_api import Linguin

linguin = Linguin("YOUR_API_KEY")

entry = linguin.lookup("bonjour", lang="fr")
print(entry["items"][0]["definition"])
# The standard French daytime greeting, equivalent to 'hello' or 'good day'.

Every method returns the API response as a dict and raises LinguinError on failure.

Dictionary

lookup returns the dictionary entry for a term. Mode fast (default) carries the definition, deep the complete entry with pronunciation, meanings, examples, synonyms, etymology and categories. Omit lang to autodetect the word's language.

entry = linguin.lookup("Serendipität", lang="de", locale="en", mode="deep")
for meaning in entry["items"][0]["meanings"]:
	print(meaning["name"], "-", meaning["definition"])

reverse is a reverse dictionary: describe a meaning and get the words that fit. Mode terms (default) returns bare words, fast adds definitions, deep the complete entries.

result = linguin.reverse("a doctor for animals", lang="en", mode="fast", limit=2)
for match in result["matches"]:
	print(match["term"], "-", match["definition"])
# veterinarian - A doctor who treats animals.
# vet - An informal short form of veterinarian, a doctor who treats animals.

Translate

Mode fast is a quick pass, deep weighs context, idiom, register and tone. live=True cross-checks the wording against current web usage, humanizer=True rewrites the output so it reads like a person wrote it.

result = linguin.translate("Hola, ¿cómo estás?", from_lang="es", to="en")
print(result["translation"])
# Hello, how are you?

Localize

Bulk UI localization: a list of strings in, the list translated into one target language out, same length, same order, so it maps straight back onto your keys. Up to 1000 strings per call.

result = linguin.localize(["Save", "Cancel", "Your changes were saved."], to="de")
print(result["strings"])
# ['Speichern', 'Abbrechen', 'Deine Änderungen wurden gespeichert.']

Async delivery

Every generating method takes an optional webhook. With one, the call returns at once with a req_id and the result is POSTed to your URL when ready. A missed callback is recoverable: get(req_id) returns any result by its id, free.

ticket = linguin.translate(long_text, to="ja", mode="deep", webhook="https://example.com/hook")
# {'req_id': '9f1c7b3e-...', 'status': 'queued'}

result = linguin.get(ticket["req_id"])

Account

Billing is prepaid and per word or per call, with the exact charge attached to every response as billed. All account methods are free to call.

linguin.balance()                     # {'balance': 24.9955}
linguin.report(since="2026-07-01")    # calls and cost per method, plus a total
linguin.topup(50)                     # Stripe payment link for a wallet top-up
linguin.refund()                      # unused paid balance back to your cards

new = linguin.key()                   # mint an additional key
linguin.revoke(prefix=new["prefix"])  # revoke one by full value or prefix

Errors

A non-2xx response raises LinguinError with a stable code you can switch on, the HTTP status and a human message. Codes are listed in the API reference.

from linguin_api import Linguin, LinguinError

try:
	linguin.lookup("qwzrtplk")
except LinguinError as e:
	if e.code == "not_found":
		print("no such word")
	elif e.code == "rate_limited":
		...  # back off and retry

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linguin_api-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

linguin_api-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file linguin_api-0.1.0.tar.gz.

File metadata

  • Download URL: linguin_api-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for linguin_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b250a864be4e636caa23d5e8b5a47b1d39b5616d80b67e63ffc71a90d6940eb
MD5 d4450efe4e60487b1cd65a0034ed2cf9
BLAKE2b-256 508e56952cf1457b1c0e8d5bfb30d2185488f360383c1b881038847c6c5161ae

See more details on using hashes here.

File details

Details for the file linguin_api-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: linguin_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for linguin_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c2d660fcf20319db042f5101be5ca7544e087294b539ef455cb97c69000ded7
MD5 d78c93f2ef3182ea6a702cf53f20abf8
BLAKE2b-256 16144e1bd93e26b4039f1d1c58546967280295a41a76d9106494c397613b243f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page