Api issue for generate order

import hashlib
import hmac
import json
import time
import requests

api_key = ‘’
api_secret = ‘’

Create the signature

def generate_signature(method, endpoint, payload):
timestamp = str(int(time.time()))
signature_data = method + timestamp + endpoint + payload
message = bytes(signature_data, ‘utf-8’)
secret = bytes(api_secret, ‘utf-8’)
hash = hmac.new(secret, message, hashlib.sha256)
return hash.hexdigest(), timestamp

Prepare the order data

order_data = {
‘product_id’: 27, # Product ID for BTCUSD is 27
‘size’: 1,
‘order_type’: ‘market_order’,
‘side’: ‘buy’
}

Convert the order data to JSON format

body = json.dumps(order_data, separators=(‘,’, ‘:’))

method = ‘POST’
endpoint = ‘/v2/orders’

Generate the signature

signature, timestamp = generate_signature(method, endpoint, body)

Add the API key and signature to the request headers

headers = {
‘api-key’: api_key,
‘signature’: signature,
‘timestamp’: timestamp,
‘Content-Type’: ‘application/json’
}

Send the request

response = requests.post(‘https://api.delta.exchange/v2/orders’, headers=headers, data=body)

Parse the response

order_response = response.json()

Optionally print the response

print(order_response)

                                                                                  when i run this code for buying show this message"{'error': {'code': 'invalid_api_key'}, 'success': False}                                                                   bt api key is correct

Hi, you are putting the wrong url, use ```
https://api.india.delta.exchange/v2/orders

Hi, can you please help with this?
I am having issues when trying to place a market order in my demo account, getting error (tried with buy and sell),

when I am buying:
‘result’: {‘reduce_only’: False, ‘cancellation_reason’: ‘order_size_not_available_in_orderbook’,

when I am selling:
{‘error’: {‘code’: ‘immediate_liquidation’}, ‘success’: False}

I am trying with ‘product_symbol’: ‘P-BTC-98000-280225’,

here is my order data code:
order_data = {

‘product_id’: 124088, # Product ID for BTCUSD is 27

‘size’: 1,

‘order_type’: ‘market_order’,

‘side’: ‘sell’

}

Hi @vijaykiran,

To effectively test strategies and get familiar with the platform, we recommend using a live production account with a small balance rather than a demo account, as demo environments may not accurately reflect real-world trading conditions.

  • Buying: If you encounter the error ‘order_size_not_available_in_orderbook’, try reducing the order size or placing a limit order instead of a market order. Additionally, check the order book liquidity using: /v2/l2orderbook/{symbol} and adjust your order accordingly.

  • Selling: If you receive the ‘immediate_liquidation’ error, check the order book for liquidity and consider placing a limit order at a defined price instead of a market order.

Let us know if you need further assistance!