Currency API is a simple service that provides currency conversion rates between two currencies. It fetches exchange rates using the ExchangeRate-API.
- Fetch exchange rates for a given base and target currency.
- Swagger documentation for API endpoints.
- Docker and Docker Compose installed on your system.
- An API key from ExchangeRate-API.
-
Clone the repository:
git clone https://github.com/your-username/reuros-api.git cd reuros-api -
Create a
.envfile in the root directory and add your ExchangeRate-API key:EXCHANGE_RATE_API_KEY=your_api_key_here -
Build and run the application using Docker Compose:
docker-compose up --build
-
The application will be available at
http://localhost:8080.
- Endpoint:
/currency/{base}/{target} - Method:
GET - Description: Fetch the conversion rate between two currencies.
- Parameters:
base(path): Base currency code (e.g., USD).target(path): Target currency code (e.g., EUR).
- Responses:
200 OK: Returns the conversion rate.400 Bad Request: Invalid input or URL format.401 Unauthorized: Missing or invalid API key.500 Internal Server Error: Server error or failed to fetch rates.
Example:
curl http://localhost:8080/currency/USD/EURSwagger documentation is available at:
http://localhost:8080/swagger/
To generate a new version of the Swagger documentation, run the following command:
swag init -g cmd/server/main.go --output docsThe project is deployed using the infrastructure provided by Railway. You can access the services at the following URLs:
- Backend Swagger: https://currency-api-production-01.up.railway.app/swagger/index.html
- UI: https://currency-app-production-01.up.railway.app/
src/handlers: Contains HTTP handlers for API endpoints.src/services: Contains business logic for fetching currency rates.src/models: Defines data models used in the application.src/docs: Auto-generated Swagger documentation files.
EXCHANGE_RATE_API_KEY: API key for accessing the ExchangeRate-API.PORT: Port on which the application runs (default: 8080).