This REST API lets you manage your Bitcoin transactions effortlessly. You can buy and sell Bitcoin, and track your investments in USD.
To run VCrypto API, you’ll need:
- Git
- Docker
- Docker Compose
Follow these steps to get the API up and running:
-
Clone the Repository:
git clone git@github.com:dleloutre/volt-crypto-api.git cd volt-crypto-api -
Copy the environment configuration file:
cp .env.example .env
-
Build and Run with Docker Compose:
docker compose up -d --build
-
Run Migrations:
docker exec -it volt-crypto-app npm run migrate:up -
Seed the Database:
docker exec -it volt-crypto-app npm run seed:allThis will initialize your wallets with $50,000 USD and 0 BTC.
-
Run Tests:
docker exec -it volt-crypto-app npm run test
Buy Bitcoin using your USD wallet.
Example Curl:
curl --location 'http://localhost:8080/api/buy' \
--header 'Content-Type: application/json' \
--data '{
"amount": 0.0001,
"currency": "btc"
}'
Sell Bitcoin and receive USD in return.
Example Curl:
curl --location 'http://localhost:8080/api/sell' \
--header 'Content-Type: application/json' \
--data '{
"amount": 0.0001,
"currency": "btc"
}'
Check how much you have invested in Bitcoin, converted to USD.
Example Curl:
curl --location 'http://localhost:8080/api/portfolio'
To make VCrypto API more scalable and robust, I'd consider the following improvements:
- Asynchronous Processing: Use JavaScript’s async features to manage multiple processes and queries concurrently.
- Caching: Implement caching for frequently accessed data to improve performance.
- User Authentication: Add user sessions with authentication and authorization strategies like OAuth.
- Rate Limiting: Introduce rate limiting to ensure fair usage and prevent abuse.