API ISSUE

Emergency please help me......

Sir,

successfully received a ACCESS TOKEN, But when try to fetch market datas using it, it seems an error.....

The code i used....

import requests

# Your Access Token (Update it if expired)

access_token = ""

# API Endpoint

url = "https://api.fyers.in/api/v2/markets/history"

# Payload (Ensure correct format)

params = {

"symbol": "NSE:NIFTY50-INDEX", # Example symbol (Change as needed)

"resolution": "5", # Timeframe: 1, 3, 5, 15, 30, 60, D, W, M

"date_format": "1", # 1 = Timestamp, 0 = Readable Date

"range_from": "2024-02-15", # Start date (YYYY-MM-DD)

"range_to": "2024-02-23", # End date (YYYY-MM-DD)

"cont_flag": "1" # 1 for continuous contract (Futures)

}

# Headers

headers = {

"Authorization": f"Bearer {access_token}"

}

# Send GET request (Use GET, not POST)

response = requests.get(url, headers=headers, params=params)

# Check response

if response.status_code == 200:

data = response.json()

print("✅ Historical Data Fetched Successfully!")

print(data)

else:

print(f"❌ Error: {response.status_code} - {response.json()}")

Please help me...

2 replies