I did make a question about this earlier today, but a few hours ago I realized that there is a new API for what I am trying to make. Now the problem is that I need to get every product name, sell price and buy price, and a few more stuff into my website. I have gotten this far so far:
import requests
from flask import Flask, render_template
full_list = list()
app = Flask(__name__)
f = requests.get(
"https://api.hypixel.net/skyblock/bazaar?key=[key is supposed to be secret]").json()
for x in product:
buyPrice = f["products"][x]["buy_summary"][0]["pricePerUnit"]
@app.route('/')
def price():
return render_template("index.html", product=product, buyprice=buyPrice)
if __name__ == "__main__":
app.run(debug=True)
The product API looks a bit like this, I can't post it all because it's very big:
{
"products": {
"product_id": "BROWN_MUSHROOM",
"sell_summary": [
"amount": 3865,
"pricerPerUnit": 14.8,
"orders": 2
],
"buy_summary": [
"amount": 704,
"pricerPerUnit": 15.8,
"orders": 1
],
"quick_status": {
"productId": "BROWN_MUSHROOM",
"sellPrice": 14.527416975007378,
"sellVolume": 915286,
"sellMovingWeek": 23745501,
"sellOrders": 40,
"buyPrice": 15.898423574723452,
"buyVolume": 673646,
"buyMovingWeek": 8011243,
"buyOrders": 54
}
}
Now what I want is "product_id", which could either be grabbed from the beginning or from the "quick_status", I also want pricePerUnit, Amount and Orders from buy/sell_summary.
How do I do this? I have tried to store all values in a separate array named "price" and I used "price.append(buyPrice)" to add, but it only added one product price, I would like to have every product price.
It should end up being something like:
- PRODUCT_ID
- BUY PRICE: XXX
- SELL PRICE: XXX
- BUY ORDERS: X WITH AMOUNT OF X
- BUY ORDERS: X WITH AMOUNT OF X
- BUY VOLUME: XXX
- SELL VOLUME: XXX
Of course I don't need the code for everything, just need a little help with how I extract these values from the API, and get it into my HTML code.
Currently my HTML looks like this:
{% for item in product %}
<h1>{{ item }}</h1>
{% endfor %}