ibind icon indicating copy to clipboard operation
ibind copied to clipboard

What is a Pre-flight request?

Open jakobovski-arb opened this issue 6 months ago • 3 comments

Thanks for making this awesome library.

I see in the API reference a few statements that a preflight request is required before calling the API. However, I do not see any documentation about how to make said preflight request or what it is.

I think adding some documentation about that would be really helpful. Thanks!

jakobovski-arb avatar Jun 23 '25 19:06 jakobovski-arb

I am guessing the reason it is not documented here is that this is just straight from IBKR’s own documentation, and it is not really explained there either.

My understanding is that a “pre-flight” request is the same thing as the actual request, you just have to make it twice because the first time it will not (or at least is not guaranteed to) return any data. So, the first time you make the request, the server “prepares” to provide the data, and then you make the request the second time, and it gives you the actual data. This sounds idiotic because it is, in fact, idiotic, but that is how it is implemented on IBKR’s side.

Realistically, I think, this library could hide this detail by just repeating the request on behalf of the user. In fact, it does so already e.g. here.

kirelagin avatar Jul 01 '25 20:07 kirelagin

Hey @jakobovski-arb there is a section on Pre-flight requests in the documentation right here: https://github.com/Voyz/ibind/wiki/Advanced-REST#-pre-flight-requests

Where it states:

A number of endpoints indicate that some type of pre-flight is required. A pre-flight request is an additional request that is required to be carried out before the actual request can be made.

And then there's an example.

Is this sufficient for you to understand the concept? Otherwise, can you suggest what else we could add to clarify it?

Voyz avatar Jul 03 '25 16:07 Voyz

@kirelagin please let's try to keep the conversation polite 🙏

Realistically, I think, this library could hide this detail by just repeating the request on behalf of the user.

This has been considered and the decision was made to not do it on behalf of the user. The explanation is outlined in the Wiki documentation:

https://github.com/Voyz/ibind/wiki/Advanced-REST#-pre-flight-requests

In fact, it does so already

Correct, IBind does that in areas where functionality would not have worked without carrying a pre-flight out - primarily within the Advanced API. I think this is reasonable - we do it only where not doing it would have made the logic impossible to carry out. In all other areas pre-flights are left to the user.

There's been a discussion regarding this in #107 if you'd like to share your views on it.

Voyz avatar Jul 03 '25 16:07 Voyz