Fetsh JSON

Hi all.

There is a request through the Fetch JSON column to the Binance and ByBit crypto exchanges. Each has its own response in JSON format.

I apply the “.price” filter to the response from Binance and everything works, the price is displayed.
Request: https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT
Response: {“symbol”:“BTCUSDT”,“price”:“20343.35000000”}

Next I also do for ByBit:
Request: https://api.bybit.com/spot/v3/public/quote/ticker/price?symbol=BTCUSDT
Response: {“retCode”:0,“retMsg”:“OK”,“result”:{“symbol”:“BTCUSDT”,“price”:“20290.97”},“retExtInfo”:{},“time”: 1664915455041}

Applying filters:
.[“result”].price
or
.result.price
and nothing works.
Although when checking the filter on the site https://jqplay.org/ everything works out for me, and the filter shows the correct results.

I can’t figure out why it doesn’t work?

Hola!

Your problem with ByBit’s link is caused by a CORS issue

image

To avoid this, you have to use a CORS proxy. You can use this one and append https://corsanywhere.herokuapp.com/ to your URL to get a valid result.

This will look like this using as filter .result.price

Saludos!

2 Likes

@gvalero Thank you very much, everything worked.

1 Like

@gvalero
Now I tried to do it by analogy with the Huobi exchange, it didn’t work in both options
Here is the request https://api.huobi.pro/market/trade?symbol=btcusdt
returns a response, but the .tick.data.price filter does not display the value.
But the .tick.data filter returns an array in the column.
Tried using .tick.data[4] also fails to get price value

Request response text: {“ch”:“market.btcusdt.trade.detail”,“status”:“ok”,“ts”:1664993434014,“tick”:{“id”:160116113672,“ts”:1664993433521, “data”:[{“id”:160116113672642023896059303,“ts”:1664993433521,“trade-id”:102742476481,“amount”:0.010794,“price”:20125.11,“direction”:“buy”}]}}

Can you tell me how to deal with these fields

Hola de nuevo @vladilkud!

Try with .tick.data[0].price

Firefox can give you a better view to understand how JSON payload is returning…

image

Saludos!

3 Likes

I use the JSON Formatter Chrome extension, which works quite well.

2 Likes

@gvalero Thank you very much, everything worked with Huobi, but now ByBit writes that access is denied. Is there really no stable way to get course data from exchanges in Glide.

but in the browser everything shows by ByBit
Error: SyntaxError: Unexpected token ‘<’, “<HEA”… is not valid JSON

Hola!

Maybe you need to create a ByBit’s Token to keep receiving new data due to your free quote is over.

Bye!

1 Like

I need help, with the bybit connection, I’m going crazy anymore I don’t know what to encode in the sha 256 to be able to read the balance of the wallet,
https://api.bybit.com/v2/private/wallet/balance?api_key={api_key}&coin=BTC&timestamp={timestamp}&sign={sign

This is the example that they put to fill in and make the call… but I am not able what am I doing wrong

Please help,.

Hola!

I’m going to need additional info in order to help you better but to start, I think you want to understand the Bybit’s link and its parameters:

  • api_key={api_key} => Here you must type your Bybit’s API key
  • coin=BTC => Your crypto’s ID (BTC= Bitcoin) to be searched
  • timestamp={timestamp} => the BTC price based on this date/time value
  • sign={sign} => I don’t understand what this parameter means :face_with_head_bandage:

If those 4 parameters are mandatory, you have to type them when you use the Bybit’s API link.

Saludos!

Sorry for my bad English, I’m Spanish, I already know all that, something didn’t work right because I didn’t connect, I don’t know what data I have to encrypt in the sha 256

https://bybit-exchange.github.io/docs/futuresV2/inverse/#t-wallet

sign={sign} => I don’t understand what this parameter means
It is understood that sign is the encryption of the API key and timestamp or something else, but it does not work for me, I tried to encrypt in a thousand ways.

Why not just follow the instructions?

https://bybit-exchange.github.io/docs/futuresV2/inverse/#t-constructingtherequest

1 Like

it doesn’t work, in python yes in glide no.

Hola!

Puedes mostrarnos tu ejemplo en Python que si funciona para tener una referencia y probar?

May you share your example in Python to see its schema and test it?

Saludos…

first install the bybit library, then use the example

Hola, lo único que quiero es que me responda bybit con la API privada sin usar phyton desde el navegador, con las públicas ya pude hacerla funcionar en la app de glide, el problema es la codificación sha 256, estoy siguiendo los pasos como explican que codifique los valores de la cadena “pi_key={api_key}&coin=BTC&timestamp={timestamp}” y pasarlo a hex. Pero no funciona.

https://api-testnet.bybit.com/v2/private/wallet/balance?api_key={api_key}&coin=BTC&timestamp={timestamp}&sign={sign}

Pero me devuelve error de sign

Yeap