A very simple Go REST API that fetches live crypto prices. Supports choosing different currencies and time zones.
-
Clone the repository and enter the directory.
-
(Optional) Create a
.envfile in the root of the project to customize settings:
# The frontend URL to allow CORS requests from (e.g. your React app)
# If not set, CORS will be disabled.
FRONTEND_URL=http://localhost:5173
# The port the API should listen on
# If not set, the default is 8080
PORT=8080- Run the server:
go run main.goFetch the current price of a specific cryptocurrency.
coin(required): The coin ID (e.g.,bitcoin). A full list of supported coin IDs can be found using the/coinsendpoint shown below.currency(optional): The target currency (default:usd)timezone(optional): The time zone for the timestamp (default: UTC)
GET /price?coin=bitcoin¤cy=usd&timezone=America/New_York
{
"coin": "bitcoin",
"currency": "usd",
"price": 29874.53,
"timestamp": "2025-07-18T12:34:56-04:00"
}Returns a list of the coins.
GET /coins
[
{
"id": "bitcoin",
"symbol": "btc",
"name": "Bitcoin"
},
{
"id": "ethereum",
"symbol": "eth",
"name": "Ethereum"
},
{
"id": "ripple",
"symbol": "xrp",
"name": "XRP"
}
]