Get Product Book

Great addition, however, the fields are including a ., which cannot be converted directly as a python attribute (I suspect only NamedTuple would work).

My whole interface relies on Pydantic to seamlessly create requests and receive responses, as well as validating the implementation against your web documentation for requests, responses as well as websocket and Changelog entries (that’s how I realized the addition)

For now, I guess I’ll have to use a Field alias and patch the web verification

Thank you @Sandy @rishabh

Hey @MementoMori, Thank you for sharing your feedback on the Get Product Book endpoint. We have let the internal team know about this.

1 Like

Hi @rishabh , Thank you. This break in convention is quite bothersome when using a Pydantic class as . is a structure navigator in python (at least). My code that verifies the correct implementation against the description on the web documentation by generating pseudo-random requests and validating them,

This would not be needed actually, if there was a Sandbox available

fails when trying to decipher the structure of template request with:

                if not isinstance(attr_list, list):
                    attr_list = [a for a in re.split(r'[\[\].]', attr_list) if a]

This splits single_product_book.limit into single_product_book, as if the structure was:

{
   single_product_book:
   {
       limit: ...
...

which does not exist.

It would be great if this gets corrected before too many people start changing their implementation, true NamedTuple should work, but Dict, TypedDict, dataclass, ect will not work. It is very odd that there is any benefit to using this uncommon convention. Does FastAPI works with this?

Anyway, I have fixed most of my code and going to foolproof that part for sake of productivity, but please consider this carefully.

Thank you and Regards

Hi @rishabh , Actually, come to think about it more, could this not be the case that the internal structure for this request is:

{
   "single_product_book":
   {
      "product_ids": "...",
      "limit": ...
   },
   "best_bid_asks":
   {
      "product_ids":
      [
         "..."
      ]
   }
}

But then because it is a “GET”, these gets expanded on the URL?

Why not have 2 endpoints? best asks/bids are already available on another endpoint it seems to me

Thank you and Regards

Hi @rishabh , LMAO, it took you less time to fix and update the documentation then me babbling around. Somehow, I decided to hit Reload … Et voila!.
That looks great, I’ll implement the new Request and Response

Thank you and Regards

We are glad that it all worked well for you, @MementoMori! Thank you.