A simple translation API that acts as a proxy for Google Translate, built with Deno and Hono.
- REST API with both GET and POST endpoints
- CORS enabled
- Make sure you have Deno installed on your system.
- Clone this repository.
# Development mode (with auto-reload)
deno task dev
# Debug mode
deno task debug
# Production mode
deno task startThe server will run on http://localhost:8000 by default.
GET /
Returns a list of available API endpoints.
GET /api/v1/translate?text=Hello&sl=en&tl=fr
Parameters:
text: The text to translate (required)sl: Source language code (optional, defaults to 'auto' for auto-detection)tl: Target language code (optional, defaults to 'en')
POST /api/v1/translate
Accepts both JSON and form data:
JSON format:
{
"text": "Hello",
"sl": "en",
"tl": "fr"
}Form data:
text: The text to translatesl: Source language codetl: Target language code
{
"detected_language": "en",
"translated_text": "Bonjour",
"pronunciation": null
}GET /api/v1/languages
Returns a JSON object with all supported source (sl) and target (tl) languages.
Translations may be cached for one week via Cache-Control header to improve performance and reduce API calls.
deno task dev: Run the server in development mode with auto-reloaddeno task debug: Run the server in debug modedeno task start: Run the server in production modedeno task fetch-languages: Update the languages.json file from Google Translatedeno task count-languages: Count the number of supported languages
Please refer to the Privacy Policy for details on how data is handled.