Added api structure calls for Flux and Presearch
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#ignore the .env
|
||||||
|
*.env
|
||||||
|
|
||||||
|
#and that csv
|
||||||
|
*.csv
|
||||||
0
__init__.py
Normal file
0
__init__.py
Normal file
BIN
__pycache__/getPrices.cpython-311.pyc
Normal file
BIN
__pycache__/getPrices.cpython-311.pyc
Normal file
Binary file not shown.
33
api.py
Normal file
33
api.py
Normal file
@@ -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()
|
||||||
40
getPrices.py
Normal file
40
getPrices.py
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user