How to Change Ad Price on Binance Using Python: A Step-by-Step Guide

How to Change Ad Price on Binance Using Python: A Step-by-Step Guide

01 June 2025

Programmatically changing the price of an ad on the Binance exchange

 

Modern cryptocurrency traders are increasingly turning to automation of routine processes. This is especially relevant for P2P traders, where it is important to quickly adapt to market conditions.

In this article, we will show how you can change the price of your ad in Python using the Binance API. We will provide a working example of the code and tell you what you should pay attention to when using it.

 

Why Automate Ad Price Changes?

Automating ad price adjustments allows you to:

  • Quickly respond to market fluctuations

  • 📉 Reduce the risk of financial losses

  • 💼 Optimize business processes

  • Save traders’ time


What Do You Need to Get Started?

Before you begin coding, make sure to:

  1. Obtain your Binance API keys.

  2. Ensure your account is a verified merchant (only merchants can modify ads via the API).

  3. Install the requests, library if it’s not already installed:


pip install requests

 

Code Example: Changing Ad Price

Below is a working Python example:

 


import time
import hmac, hashlib
import requests

class BinanceAPI:
    def __init__(self, api_key, api_secret):
        self.api_key = api_key
        self.api_secret = api_secret

    def getServerTime(self):
        return int(time.time() * 1000)

    def getSignature(self):
        query_string = f"timestamp={self.getServerTime()}"
        return hmac.new(self.api_secret.encode("utf-8"), query_string.encode("utf-8"), hashlib.sha256).hexdigest()

    def getApiKey(self):
        return self.api_key

    def edit_ad(self, adv_num, new_price):
        payload = {'advNo': adv_num, 'price': new_price}
        params = {'timestamp': self.getServerTime(), 'signature': self.getSignature()}
        headers = {"Content-Type": "application/json", "X-MBX-APIKEY": self.getApiKey()}

        res = requests.post('https://api.binance.com/sapi/v1/c2c/ads/update?', headers=headers, json=payload, params=params).json()

        if res.get('code') == -1002:
            print("Access error: Merchant keys required.")
        elif res.get('success'):
            print(f"Price changed: ad {adv_num} - new price {new_price}")
        else:
            print(f"Price change error: {res.get('message', 'Unknown error')}")

        return res

 

Example Usage:

 


if __name__ == '__main__':
    api = BinanceAPI("YOUR_API_KEY", "YOUR_API_SECRET")
    api.edit_ad("1234567890987654321", "46")

 

Possible Errors and How to Fix Them

  • code -1002:  Access denied. Make sure you are using merchant API keys.

  • success: False:  Check if the ad ID is correct.

  • 403 or 401 errors: Authorization issue — verify your API keys.


💡 Ready-Made Solution
We offer a ready-to-use product — P2P Trade Bot for Binance, which already includes the necessary functionality.
This bot automatically tracks competitors’ prices and updates your ad prices to make them more attractive to users.


📌 Conclusion
Changing ad prices on Binance using Python is a powerful tool for automating P2P trading.
It allows you to react quickly to market changes and stay competitive.
This approach is especially useful when building your own trading bot or price monitoring system.



Looking for Integration & API Docs?

Explore our official technical reference for Binance SAPI endpoints, including C2C ads management, deposit/withdrawal logs, and REST API examples.

Explore Binance API Documentation

Comments  

Peter
# Peter 2026-02-22 03:45
Hello,

How can I contact you? My telegram is not working, I cannot reach you there. I need to buy a binance P2P bot, I am a Binance Merchant

Best regards

Peter
Reply | Reply with quote | Quote
Support
# Support 2026-02-22 10:29
Hello Peter,

If you are an active Binance Merchant and interested in a professional P2P automation solution, please contact me through the official channels listed here:

py-dev.top/contact-us

All communication is handled only via the official contacts published on the website.

Best regards,
PyDev
Reply | Reply with quote | Quote

Add comment


Security code
Refresh


💬
Telegram WhatsApp