Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major refactor of code to eliminate the need to provide apikey on every function call #49

Closed
wants to merge 3 commits into from

Conversation

dwrod
Copy link

@dwrod dwrod commented Jul 8, 2024

This substantive PR changes all functions within the module to eliminate the need to call apikey as part of every function call. Instead users will need to add an environment variable named FMP_API_KEY which will automatically be read.

@psohn
Copy link

psohn commented Jul 19, 2024

Not a contributor here but I'm wondering if this could be done with backwards compatibility in mind. E.g. keep apikey as an optional param and if it's not supplied, it takes the env variable.

@dwrod
Copy link
Author

dwrod commented Jul 19, 2024

Yes fair point @psohn . I've amended the commit accordingly. cc @daxm

EDIT: This version keeps apikey as optional parameter.
:return: A list of dictionaries.
"""
path = f"commitment_of_traders_report/list"
query_vars = {"apikey": apikey}
query_vars = {"apikey": apikey} if apikey else {"apikey": API_KEY}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
query_vars = {"apikey": apikey} if apikey else {"apikey": API_KEY}
query_vars = {"apikey": apikey or API_KEY}

nit
should work and be a little more concise but doesn't really matter

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also wondering (maybe not in the scope of this work) if an error should be raised if neither an apikey nor API_KEY are supplied

fmpsdk/alternative_data.py Outdated Show resolved Hide resolved
Co-authored-by: Philip Sohn <46043263+psohn@users.noreply.github.com>
@vquelque
Copy link

+1 for merging this 🙏

@dwrod dwrod closed this Oct 28, 2024
@dwrod dwrod deleted the refactor/code branch October 28, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants