https://github.com/ramtinsoltani/my-coins
https://github.com/ramtinsoltani/my-coins
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ramtinsoltani/my-coins
- Owner: ramtinsoltani
- Created: 2022-05-14T02:14:12.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-18T21:47:31.000Z (over 2 years ago)
- Last Synced: 2025-01-10T03:48:28.397Z (5 months ago)
- Language: JavaScript
- Size: 66.4 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# My Coins API Server
## How to run
1. Install all the dependencies: `pip install -r requirements.txt`
2. Install MongoDB Community server and have it run on `localhost:27017` without user authentication
3. Set the environment variables `BITTREX_API_KEY` and `BITTREX_API_SECRET` with your Bittrex account API key and secret
4. Run `flask run`
5. API server becomes available on `http://localhost:5000`## How to run on Windows startup
1. Set the environment variable `FLASK_APP` with `PATH_TO_PROJECT/app.py` (replace `PATH_TO_PROJECT` with the absolute path to this project)
2. Add the absolute path to this project to the `PATH` environment variable
3. Open the startup folder by pressing Windows + R and typing `shell:startup`
4. Create a VBS file (e.g. `startup.vbs`) with the following content:
```vbs
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run Chr(34) & "run_flask.bat" & Chr(34), 0
Set WshShell = Nothing
```
5. The server will automatically run in the background when the Windows starts next time, process name in Task Manager is `Python.exe`## Endpoints:
- **GET** `/purchases`: Returns a list of all purchases
- **Response**: Array of [Detailed Purchase](#detailed-purchase) or [Error](#error)
- **POST** `/purchase`: Creates a new purchase in the database
- **Body**: [Purchase](#purchase)
- **Response**: [Detailed Purchase](#detailed-purchase) or [Invalid](#invalid) or [Error](#error)
- **PUT** `/purchase/`: Updates an existing purchase in the database
- **Parameters**:
- **id**: The ID of the purchase to update
- **Body**: [Purchase](#purchase)
- **Response**: [Success](#success) or [Invalid](#invalid) or [Error](#error)
- **DELETE** `/purchase/`: Deletes a purchase from the database
- **Parameters**:
- **id**: The ID of the purchase to update
- **Response**: [Success](#success) or [Invalid](#invalid) or [Error](#error)
- **GET** `/bitcoin`: Returns the current market ticker for BTC-USD from Bittrex
- **Response**: [Bittrex Ticker](#bittrex-ticker) or [Bittrex Error](#bittrex-error) or [Error](#error)## Static hosting
Contents of `/public` directory is hosted on `http://localhost:5000`.
# Responses
The following responses are defined in the API server's REST interface:
## Purchase
```py
{
# The dollars value of the purchase
'dollar_value': float,
# The euros value of the purchase
'euro_value': float,
# The Bitcoin price at the time of the purchase
'bitcoin_price': float,
# The Bitcoin volume purchased
'bitcoin_volume': float,
# An epoch timestamp (in milliseconds) for the date of purchase
'created_at': int
}
```## Detailed Purchase
```py
{
'_id': str,
# The dollars value of the purchase
'dollar_value': float,
# The euros value of the purchase
'euro_value': float,
# The Bitcoin price at the time of the purchase
'bitcoin_price': float,
# The Bitcoin volume purchased
'bitcoin_volume': float,
# An epoch timestamp (in milliseconds) for the date of purchase
'created_at': int
}
```## Success
```py
{
'success': bool
}
```## Invalid
```py
{
'invalid': True
}
```## Error
```py
{
'error': True
}
```## Bittrex Ticker
```py
{
'symbol': str,
'lastTradeRate': float,
'bidRate': float,
'askRate': float
}
```## Bittrex Error
```py
{
'code': str,
# Optional
'detail': str,
# Optional
'data': dict
}
```