Как вернуть поля «цена» из p2p-торговли на сайте by bit? ⇐ JAVA
Как вернуть поля «цена» из p2p-торговли на сайте by bit?
I'm making a web application for personal use.
I need to take the first 3 p2p trading positions from the ByBit site. Namely (USDT-KZT) [Purchase], the price field. Display them on the vp page. I've been suffering for three weeks now. They have a java API, but there is nothing there to work with the p2p trading section. I use Inteleji Idea, postman web, java, maven, okhttp, spring boot.
I found a legal entity where you can make a request (https://api2.bybit.com/fiat/otc/item/online), prescribed in the body:
{"userId":"","tokenId":"USDT","currencyId":"KZT","payment":[],"side":"1","size":"3","page":"1","amount":"","authMaker":false,"canTrade":false}
I checked in postman, the whole page arrives instantly. But there are a lot of extra fields. Next, I poured okhttp into my project, made a method:
public String kztBuy() { double result = 0; String allrequest = ""; OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json; charset=utf-8"); String json = "{\"userId\":\"\",\"tokenId\":\"USDT\",\"currencyId\":\"KZT\",\"payment\":[],\"side\":\"1\",\"size\":\"3\",\"page\":\"1\",\"amount\":\"\",\"authMaker\":false,\"canTrade\":false}"; RequestBody body = RequestBody.create(json, mediaType); Request request = new Request.Builder() .url("https://api2.bybit.com/fiat/otc/item/online") .post(body) .build(); try { Response response = client.newCall(request).execute(); // java.net.SocketTimeoutException String responseString = response.body().string(); allrequest = responseString; System.out.println("KztBuy result"); System.out.println(responseString); // just over 250 lines here. There is a lot of excess. In general, there is no problem in this, you can parse it. System.out.println(); } catch (Exception e) { e.printStackTrace(); } return allrequest; When calling the method, a post request occurs, in the body of which the parameters are entered. After 8-12 seconds, the request comes back, but with a 40% probability it turns out to be an error (SocketTimeoutException). But if you open bybit in the browser, log in to your account, and then make a request in the code, then it passes with 100% probability, but also 8-12 seconds.
Who knows if it is possible to simplify this whole task somehow? Or solve the problem with a high expectation of acceptance of the request and 40% exepshion. (below are the screenshots)
By Bit p2p 3 positions (10 positions in the screenshot, you can change the number in the size parameter)
Postman request
ByBit positions
Источник: https://stackoverflow.com/questions/780 ... it-website
I'm making a web application for personal use.
I need to take the first 3 p2p trading positions from the ByBit site. Namely (USDT-KZT) [Purchase], the price field. Display them on the vp page. I've been suffering for three weeks now. They have a java API, but there is nothing there to work with the p2p trading section. I use Inteleji Idea, postman web, java, maven, okhttp, spring boot.
I found a legal entity where you can make a request (https://api2.bybit.com/fiat/otc/item/online), prescribed in the body:
{"userId":"","tokenId":"USDT","currencyId":"KZT","payment":[],"side":"1","size":"3","page":"1","amount":"","authMaker":false,"canTrade":false}
I checked in postman, the whole page arrives instantly. But there are a lot of extra fields. Next, I poured okhttp into my project, made a method:
public String kztBuy() { double result = 0; String allrequest = ""; OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/json; charset=utf-8"); String json = "{\"userId\":\"\",\"tokenId\":\"USDT\",\"currencyId\":\"KZT\",\"payment\":[],\"side\":\"1\",\"size\":\"3\",\"page\":\"1\",\"amount\":\"\",\"authMaker\":false,\"canTrade\":false}"; RequestBody body = RequestBody.create(json, mediaType); Request request = new Request.Builder() .url("https://api2.bybit.com/fiat/otc/item/online") .post(body) .build(); try { Response response = client.newCall(request).execute(); // java.net.SocketTimeoutException String responseString = response.body().string(); allrequest = responseString; System.out.println("KztBuy result"); System.out.println(responseString); // just over 250 lines here. There is a lot of excess. In general, there is no problem in this, you can parse it. System.out.println(); } catch (Exception e) { e.printStackTrace(); } return allrequest; When calling the method, a post request occurs, in the body of which the parameters are entered. After 8-12 seconds, the request comes back, but with a 40% probability it turns out to be an error (SocketTimeoutException). But if you open bybit in the browser, log in to your account, and then make a request in the code, then it passes with 100% probability, but also 8-12 seconds.
Who knows if it is possible to simplify this whole task somehow? Or solve the problem with a high expectation of acceptance of the request and 40% exepshion. (below are the screenshots)
By Bit p2p 3 positions (10 positions in the screenshot, you can change the number in the size parameter)
Postman request
ByBit positions
Источник: https://stackoverflow.com/questions/780 ... it-website
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Почему на секунду отображается цена со скидкой, а через секунду — полная цена?
Anonymous » » в форуме Php - 0 Ответы
- 39 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Почему на секунду отображается цена со скидкой, а через секунду — полная цена?
Anonymous » » в форуме Php - 0 Ответы
- 34 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Почему на секунду отображается цена со скидкой, а через секунду — полная цена?
Anonymous » » в форуме Php - 0 Ответы
- 24 Просмотры
-
Последнее сообщение Anonymous
-