Ethereum: Binance API P2P I can´t see the SELL information using Python

Ethereum: Binance API P2P Purchase Information Retrieval

As a popular and widely-used platform for cryptocurrency trading, Binance has made its API publicly available. However, when it comes to retrieving purchase data from the platform using Python, users often encounter issues. In this article, we will explore why you may not be able to see the SELL information and provide steps to troubleshoot and resolve the problem.

Why can’t I access Binance API P2P data?

The Binance API has several limitations when it comes to retrieving specific types of data from the platform. Specifically:

  • The orders endpoint returns a list of all orders, including buys, but not specifically SELL information.

  • To retrieve SELL information, you need to use a different endpoint that provides a more detailed view of transactions.

P2P Purchase Data Retrieval using Python

To retrieve P2P purchase data from Binance using Python, we will use the requests library. We will first try to connect to the API and then use a custom function to extract the desired data.

import requests

import json








Ethereum: Binance API P2P I can´t see the SELL information using Python

Set your Binance API credentials

api_key = 'YOUR_API_KEY'

api_secret = 'YOUR_API_SECRET'


Define the URL for the P2P endpoint

url = f'


Set a flag to indicate whether we are connecting to the P2P endpoint

connect_p2p = True

def get_p2p_orders(symbol, limit):


Try to connect to the P2P endpoint

if not connect_p2p:

print('Connecting to P2P endpoint...')

try:

response = requests.get(url)


Parse JSON response

data = json.loads(response.text)


Extract SELL information from orders

sell_orders = []

for order in data['book']['orders']:

if 'side' == 'buy':

sell_orders.append({

'symbol': symbol,

'amount': float(order['amount']),

'time': int(order['time']) // 1000

Convert to seconds

})

return sell_orders

except requests.exceptions.RequestException as e:

print(f'Error connecting to P2P endpoint: {e}')

return []


Test the function with your BINARYSCAPE symbol

symbol = 'YOUR_BINARYSCAPE_SYMBOL'

sell_orders = get_p2p_orders(symbol, 10)


Print the results

for order in sell_orders:

print(order)

Troubleshooting Tips

  • Check API documentation: Ensure you are using the correct endpoint and parameters for your BINARYSCAPE symbol.

  • Verify API credentials: Double-check your Binance API credentials and ensure they match the ones provided in the requests library.

  • Use a logging mechanism: Print debug messages to identify issues with the API connection or request processing.

  • Test in different environments: Try testing the function in various Python environments, including local development servers or cloud platforms like Heroku.

By following these steps and troubleshooting tips, you should be able to successfully retrieve P2P purchase data from Binance using Python. If you continue to encounter issues, please provide more details about your setup and environment for further assistance.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top