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

How can I request only a part of the response when using client.get_search_instrument(query_string=)? #18

Closed
fabmeyer opened this issue Feb 28, 2022 · 2 comments

Comments

@fabmeyer
Copy link

Is it possible to request only a part of the response dict?

With requests I can write requests.get(f'https://eodhistoricaldata.com/api/fundamentals/{ticker}.us?api_token={eod_api}&filter={eod_filter}') with eod_filter = 'General::Code,Name,Description' to get only a part of the response.

It would be nice to have this possibility with client.get_search_instrument() too.

@LautaroParada
Copy link
Owner

Hi @fabmeyer ,

As far as I understand, do you want to filter the response fields of get_search_instrument by explicitly declaring the parameters? Like the get_fundamental_equity method (can you confirm if that is correct?)

# Stock - request the quarterly statements
resp = client.get_fundamental_equity('AAPL.US', filter_='Financials::Balance_Sheet::quarterly')

If my understanding of your question is correct, I'm afraid it is not possible to include the filter. The documentation says that this method (and consequently the URL) only allows the following parameters: query_string, limit, bonds_only, exchange, type (This one is redundant with bonds_only, I do not recommend type). This characteristic is by default, and I can't do anything.

Despite that, If you still want to filter by some desired fields, the following code may help you:

import os
# load the key from the environment variables
from eod import EodHistoricalData
# import the key from the environment variables
api_key_eod = os.environ['API_EOD']
# Create the instance. You can always write directly the API key, but that's not secure.
client = EodHistoricalData(api_key_eod)

# I'm going to assume that you want companies related to blockchain
import pandas as pd
print( pd.DataFrame(client.get_search_instrument(query_string='blockchain'))[['Code', 'Name']] )

If the EOD API implements this optionality in the future, I will certainly include it in the get_search_instrument method.

I hope it helps.

@fabmeyer
Copy link
Author

fabmeyer commented Mar 1, 2022

OK thanks for your time and effort.

@fabmeyer fabmeyer closed this as completed Mar 1, 2022
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

No branches or pull requests

2 participants