SDKs overview

IEX Cloud offers Software Development Kits (SDKs) and client libraries designed to streamline integration with its financial data API. These tools encapsulate the underlying RESTful API calls, handling authentication, request formatting, and response parsing, which allows developers to focus on application logic rather than API mechanics. The official SDKs are maintained directly by IEX Cloud, ensuring compatibility and access to the latest API features and data endpoints. Community-developed libraries also exist, providing broader language support and alternative approaches to interacting with the IEX Cloud platform.

Using an SDK can significantly reduce development time and potential errors compared to making raw HTTP requests. For instance, an SDK typically manages API key handling securely and provides type-safe methods for accessing specific data points like historical stock prices or company balance sheets. This approach is common among API providers to enhance the developer experience, as seen with platforms like Stripe's API libraries or Twilio's Helper Libraries, which offer similar benefits for their respective services.

Official SDKs by language

IEX Cloud provides official SDKs for two widely used programming languages: Python and JavaScript. These libraries are developed and maintained by IEX Cloud to ensure optimal performance, reliability, and alignment with the API's capabilities. They are recommended for most integration projects due to their direct support from the platform. These SDKs are designed to abstract away the complexities of HTTP requests, JSON parsing, and error handling, providing a more idiomatic way to interact with the IEX Cloud API.

Language Package Name Installation Command Maturity
Python iexfinance pip install iexfinance Stable
JavaScript iexcloud or iexcloud-js npm install iexcloud or npm install iexcloud-js Stable

The Python SDK, iexfinance, provides a comprehensive set of functions for accessing various IEX Cloud endpoints, including real-time quotes, historical data, company fundamentals, and economic indicators. It integrates well within data science workflows and financial modeling applications. The JavaScript SDK, often found under package names like iexcloud or iexcloud-js, is suitable for web-based applications, Node.js backend services, and client-side integrations, offering asynchronous methods for data retrieval. Developers can find detailed documentation and usage examples for these official SDKs on the IEX Cloud API documentation portal.

Installation

Installing the IEX Cloud SDKs is typically straightforward, leveraging standard package managers for each respective language. Before installation, developers should ensure they have the correct environment set up, including the appropriate version of Python or Node.js.

Python SDK (iexfinance)

The Python SDK can be installed using pip, the Python package installer. It is recommended to use a virtual environment to manage dependencies and avoid conflicts with other projects.

  1. Create a virtual environment (optional but recommended):
    python -m venv iex_env
    source iex_env/bin/activate  # On Windows, use `iex_env\Scripts\activate`
    
  2. Install the iexfinance package:
    pip install iexfinance
    
  3. Verify installation:
    import iexfinance
    print(iexfinance.__version__)
    

For more advanced features or specific versions, developers can refer to the official iexfinance documentation for detailed installation instructions and dependency requirements.

JavaScript SDK (iexcloud or iexcloud-js)

The JavaScript SDK is installed via npm (Node Package Manager), which is typically bundled with Node.js installations.

  1. Ensure Node.js and npm are installed:
    node -v
    npm -v
    
    If not installed, download from the Node.js official website.
  2. Initialize a new project (optional):
    mkdir my-iex-app
    cd my-iex-app
    npm init -y
    
  3. Install the IEX Cloud JavaScript package:
    npm install iexcloud
    
    Or, if using an alternative community package:
    npm install iexcloud-js
    
  4. Verify installation:
    const iex = require('iexcloud');
    console.log('IEX Cloud JS SDK installed');
    

The specific package name may vary slightly depending on the maintainer or version, so checking the IEX Cloud developer documentation for the most current recommendation is advisable.

Quickstart example

These quickstart examples demonstrate how to fetch basic stock data using the official IEX Cloud SDKs. Before running these examples, ensure you have an IEX Cloud API key (publishable token) and set it as an environment variable or pass it directly.

Python example: Get real-time stock quote

This Python snippet demonstrates how to retrieve the latest quote for a specific stock ticker using the iexfinance library. This example assumes your publishable token is available as an environment variable named IEX_CLOUD_PUBLISHABLE_TOKEN.

