Skip to content

0XwX/deeplx

Repository files navigation

DeepLX on EdgeOne

DeepLX Logo

DeepLX on EdgeOne Pages

Free · Fast · Open Source · Self-hostable

English | 简体中文


Features

  • Free - No payment required, free forever
  • Fast - Based on EdgeOne edge computing, globally accelerated
  • Secure - Fully open source, self-hostable
  • Simple - RESTful API, easy integration into any application
  • Multi-language UI - Supports English and Chinese interface with auto-detection

Quick Start

API Call

curl -X POST https://your-domain.com/translate \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello, World!",
    "source_lang": "auto",
    "target_lang": "ZH"
  }'

Response Example:

{
  "code": 200,
  "data": "你好,世界!",
  "source_lang": "EN",
  "target_lang": "ZH",
  "provider": "deepl"
}

API Usage

POST /translate

Main translation endpoint with multi-provider auto-failover (DeepL → Google).

Request Parameters:

Parameter Type Required Description
text string Yes Text to translate (max 5000 characters)
source_lang string No Source language code, default auto
target_lang string Yes Target language code

Language Code Examples: EN, ZH, JA, KO, DE, FR, ES, PT-BR

POST /api/deepl

Directly call DeepL Provider.

POST /api/google

Directly call Google Translate Provider (text limit 1500 characters).

GET /stats

Get service monitoring statistics.

Self-hosting

This project is deployed on Tencent Cloud EdgeOne Pages.

Prerequisites

  • Node.js >= 18
  • EdgeOne Pages account

Deployment Steps

# 1. Clone repository
git clone https://github.com/0XwX/deeplx.git
cd deeplx

# 2. Install dependencies
npm install
cd frontend && npm install && cd ..

# 3. Login to EdgeOne
npx edgeone login

# 4. One-click deploy
npm run deploy

First deployment will create the project. To deploy to overseas region (no real-name verification required), add -a overseas parameter to the deploy command.

Environment Variables

Variable Description Default
TOKEN API authentication token (optional) None (allow all requests)

When TOKEN is configured, API requests must include authentication:

Method 1: URL Query Parameter (Recommended)

curl -X POST "https://your-domain.com/translate?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello", "target_lang": "ZH"}'

Method 2: Authorization Header

curl -X POST https://your-domain.com/translate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"text": "Hello", "target_lang": "ZH"}'

Development

# Start frontend dev server
npm run dev

# Lint code
npm run lint
npm run format:check

# Build frontend
npm run build

Tech Stack

Backend:

  • EdgeOne Edge Functions
  • KV Storage (health checks + logs)

Frontend:

  • React 19 + TypeScript
  • Vite 7
  • Tailwind CSS 4
  • Lucide Icons

Related Projects

License

MIT License

About

DeepLX on EdgeOne Pages - Free, Fast, Open Source Translation API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors