dblock / iex-ruby-client

IEX Finance API Ruby Client
MIT License
118 stars 60 forks source link

logo url return type #73

Closed chris19960730 closed 4 years ago

chris19960730 commented 4 years ago

Hi, I am trying to get the company's logo image address using client.logo("name").url. However, the result seems like encoded string, not the example shown as https://storage.googleapis.com/iex/api/logos/XXXX

Here is the rails console trying to get the logo of Apple. image Can you help me with that? Much thanks!

bguban commented 4 years ago

Works well for me:

client = IEX::Api::Client.new
logo = client.logo('AAPL')
logo.url # "https://storage.googleapis.com/iexcloud-hl37opg/api/logos/AAPL.png"

Maybe it's a problem with specific company. What ticker do you use?

chris19960730 commented 4 years ago

I tested several companies like 'AAPL', 'GOOG', 'MSFT'. All the URL I got is encoded like below: image

By the way, My IEX account is in a free plan, is that limit me to access the logo?

Thanks!

bguban commented 4 years ago

Sorry for the delay. I checked it with my free public token and it works well. Looks like something in your project substitutes the response or breaks JSON parsing. You can try to do the same manually to find the step where it breaks.

# bash
curl "https://cloud.iexapis.com/v1/stock/msft/logo?token=your_token_here"
# ruby console
Faraday.get('https://cloud.iexapis.com/v1/stock/msft/logo', token: 'your_token').body

JSON.parse('{"url":"https://storage.googleapis.com/iexcloud-hl37opg/api/logos/MSFT.png"}')
dblock commented 4 years ago

@chris19960730 If you have a repro for us we can take a look! Closing otherwise for now.

dblock commented 4 years ago

This happens because you're running against IEX sandbox and that is the data returned from the API. According to that doc:

Test data randomization

Data returned from sandbox API calls is scrambled and should not be used for purposes outside of testing. However, test calls return the same properties and data types as they will in production, which allows for full functionality testing.

Many endpoints that return a date — such as Historical Prices — will have the date accurately returned in the sandbox environment, so as to allow users to test out charting functionality within their application or project.

dblock commented 4 years ago

I'm going to stop recommending the sandbox environment as the default in the README, it confuses new users, https://github.com/dblock/iex-ruby-client/pull/75.