OpenAPI

On or shortly after April 1st. 2022 we will be introducing HTTP/2 and Akamai acceleration for Saxo Bank OpenAPI.

We are doing this to optimize performance!

About Akamai

Akamai is a network acceleration provider, which ensures faster and more reliable connectivity from network endpoints to Saxo Banks data centers. We are already using Akamai network acceleration for all connections outside of Europe. After the change we will also accelerate connection for all clients residing within Europe.

About HTTP/2

HTTP/2 is the successor of HTTP/1.1.

With HTTP/2 multiple bidirectional streams are multiplexed over a single TCP connection. Each stream can carry a request/response pair, and multiple requests to a server can be made by using multiple streams.

This functionality essentially provides standard support for "batching" of requests, and it means that going forward you will get the benefit of parallel execution of requests without using our current proprietary batching mechanism.

More info: https://arstechnica.com/information-technology/2015/02/http2-finished-coming-to-browsers-within-weeks/

What will be the change

Saxo Bank will introduce HTTP/2 for the OpenAPI in April 2022. For countries in Europe this protocol upgrade is combined with a move to Akamai Edge.

1. What to expect

The move to Akamai results in better request/response performance. In addition, the responses are gzipped, where in the past it was just plain JSON. This is very standard behavior and most applications would need no change to handle this. But some do - unfortunately.

Once we enable HTTP/2 you may find that your application client library will start sending requests in parallel, possibly resulting in a better experience because of the shorter time to complete all of the calls, which were previously sent in sequence. This is also very standard behavior, and it "should" not break your client.

2. What to do

We strongly recommend that you already now verify that your application will work smoothly after the transition. For this purpose we have prepared a new host: gateway.home.saxo instead of gateway.saxobank.com. You may use this domain and url to test if your app is ready for the upgrade! After the test, move back to gateway.saxobank.com.

3. What to fix

Browsers support HTTP/2 since 2015. But C# and other languages might have issues with this change.

If your app breaks because of receiving gibberish JSON responses, a fix is required. You might have this code (C#) for parsing a response:

    HttpClient httpClient = new HttpClient(new HttpClientHandler()
    {
        AllowAutoRedirect = false
    });
    // Disable Expect: 100 Continue according to https://www.developer.saxo/openapi/learn/openapi-request-response
    // In our experience the same two-step process has been difficult to get to work reliable, especially as we support clients world wide, 
    // who connect to us through a multitude of network gateways and proxies.We also find that the actual bandwidth savings for the majority of API requests are limited, 
    // since most requests are quite small.
    // We therefore strongly recommend against using the Expect:100 - Continue header, and expect you to make sure your client library does not rely on this mechanism.
    // See: http://chrisoldwood.blogspot.com/2016/12/surprising-defaults-httpclient.html for further explanation.
    httpClient.DefaultRequestHeaders.ExpectContinue = false;

This code must be changed, so it handles GZip content:

    HttpClient httpClient = new HttpClient(new HttpClientHandler()
    {
        AllowAutoRedirect = false,
        AutomaticDecompression = System.Net.DecompressionMethods.GZip
    });
    // Disable Expect: 100 Continue according to https://www.developer.saxo/openapi/learn/openapi-request-response
    // In our experience the same two-step process has been difficult to get to work reliable, especially as we support clients world wide, 
    // who connect to us through a multitude of network gateways and proxies.We also find that the actual bandwidth savings for the majority of API requests are limited, 
    // since most requests are quite small.
    // We therefore strongly recommend against using the Expect:100 - Continue header, and expect you to make sure your client library does not rely on this mechanism.
    // See: http://chrisoldwood.blogspot.com/2016/12/surprising-defaults-httpclient.html for further explanation.
    httpClient.DefaultRequestHeaders.ExpectContinue = false;


This code is backwards compatible with the current OpenAPI responses, so you are urged to make this change as soon as possible.

4. When you have more time

The HttpClient from the sample above doesn't support HTTP/2. This makes the server fallback to HTTP/1.1:

  Console.WriteLine(request.RequestUri + " is using HTTP/" + response.Version);

Make sure your code accepts HTTP/2 to get the benefits of this upgrade.

  HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, url)

  {

      Version = new Version(2, 0)  // Make sure HTTP/2 is used, if available

  };


When your app is on HTTP/2, there is no need for batching requests anymore. That feature will not be removed straight away, but Saxo will eventually move away from batch endpoints.