kite api is not fetching any data

rajni
rajni edited April 17 in API clients
It is giving error status as 400
I tried the following code to check the profile.
import requests


# Your Kite API key and access token
api_key = '' '
access_token = '' '

# Kite API endpoints
base_url = 'https://api.kite.trade'
profile_url = f'{base_url}/user/profile'

# Headers with authorization
headers = {
'X-Kite-Version': '3',
'Authorization': f'token {access_token}'
}

# Function to check API status
def check_api_status():
try:
response = requests.get(profile_url, headers=headers)
if response.status_code == 200:
print("Kite API is working. User profile fetched successfully.")
print("User Profile:", response.json())
else:
print(f"Failed to fetch user profile. Status Code: {response.status_code}")
except Exception as e:
print(f"Error occurred: {e}")

# Check API status
check_api_status()

Sign In or Register to comment.