This project implements a RESTful API endpoint to translate English text to French.
- Endpoint:
/translate
- Method: POST
The API utilizes the Google Translate API to translate the English text received in the request body to French.
The API accepts JSON data in the request body with a key-value pair where the key is "text"
and the value is the English text to translate.
{
"text": "Hello, how are you?"
}
The API responds with a JSON object containing the translated text in French in the format:
{
"translation": "Translated text in French"
}
{
"translation": "Bonjour, comment ça va?"
}
The API handles missing or invalid request bodies and errors during translation with appropriate error messages and status codes.
You can test the API using tools like Postman or cURL to ensure correct translation and response format.
The API is deployed to INSERT_URL_HERE
.
- Node.js
- Express.js
- Google Translate API
To get started with the project, follow these steps:
- Clone this repository.
- Install dependencies using
npm install
. - Run the server using
npm start
. - Send POST requests to
http://localhost:3000/translate
with JSON data containing the English text to translate.
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.