API in Go that provides endpoints for retrieval of the Last Traded Price of Bitcoin for the following currency pairs:
- BTC/USD
- BTC/CHF
- BTC/EUR
The request path is:
- /api/v1/ltp (all pairs)
- /api/v1/ltp/{pair} (single pair, e.g., BTC-USD)
The response contains a JSON of the following structure:
{
"ltp": [
{
"pair": "BTC/CHF",
"amount": 49000.12
},
{
"pair": "BTC/EUR",
"amount": 50000.12
},
{
"pair": "BTC/USD",
"amount": 52000.12
}
]
}
- Go 1.21 or newer
- Docker (for containerization)
Create a .env
file in the root directory based on the env.sample
file, and fill in the required values.
- Build the Docker image:
docker build -t challenge-bitcoin-api .
- Run the Docker container:
docker run -p 8080:8080 challenge-bitcoin-api
- Open the project in VS Code
- Make sure the Go extension is installed
- launch.json file is already configured for debugging
- Start debugging by pressing F5 or clicking the green play button in the Debug panel or using the Run menu and selecting "Start Debugging".
To run the tests, you can use the following command:
go test ./tests/integration/... -v
This project follows Clean Architecture principles with a layered approach:
api/
├── internal/ # Private application code
│ └── server/ # Server setup and routes
├── pkg/ # Public library code
│ ├── constants/ # Application constants
│ ├── domain/ # Domain models and interfaces
│ └── useCases/ # Application use cases
│ ├── Handlers/ # Business logic handlers
│ └── Helpers/ # Utility helpers
- The public Kraken API is used to retrieve the Bitcoin LTP information API Documentation