import os
from iexfinance.stocks import Stock

# Set your publishable token as an environment variable or replace directly
# For production, always use environment variables or a secure key management system
publishable_token = os.environ.get('IEX_CLOUD_PUBLISHABLE_TOKEN')

if not publishable_token:
    print("Error: IEX_CLOUD_PUBLISHABLE_TOKEN environment variable not set.")
    exit()

try:
    # Initialize Stock object for a given symbol
    stock = Stock("AAPL", token=publishable_token)

    # Fetch quote data
    quote_data = stock.get_quote()

    if quote_data:
        # Access relevant fields from the quote
        symbol = quote_data['symbol']
        company_name = quote_data['companyName']
        latest_price = quote_data['latestPrice']
        change = quote_data['change']
        change_percent = quote_data['changePercent']

        print(f"Symbol: {symbol}")
        print(f"Company: {company_name}")
        print(f"Latest Price: {latest_price}")
        print(f"Change: {change}")
        print(f"Change Percent: {change_percent:.2%}")
    else:
        print("Could not retrieve quote data for AAPL.")

except Exception as e:
    print(f"An error occurred: {e}")

JavaScript example: Get company profile

This JavaScript snippet illustrates how to fetch a company's profile information using the iexcloud SDK. Similar to the Python example, ensure your publishable token is configured.

const iex = require('iexcloud');

// Configure IEX Cloud with your publishable token
// For production, use environment variables (e.g., process.env.IEX_CLOUD_PUBLISHABLE_TOKEN)
iex.configure({ 
  publishable: process.env.IEX_CLOUD_PUBLISHABLE_TOKEN || 'YOUR_PUBLISHABLE_TOKEN_HERE',
  version: 'stable' // 'stable' for production, 'sandbox' for testing
});

async function getCompanyProfile(symbol) {
  try {
    const company = await iex.symbol(symbol).company().get();

    if (company) {
      console.log(`Company Name: ${company.companyName}`);
      console.log(`Exchange: ${company.exchange}`);
      console.log(`Sector: ${company.sector}`);
      console.log(`Description: ${company.description.substring(0, 150)}...`);
      console.log(`Website: ${company.website}`);
    } else {
      console.log(`Could not retrieve company profile for ${symbol}.`);
    }
  } catch (error) {
    console.error(`Error fetching company profile for ${symbol}:`, error.message);
  }
}

// Call the function with a stock symbol
getCompanyProfile('MSFT');

These examples provide a starting point. The IEX Cloud API reference documentation contains extensive details on all available endpoints and their corresponding SDK methods.

Community libraries

Beyond the official SDKs, the IEX Cloud developer community has contributed various client libraries and tools in other programming languages. These community-driven projects expand the accessibility of IEX Cloud data to a wider range of development environments and preferences. While not officially supported by IEX Cloud, they can be valuable resources for developers working in languages not covered by the official SDKs.

Examples of community-contributed libraries often include:

  • Go/Golang clients: Libraries designed for high-performance backend services, leveraging Go's concurrency features.
  • Ruby gems: Tools for Ruby on Rails applications or other Ruby-based projects.
  • PHP packages: Integrations for web applications built with PHP frameworks like Laravel or Symfony.
  • C#/.NET clients: Libraries for Windows-based applications or .NET core services.

When using community libraries, it is important to:

  • Check maintenance status: Verify that the library is actively maintained and compatible with the latest IEX Cloud API versions.
  • Review documentation: Assess the quality and completeness of the library's documentation and examples.
  • Examine source code: For critical applications, reviewing the source code can help ensure security and proper handling of API responses.
  • Consider licensing: Understand the open-source license under which the library is distributed.

Developers can typically find these community contributions on platforms like GitHub by searching for "IEX Cloud" along with the desired programming language. While they offer flexibility, official SDKs generally provide the most reliable and up-to-date integration experience. For example, similar community-driven efforts exist for other financial APIs, such as Polygon.io's community SDKs, which complement their official offerings by extending language support based on developer demand.