Getting 403: Forbidden from APIs

Hi Delta Exchange,

I’m not sure whether I should use this platform for discussions.

I have subscribed to your APIs. I’m exploring CCXT library along with self written code to explore APIs.

I’m facing issue while hitting APIs either from library or code. APIs returning status code 403

In my code I added ‘User-Agent: rest-client’ header and it worked. I’m exploring this library too to fasten development but seems like something wrong.

Could you please suggest something on this?

Thanks in advance!

Hi Dharmender, welcome to the community!
will have someone look at this. thanks

1 Like

Hi Dharmender, wlecome to delta exchange. You are not hitting the appropriate endpoint. please use
https://api.india.delta.exchange/v2/ endpoint for trading on delta India. Let me know if you face any further issues.

1 Like

Thank you guys for taking this up on weekend!

1). @ayush.aggrwl I’m hitting the same base URL that you mentioned but still facing same issue. I have attached screenshot of this. This is of .Net so please have a look into highlighted part:

I think this error is coming for all the APIs endpoints. However I tried few. I directly tried CCXT for APIs and was getting same error there as not sure if anything need to setup there as well. I just installed and tried.

Hope this will help!

2). I was exploring Web Socket doc for candlesticks history and live candle data. I need bit help to understand what and how should I use in case if I want to get say hundred candles of history including current candle, say for resolution of ‘5m’ in one go (if it is API hit) or through Web Socket channel. I think this is very normal use case.

3). Consider a use case where user need to get multiple resolution data through web socket then do our current setup allow to get candles of multiple resolution in one subscription. Also, what if user want to get data of multiple symbol in one subscription. I’m thinking of pretty much flexible way to get multiple resolution data of multiple symbols. Indian market brokers provides those.

I hope these two use case makes sense to you. Please let me know if we don’t have current setup like this or I’m going out of standards or something.

Thanks again!

Hi @Dharmender ,

Please find the answers to your queries below:

Some libraries don’t handle missing User-Agent headers by default. Adding the header resolves the issue, so it’s recommended to include it for all requests.
Use REST APIs for historical candlesticks and WebSocket APIs for live candlesticks. According to the API documentation, you can subscribe to multiple channels with different resolutions and symbol lists.
Yes, multiple resolutions can be applied in a single subscription.

Example:

{
    "type": "subscribe",
    "payload": {
        "channels": [
            {
                "name": "candlestick_1m",
                "symbols": ["BTCUSD", "ETHUSD"]
            },
            {
                "name": "candlestick_5m",
                "symbols": ["BTCUSD", "XRPUSD"]
            }
        ]
    }
}

Doc references:
Rest API for historical candles: Doc Reference: Delta Exchange Api
Webscoket for live candles: Delta Exchange Api

Hey guys,

I am also getting the same 403 forbidden error when trying to get historical data from this endpoint - https://api.india.delta.exchange/v2/history/candles

This is the complete message that I receive…
Request blocked. We can’t connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.

When I access the same URL with the timestamps in the browser, I do get the candle data. So why is it not working when accessing from code? I am using cURL with PHP.

Hi Karanveer,

You need to pass the “user-agent” header in the request.
As you are using php to query data, you will need to ensure that you are adding the user-agent header in the request.

Reference: How to add user agent to the request using php: PHP cURL how to add the User Agent value OR overcome the Servers blocking cURL requests?

Even after adding the user-agent header, if you get the same error, then please share the x-amz-id that appears on the screen with the 403 forbidden error.

Hi everyone here,

I was also getting the same 403 error. request blocked.
By adding the user agent. i got that error resolved. now i am getting the response as
“error”:“unauthorized”,“success”:false

where could i be wrong. i have mentioned proper api key and secret at the required places.

Hi @sourabhg

Unauthorized means either the api key/secret pair is wrong or the host is wrong, like host is of delta global and api key/secret is of delta india.

Please confirm if this is the case and share the code if the issue still persists.

I am able to successfully place the orders.
Thanks for the support.

1 Like