Recent

Author Topic: Anyone working with quotes from Deutsche Börse & CME?  (Read 636 times)

Nicole

  • Hero Member
  • *****
  • Posts: 1303
Anyone working with quotes from Deutsche Börse & CME?
« on: April 14, 2025, 09:35:44 am »
Here is something which sounds too good to be true (a bad sign, I know):
https://console.developer.deutsche-boerse.com/

A free API for getting quotes from half Europe and the CME. In other words, the most important quotes of the world, for free. The quotes can be addressed by a language,  similar to SQL.

The only disadvantage: It does not work for me.

Yes, I have an API-key but am not sure, how to put it into the url.

What I usually work with is this below (the response is not json here)
The url of the documenation how I read it does not even give a positive response, if I key it into the browser. I am clueless.

Code: Pascal  [Select][+][-]
  1. // Input: url mit Datenanbieter und korrektem Anforderungslink, Ooutput: json-String
  2. function TAktienkurse_holen.GetUrlJsonResponse(Url: string): string;
  3. var
  4.   HttpClient: TFPHTTPClient;
  5.   Json_Response: string;
  6.   Json_Obj: TJSONObject;
  7.  
  8. begin
  9.   HttpClient := TFPHTTPClient.Create(nil);
  10.  
  11.     // Sende die Anfrage und erhalte die Antwort als String
  12.     Json_Response := HttpClient.Get(Url);
  13.  
  14.     // Prüfen, ob die Antwort im JSON-Format vorliegt
  15.     Json_Obj := TJSONObject(GetJSON(Json_Response));
  16.  
  17.     // Wenn das Parsen erfolgreich war, gebe die Antwort im JSON-Format zurück
  18.     Result := Json_Obj.FormatJSON;
  19.  
  20.  
  21.     HttpClient.Free;  // Stelle sicher, dass das Objekt freigegeben wird
  22.  
  23. end;

dseligo

  • Hero Member
  • *****
  • Posts: 1651
Re: Anyone working with quotes from Deutsche Börse & CME?
« Reply #1 on: April 14, 2025, 11:31:52 am »
Yes, I have an API-key but am not sure, how to put it into the url.

It says (here: https://docs.developer.deutsche-boerse.com/docs/consumer/getting-started/consume) that:
To call an API, pass the API key as an HTTP header named: X-DBP-APIKEY

So, try following:

Code: Pascal  [Select][+][-]
  1. ...
  2. const APIKey = 'xxxxxxxxxxx';
  3. ...
  4.   HttpClient := TFPHTTPClient.Create(nil);
  5.   HttpClient.AddHeader('X-DBP-APIKEY', APIKey);

You might also want to add couple of try..finally and try..except.

Nicole

  • Hero Member
  • *****
  • Posts: 1303
Re: Anyone working with quotes from Deutsche Börse & CME?
« Reply #2 on: April 14, 2025, 12:03:01 pm »
Thank you for your quick reply. This looks great.
Please more slowly for somebody who has no idea of the matter.

What is a
"HttpClient.AddHeader"?

I know, how html is written, with head and body.
I know a little bit, how json works (in the meanwhile).
I know, what a url looks alike and a "&" etc. and there is a response in my browser.
Of APIs I have very little idea.

This "header" I cannot insert in the grid of my small knowledge.


dseligo

  • Hero Member
  • *****
  • Posts: 1651
Re: Anyone working with quotes from Deutsche Börse & CME?
« Reply #3 on: April 14, 2025, 12:14:25 pm »
This is not the header of HTML document, this is the header of HTTP request.

https://en.wikipedia.org/wiki/List_of_HTTP_header_fields

 

TinyPortal © 2005-2018