Skip to content

[Enhancement/Bug Fix] Tiingo Backend Uses JSON Which Conflicts With Python Boolean Calls #600

@GenusGeoff

Description

@GenusGeoff
  • Tiingo Python version: 0.13
  • Python version: 3.8.8
  • Operating System: Windows/Ubuntu 18.04

Description

Made a call to IEX Intraday data enabling the "&afterHours=True" parameter. The problem is with the Pythonic need for True and False to be capitalized which conflicts with JSONs need to use "true" and "false" lowercase.

I expected the API call to return fruitful but instead returned None.

What I Did

I suggest that we utilize a JSON.dump(url_parameters) going forward to be better able to adapt to changes in the Tiingo API. A simple function could be created that is called before returning the URL string to the requests library.

Please see an excerpt from an email exchange from @tiingo:

Interesting little 'bug' or 'feature': When getting intraday IEX quotes and choosing afterHours=true or afterHours=false the boolean MUST BE lowercase which is an interesting little incompatibility with Python that likes Booleans to be either True or False. So, I can workaround with using an encapsulated 'true' or 'false' but as you continue making your API v2, this might be something worth examining.

@tiingo response:

This behavior is intentional

REST APIs typically take data in JSON format - the lowercase true/false is a function of following this spec (JSON booleans are lowercase).

In the backend, the json is parsed into Python using a standard json parsing library.

This is a function of following standard web practices - if you want to send a request to the API, you could use a standard json encoding library (ujson, simplejson for example). then do json.dumps(pythonObj) to get the JSON representation

I believe it's only a matter of time, as in my attempted enhancement, before the V2 API or later functionality exposes this "bug" in the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions