Jump to content
  • 0

Another error in fetching data.



Hi, I have also tried the following Python code to extract data. 

import requests
# Set your API credentials
api_key = "xx"
account_id = 'xx'
# Set the API endpoint and parameters
endpoint = 'https://demo-api.ig.com/gateway/deal/session'
headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'X-IG-API-KEY': api_key,
    'Authorization': f'Bearer {account_id}',
params = {
    'resolution': 'D',  # Daily resolution
    'epic': 'CS.D.BHP.LON.IP',  # BHP market identifier
    'pageSize': 10,  # Number of prices to fetch
# Make the API request
response = requests.get(endpoint + 'prices', headers=headers, params=params)
# Check if the request was successful
if response.status_code == 200:
    # Extract the close prices from the response
    data = response.json()
    close_prices = [price['closePrice'] for price in data['prices']]
    print('Error occurred:', response.text)

It gives me the following error message. 

Error occurred: <html><head><title>Page Not Found</title><h3>Error 404</h3><h3>Sorry, the requested page is not available.</h3></body></html>

So basically, I am not sure how to extract price data via the API using Python. 

Link to comment

1 answer to this question

Recommended Posts

  • 0

Judging from this code, you would query the non-existing endpoint "/sessionprices", which indeed does not exist, so the 404 is valid.

You need to create a /session first, then you can query price data.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • image.png

  • Posts

    • I'm currently bullish on AI project tokens, especially on Bitget, and I'm excited about their symbiotic relationship with blockchain technology, which is driving financial inclusion and innovation. Projects like SORA, SingularityNET's AGIX, The Graph (GRT), and Nebula AI's NMT are leading the way in transformative advancements across various sectors.
    • I trade leveraged futures on Binance so I'm going to miss them, not that much though cos I also use Bitget exchange, and they have high liquidity and low fees, So I will just move my funds there and continue leveraged trading.
    • If you've tried using Ethereum, you know it can get slow and expensive. Think of Starknet as a helper that makes everything faster and cheaper. It does this by taking a bunch of transactions, squishing them into one, and then processing that one. This means more transactions can happen at once without clogging up the system. For people making apps on the blockchain (they call these dApps), Starknet is like a dream come true because it lets their apps handle a lot more users without slowing down. It also gives them the freedom to make their apps work just how they want, making things better for users. When it comes to making money, Starknet charges fees to use its network and lets people 'stake' their coins – that's like putting your money in a savings account that helps the network run, and you get a little reward for that. So, what do you think about Starknet? It's all about helping Ethereum handle more action without any hassle. Could be a big deal for how we use digital money, right?
  • Create New...