Error: 429 - {“data”:{“805”:“Too many requests. Further requests may result in the user being blocked.”},“status”:“failed”} @Hardik i have paid you guys and this happen after making code just testing for the code 5 to 6 times
import requests
import json
import pandas as pd
API endpoint
Replace with your credentials
headers = {
“access-token”: “YOUR_ACCESS_TOKEN”, # Access token generated via Dhan
“client-id”: “YOUR_CLIENT_ID”, # Your client-id from Dhan
“Content-Type”: “application/json”
}
Request payload
payload = {
“UnderlyingScrip”: 3499, # Example: NIFTY ID (replace with required security ID)
“UnderlyingSeg”: “IDX_I”, # Use NSE_EQ for stocks, IDX_I for index options
“Expiry”: “2025-08-28” # Expiry date in YYYY-MM-DD format
}
Send POST request
response = requests.post(url, headers=headers, data=json.dumps(payload))
Check response
if response.status_code == 200:
result = response.json()
option_chain = result[“data”][“oc”]
# Flatten into list of rows
rows = []
for strike, contracts in option_chain.items():
for option_type in ["ce", "pe"]:
if option_type in contracts:
d = contracts[option_type]
row = {
"strike": float(strike),
"type": option_type.upper(),
"last_price": d.get("last_price"),
"oi": d.get("oi"),
"volume": d.get("volume"),
"iv": d.get("implied_volatility"),
"delta": d.get("greeks", {}).get("delta"),
"theta": d.get("greeks", {}).get("theta"),
"gamma": d.get("greeks", {}).get("gamma"),
"vega": d.get("greeks", {}).get("vega"),
"bid_price": d.get("top_bid_price"),
"bid_qty": d.get("top_bid_quantity"),
"ask_price": d.get("top_ask_price"),
"ask_qty": d.get("top_ask_quantity"),
}
rows.append(row)
# Convert to DataFrame
df = pd.DataFrame(rows)
display(df) # Show DataFrame nicely in Google Colab
else:
print(f"Error: {response.status_code} - {response.text}")