Skip to content

RocioCM/ltp-bitcoin-api-challenge

Repository files navigation

Setup and Installation

API in Go that provides endpoints for retrieval of the Last Traded Price of Bitcoin for the following currency pairs:

  1. BTC/USD
  2. BTC/CHF
  3. 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
		}
	]
}

Prerequisites and Requirements

  • Go 1.21 or newer
  • Docker (for containerization)

Environment Configuration

Create a .env file in the root directory based on the env.sample file, and fill in the required values.

Running the Project

Using Docker

  1. Build the Docker image:
docker build -t challenge-bitcoin-api .
  1. Run the Docker container:
docker run -p 8080:8080 challenge-bitcoin-api

Using VS Code Debug

  1. Open the project in VS Code
  2. Make sure the Go extension is installed
  3. launch.json file is already configured for debugging
  4. Start debugging by pressing F5 or clicking the green play button in the Debug panel or using the Run menu and selecting "Start Debugging".

Run tests

To run the tests, you can use the following command:

go test ./tests/integration/... -v

Project Architecture

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

Useful Links

  • The public Kraken API is used to retrieve the Bitcoin LTP information API Documentation

About

API in Go that provides endpoints for retrieval of the Last Traded Price of Bitcoin

Topics

Resources

Stars

Watchers

Forks