This is a simple currency conversion API built using Go and the HTTP framework. It fetches real-time exchange rates from the ExchangeRate-API and allows users to convert currency values.
- Fetches live exchange rates from ExchangeRate-API.
- Converts currency based on user input.
- Uses Gin for routing and JSON response handling.
- Lightweight and efficient.
- Go (version 1.18+ recommended)
- An active internet connection
- ExchangeRate-API key (replace with your own key in the
API_URLconstant)
- Clone this repository:
git clone https://github.com/your-repo/currency-converter-api.git cd currency-converter-api - Install dependencies:
go mod tidy
- Run the server:
go run main.go
- The server will start at
http://localhost:8080.
GET /convert?base=USD&target=EUR&amount=100base- Base currency code (e.g., USD)target- Target currency code (e.g., EUR)amount- Amount to convert
{
"base": "USD",
"target": "EUR",
"rate": 0.85,
"message": "1 USD = 0.85 EUR"
}Developed by SAURABH SINGH PATEL. Contributions are welcome!