The LanguageWire API is a simple REST API designed to demonstrate translations into five languages (Spanish, German, French, Italian, Danish) and a fun transformation into Jeringonza. It's built with FastAPI and Python 3.12.2, showcasing REST API development best practices.
- Installation
- Running the API
- Running the tests
- Usage
- Architecture
- Packaging and running with Docker
- Contributing
Python 3.12.2 or later
Clone the repository and navigate to the project directory to set up a virtual environment:
git clone https://github.com/yourusername/languagewire-api.git
cd languagewire-api
# For macOS/Linux
python3 -m venv venv
source venv/bin/activate
# For Windows
python -m venv venv
.\venv\Scripts\activate
Install the required dependencies:
pip install -r requirements.txt
Start the API with Uvicorn on the local development server:
uvicorn server.main:app --reload
The API will be available at http://localhost:8000
Run the tests suite with the following command:
pytest
The API provides two main endpoints:
/translations/translate
Accepted Query Parameters:
-
text: Fixed phrase "Hello. How are you?"
-
lang: Target supported language (spanish, german, french, italian, danish)
Example Request:
curl -X 'GET' \
'http://localhost:8000/translations/translate?text=Hello.%20How%20are%20you%3F&lang=french' \
-H 'accept: application/json'
/translations/jeringonza
Transforms any given text into Jeringonza, a playful language game.
Accepted Query Parameters:
- text: Any text to be transformed into Jeringonza
Example Request:
curl -X 'GET' \
'http://localhost:8000/translations/jeringonza?text=biblioteca' \
-H 'accept: application/json'
Read more at http://localhost:8000/docs
The API is structured around FastAPI for handling HTTP requests, with a clear separation between the routing layer (routers), data models (models), and business logic (services). This modular architecture ensures ease of maintenance and scalability.
docker build -t languagewire-api .
docker run -d --name languagewire-api-instance -p 8000:8000 languagewire-api
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue if you encounter any problems or have any questions.