gem 'iex-ruby-client' how to set up
- Add the 'iex-ruby-client' gem to your Gemfile:
ruby
gem 'iex-ruby-client'
- Run the following command to install the gem:
bundle install
- Require the 'iex-ruby-client' gem in your Ruby file:
ruby
require 'iex-ruby-client'
- Initialize the IEX::Api::Client with your API key:
ruby
client = IEX::Api::Client.new(
publishable_token: 'your_publishable_token',
secret_token: 'your_secret_token',
endpoint: 'https://cloud.iexapis.com/v1' # optional, use if different from default
)
Replace 'your_publishable_token' and 'your_secret_token' with your actual IEX Cloud API tokens.
- Use the client to make API requests. For example, to get the quote for a specific symbol:
ruby
quote = client.quote('AAPL')
puts "Latest Price for AAPL: $#{quote.latest_price}"
Replace 'AAPL' with the desired stock symbol.
Refer to the official documentation for more details and available methods:
- IEX Cloud API Documentation
Ensure you comply with IEX Cloud's terms of service and use the appropriate API token levels for your needs.