API binance P2P I only access a part (only the BUY) and not all of it (BUY and SELL)

Viewed 11296

I am trying to access the data on this Binance website. It is the P2P: https://p2p.binance.com/en/trade/buy/USDT.

For BUY I am using this in python3 (I am getting the data correctly for this section):

import requests


headers = {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
    "Cache-Control": "no-cache",
    "Connection": "keep-alive",
    "Content-Length": "123",
    "content-type": "application/json",
    "Host": "p2p.binance.com",
    "Origin": "https://p2p.binance.com",
    "Pragma": "no-cache",
    "TE": "Trailers",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0"
}

data = {
  "asset": "USDT",
  "fiat": "ARS",
  "merchantCheck": False,
  "page": 1,
  "payTypes": [],
  "publisherType": None,
  "rows": 50,
  "tradeType": "BUY"
}


r = requests.post('https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search', headers=headers, json=data)
print(r.text)

But then when I want to access this part of the page: https://p2p.binance.com/en/trade/sell/USDT (to SELL), I can't do it. Because when I change in the data the following: "tradeType": "SELL", it still brings me the same values of the BUY. It never brings me the SELL data.

And I am not finding out why yet.

4 Answers

Instead of sending requests to the website itself you can send a request to the source itself. If you check your console while the website loads results you will notice it sends a request to https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search which returns an array of trade details. I believe this is what you need.

Expanding on the accepted answer

https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search

POST Fields

    "asset": "USDT",
    "fiat": "NGN",
    "merchantCheck": true,
    "page": 1,
    "payTypes": ["BANK"],
    "publisherType": null,
    "rows": 20,
    "tradeType": "SELL",
    "transAmount":  "5000"
}

asset: Currently available asset USDT, BTC, BNB, BUSD, ETH, DAI.

fiat: Its long, visit sanchezmarcos.

merchantCheck: Well i don't know its use, but value is null, true, false.

page: The endpoint is paginated.

payTypes: An array of payment types example BANK, GoMoney, CashDeposit etc.

payTypes depend on fiat used so you might not see some of these but there's a lot of payment types.

publisherType: I'm only aware of merchant.

row: Amount of rows from 1 - 20.

tradeType: BUY or SELL.

transAmount: Filter merchant by amount.

Note The api is for binance internal operation which means it can change any time.

I did check the result of the api call and confirm the data is correct except tradeType, you did nothing wrong

You need use it:

client.get_c2c_trade_history() and go to ['data'] Next step is work like json or dateframe, the column that you need have the header 'tradeType'

Related