Skip to content

A simple translation API that acts as a proxy for Google Translate, built with Deno and Hono.

Notifications You must be signed in to change notification settings

cheeaun/translang-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TransLang API

A simple translation API that acts as a proxy for Google Translate, built with Deno and Hono.

Features

  • REST API with both GET and POST endpoints
  • CORS enabled

Installation

  1. Make sure you have Deno installed on your system.
  2. Clone this repository.

Usage

Start the server

# Development mode (with auto-reload)
deno task dev

# Debug mode
deno task debug

# Production mode
deno task start

The server will run on http://localhost:8000 by default.

API Endpoints

List Available Endpoints

GET /

Returns a list of available API endpoints.

Translate Text

GET Method

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 Method

POST /api/v1/translate

Accepts both JSON and form data:

JSON format:

{
  "text": "Hello",
  "sl": "en",
  "tl": "fr"
}

Form data:

  • text: The text to translate
  • sl: Source language code
  • tl: Target language code

Response Format

{
  "detected_language": "en",
  "translated_text": "Bonjour",
  "pronunciation": null
}

List Supported Languages

GET /api/v1/languages

Returns a JSON object with all supported source (sl) and target (tl) languages.

Cache

Translations may be cached for one week via Cache-Control header to improve performance and reduce API calls.

Development

Available Tasks

  • deno task dev: Run the server in development mode with auto-reload
  • deno task debug: Run the server in debug mode
  • deno task start: Run the server in production mode
  • deno task fetch-languages: Update the languages.json file from Google Translate
  • deno task count-languages: Count the number of supported languages

Privacy

Please refer to the Privacy Policy for details on how data is handled.

License

MIT

About

A simple translation API that acts as a proxy for Google Translate, built with Deno and Hono.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published