diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a655b61 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +#ignore the .env +*.env + +#and that csv +*.csv \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/__pycache__/getPrices.cpython-311.pyc b/__pycache__/getPrices.cpython-311.pyc new file mode 100644 index 0000000..74c4567 Binary files /dev/null and b/__pycache__/getPrices.cpython-311.pyc differ diff --git a/api.py b/api.py new file mode 100644 index 0000000..14895db --- /dev/null +++ b/api.py @@ -0,0 +1,33 @@ +from flask import Flask +from flask_restful import Resource, Api, reqparse +import pandas as pd +import ast +from re import search +import sys +sys.path.append("C:/Users/jerick/Documents/Development/databroker") + +from getPrices import fluxPrice, prePrice + +app = Flask(__name__) +api = Api(app) + +class Crypto(Resource): + def get(self): + #initialize empty dict + priceDict = {} + #Flux + flux = fluxPrice() + priceDict.update({'Flux': flux}) + + #Presearch + pre = prePrice() + priceDict.update({'Presearch': pre}) + + #print (priceDict) + data = priceDict + return {'data': data}, 200 + +api.add_resource(Crypto, '/crypto') + +if __name__ == '__main__': + app.run() \ No newline at end of file diff --git a/getPrices.py b/getPrices.py new file mode 100644 index 0000000..54cb4e0 --- /dev/null +++ b/getPrices.py @@ -0,0 +1,40 @@ +#Checks price of flux +import requests + +def fluxPrice(): + #URL to send the request to + url = 'https://api.kucoin.com/api/v1/market/orderbook/level1?symbol=FLUX-USDT' + headers = '' + #Looks only for the price data + params = {'price': ''} + + #result calculcation + result = requests.get(url=url, params=params) + jsonResult = result.json() + #fluxPrice = + #Finds the json data with the "data" category, then looks for "price" + price = jsonResult["data"]["price"] + #Maps to a dict that will be returned to the API + #price = {'Flux': price} + #print(price) + + return price + +def prePrice(): + #URL to send the request to + url = 'https://api.kucoin.com/api/v1/market/orderbook/level1?symbol=PRE-USDT' + headers = '' + #Looks only for the price data + params = {'price': ''} + + #result calculcation + result = requests.get(url=url, params=params) + jsonResult = result.json() + #fluxPrice = + #Finds the json data with the "data" category, then looks for "price" + price = jsonResult["data"]["price"] + #Maps to a dict that will be returned to the API + #price = {'Flux': price} + #print(price) + + return price