• 25-09-2023, 14:25:18
    #1
    Edit: (Çözüldü) teşekkürler
    Merhaba,
    Bu api adresinden : https://www.bitexen.com/api/v1/ticker/
    "USDTTRY" Değişkeninden bid ve ask fiyatlarını çekeceğim.

    Mesela btctürkte ve diğer borsalarda sorunsuz şekilde yapabildim fakat bitexende takıldım.
    Sorunsuz çalışan örnek kod:
    btcturk_url = "https://api.btcturk.com/api/v2/ticker"
    
    def get_btcturk_price():
        try:
            response = requests.get(btcturk_url)
            data = response.json()
            for pair_data in data["data"]:
                if pair_data["pair"] == "USDTTRY":
                    buy_price = pair_data["ask"]
                    sell_price = pair_data["bid"]
                    buy_label_btcturk.config(text=f"Alış Fiyatı (BTC Turk): {buy_price}")
                    sell_label_btcturk.config(text=f"Satış Fiyatı (BTC Turk): {sell_price}")
                    break
            root.after(5000, get_btcturk_price)  
        except Exception as e:
            print("BTC Turk API hatası:", e)
    Hatalı kafayı yedirten Kodum :
    bitexen_url = "https://www.bitexen.com/api/v1/ticker"
    def get_bitexen_price():
        try:
            response = requests.get(bitexen_url)
            data = response.json()
            for pair_data in data["data"]:
                if pair_data["pair"] == "USDTTRY":
                    buy_price = pair_data["ask"]
                    sell_price = pair_data["bid"]
                    buy_label_bitexen.config(text=f"Alış Fiyatı (Bitexen): {buy_price}")
                    sell_label_bitexen.config(text=f"Satış Fiyatı (Bitexen): {sell_price}")
            root.after(5000, get_bitexen_price)  
        except Exception as e:
            print(" API hatası:", e)
    Tam olarak nerede hata yapıyorum acaba? Teşekkürler.
  • 25-09-2023, 14:29:50
    #2
    Üyeliği durduruldu
    Kodda sorun yok. Url hatalı hocam.
  • 25-09-2023, 14:30:03
    #3
    bitexen de api linkinin çalıştığına emin misiniz?
  • 25-09-2023, 14:33:07
    #4
    Üyeliği durduruldu
    lastasmile adlı üyeden alıntı: mesajı görüntüle
    evet hocam uğraştırdı ama halüsinasyon görecek kadar bence buyrun siz de bakın https://www.bitexen.com/api/v1/ticker/
    Hocam kodda ticker yazmışsınız o şekilde açılmıyor
    ticker/ bu şekilde yapın.
  • 25-09-2023, 14:34:21
    #5
    Üyeliği durduruldu




  • 25-09-2023, 14:37:26
    #6
    Python Coder
    usdt_try = requests.get("https://www.bitexen.com/api/v1/ticker/").json()['data']['ticker']['USDTTRY']
    ask_price , bid_price = float(usdt_try['ask']) ,float(usdt_try['bid'])
  • 25-09-2023, 14:40:49
    #7
    import requests

    def get_bid_ask_price():
    url = "https://www.bitexen.com/api/v1/ticker/USDTTRY"
    response = requests.get(url)

    if response.status_code == 200:
    data = response.json()
    bid_price = data['bid']
    ask_price = data['ask']
    return bid_price, ask_price
    else:
    print("Error: Unable to fetch data from the API.")
    return None, None

    bid, ask = get_bid_ask_price()
    if bid is not None and ask is not None:
    print("Bid Price: ", bid)
    print("Ask Price: ", ask)
  • 25-09-2023, 14:42:16
    #8
    Üyeliği durduruldu
    lastasmile adlı üyeden alıntı: mesajı görüntüle
    Ah ah her şeyi denedim bir ona akıl edemedim, diğer borsalarda gerekmiyordu, çok çok teşekkür ederim hocam.
    Rica ederim
  • 25-09-2023, 14:49:23
    #9
    Python Coder
    lastasmile adlı üyeden alıntı: mesajı görüntüle
    Çok gariptir ki verilen 3 yanıttaki tüm ihtimalleri denedim fakat yine apiden yanıt alamıyorum
    Hata mesajını yazdırmazsanız hata sebebi anlaşılamaz