Links

Welcome to Efficient NLP

Getting Started with the Translation API
This guide will walk you through the process of getting started with our service. By integrating our API into your applications, you'll be able to effortlessly translate text.
To get started, you'll need to copy the API key from the cloud console. Then, to use the API, just send a POST request to https://api.efficientnlp.com/v1/translate. The request body should be a JSON object with the following fields:
  • q: List of strings to translate.
  • source: The language of the text to translate.
  • target: The language to translate the text to.
Here are some examples of how to do this in several languages:

Bash

curl -X POST \
-H "Authorization: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"q": ["Hello world"],
"source": "en",
"target": "fr"
}' \
https://api.efficientnlp.com/v1/translate

Python

import requests
headers = {
"Authorization": "YOUR_KEY",
"Content-Type": "application/json"
}
json = {
"q": ["Hello world"],
"source": "en",
"target": "fr",
}
response = requests.post("https://api.efficientnlp.com/v1/translate", json=json, headers=headers)
print(response.content)

Typescript

const axios = require("axios");
const efficientnlp = axios.create({
baseURL: "https://api.efficientnlp.com/v1",
headers: {
"Authorization": "YOUR_KEY",
"Content-Type": "application/json"
}
});
efficientnlp
.post("/translate", {
q: ["Hello world"],
source: "en",
target: "fr",
})
.then(response => console.log(response.data))

Translation Response

The API response will be a JSON list with the translations in the same order as provided in the source:
[ { "translatedText": "Bonjour Monde" } ]

Conclusion

Congratulations! You now have the basic knowledge to make requests to our Translation API. If you have any questions or need further assistance, please reach out to [email protected]. Happy translating!
Last modified 8mo ago