LingoX API Documentation

Welcome to the LingoX API documentation. This API provides endpoints to create apps, translate text, manage authentication, and more.

Features

  • Create and manage apps.
  • Immediate and queued text translations.
  • Secure user authentication.

Authentication

This API uses Bearer tokens for secure communication. Include the token in the Authorization header:
Authorization: Bearer <your_token>
For translation endpoints, provide the x-api-key and x-api-secret headers, you will get it after creating your first app.
x-api-key: <your_api_key>
x-api-secret: <your_api_secret>

Endpoints

Auth Endpoints

Login User

POST /auth/login Login a user to receive a Bearer token. JavaScript Example:
const endpoint = 'https://lingox-a52b18533193.herokuapp.com';

async function loginUser() {
  const response = await fetch(`${endpoint}/auth/login`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email: 'user@example.com', password: '123456' }),
  });
  
  const data = await response.json();
  console.log('Token:', data.token);
}

loginUser()

Sign Up

POST /auth/signup Register a new user. JavaScript Example:
const endpoint = 'https://lingox-a52b18533193.herokuapp.com';

async function signUpUser() {
  const response = await fetch(`${endpoint}/auth/signup`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email: 'user@example.com', password: '123' }),
  });
  const data = await response.json();
  console.log('Message:', data.message);
}

signUpUser();

Get Profile

GET /auth/profile Retrieve the profile of the authenticated user. JavaScript Example:
const endpoint = 'https://lingox-a52b18533193.herokuapp.com';

async function getUserProfile() {
  const response = await fetch(`${endpoint}/auth/profile`, {
    method: 'GET',
    headers: { Authorization: 'Bearer your_token' },
  });
  
  const data = await response.json();
}

getUserProfile();}

App Management

Create App

POST /create Create a new app. JavaScript Example:
const endpoint = 'https://lingox-a52b18533193.herokuapp.com';

async function createApp() {
  const response = await fetch(`${endpoint}/create`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: 'Bearer your_token',
    },
    body: JSON.stringify({
      name: 'My App',
      url: 'https://example.com',
      webHookUrl: 'https://example.com/webhook',
    }),
  });
  
  const data = await response.json();
  console.log('Created App:', data);
}

createApp();

List Apps

GET /list Retrieve all apps associated with the user. JavaScript Example:
const endpoint = 'https://lingox-a52b18533193.herokuapp.com';

async function listApps() {
  const response = await fetch(`${endpoint}/list`, {
    method: 'GET',
    headers: { Authorization: 'Bearer your_token' },
  });
  
  const data = await response.json();
  console.log('Apps:', data);
}

listApps();

Translation Endpoints

Immediate Translation

POST /translateText Request immediate text translation. Note: The from field is optional. If not provided, the model will automatically detect the source language. JavaScript Example:
const endpoint = 'https://lingox-a52b18533193.herokuapp.com';

async function translateText() {
  const response = await fetch(`${endpoint}/translateText`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': 'your_api_key',
      'x-api-secret': 'your_api_secret',
    },
    body: JSON.stringify({
      text: 'Hello, world!',
      to: 'es',
    }),
  });
  const data = await response.json();
  console.log('Translated Text:', data.translatedText);
}

translateText();

Queued Translation

POST /queue Request queued text translation. JavaScript Example:
const endpoint = 'https://lingox-a52b18533193.herokuapp.com';

async function queueTranslation() {
  const response = await fetch(`${endpoint}/queue`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': 'your_api_key',
      'x-api-secret': 'your_api_secret',
    },
    body: JSON.stringify({
      text: 'Good morning',
      from: 'en',
      to: 'fr',
    }),
  });
  
  const data = await response.json();
}

queueTranslation();