From c1af0c7c89eea634336cc8a9964946b669694eb8 Mon Sep 17 00:00:00 2001 From: jerick Date: Thu, 18 May 2023 21:39:15 -0400 Subject: [PATCH] Added api structure calls for Flux and Presearch --- .gitignore | 5 ++++ __init__.py | 0 __pycache__/getPrices.cpython-311.pyc | Bin 0 -> 1095 bytes api.py | 33 +++++++++++++++++++++ getPrices.py | 40 ++++++++++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 .gitignore create mode 100644 __init__.py create mode 100644 __pycache__/getPrices.cpython-311.pyc create mode 100644 api.py create mode 100644 getPrices.py 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 0000000000000000000000000000000000000000..74c45673e1c203cac171f108006cd9220d3d3b3a GIT binary patch literal 1095 zcmdT@J#W)M7(Rc*O+yk09}Q3yF%@+nRu+be!q6m0sH#FrBvhHfiLW$?6Px$!Kv5!j zK!|~%Af$F=Dn#XXFjFZ*rs^~~)!SLUX+nc~x&s!4isLkNo3^Q)z0Y=<6~|sF ztd*bKE^p)>ha`-+P^;3O94bE8q2`)kHd&}zrf2q)Fbed!PnpL;d?I zE++=BT>+;-!N8(L-XF`jJK^k>?Y|ThE@4tG4J#r9WDqL_tH;R;!Gl5a$}YTp8WetM zBsura*sp$B{GP}jC9?fQHYgmY(tGnC=HD-TTnHWxHIhj0w)^oL`!D+OTS0ypBk@$Q zHo~0bf4Bwtzq$p*QeIpF;6GAm1zanb<-lJPBoWT&2N#itQ5WbR5$2Glxyx9DNB>X+ zxQv;X6gY>AkQ;cp9ufPZlauJ(repawy$4tEh`&B|2Vtm4k~ARa12KncN=gmM1QsXO JbdOsi?{DQ-07(D< literal 0 HcmV?d00001 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