Stock API For Fintech Developers: How To Get Started

Intrinio's stock API was designed by financial professionals for developers, a rare situation in the world of FinTech. This makes them easy to integrate and scale for a developer while the data structures are intuitive for financial analysts.

Even with this solid foundation,  getting started with the API can be challenging- developers need to understand how to work with a RESTful API AND understand financial data. This article explains a few of the resources Intrinio has made available to help you get started.

The API Documentation

Start by looking at the API documentation.  There you will see that the API uses Basic Authentication administered over HTTPS. You can see what this means, and build your first API call, by pasting the following text into your browser:

https://api.intrinio.com/data_point?ticker=AAPL&item=close_price

Your browser will prompt you to enter your API username and password- you can get those on your account page (in the Access Keys section):

Stock API authentication example

Copy and paste your API username and password from intrinio.com/account

All you need to do is copy and paste them in and you have authenticated over HTTPS. When you do, you will see the result of your API call- the current price for Apple's stock. Your application will do this part with code instead of copy and paste:

Stock API response example

Sample response in JSON format

Notice that the API call is broken into several parts:

The base URL- https://www.api.intrinio.com/

A data type- data_point?

A ticker- ticker=AAPL&

And an item - item=close_price

By varying the data type, the ticker, and the item, you can use the API to call many different data points from Intrinio's database for thousands of securities in numerous formats.

Reading the documentation will show you the different data data types you can use in your API calls and Intrinio has documentation where you can search for tickers as well. If you are interested in economic data, there is a separate search page. Our help page has links to the various tag look up pages in our documentation.

If you prefer a video overview, we have one for your viewing pleasure:

Sample Stock API calls

While sample stock API calls are included in the API documentation, it can be useful to see a few together to get an idea of the breadth of data types available through Intrinio. Once you learn the format of a few data types, its easy to change the building blocks of the API call to get a different piece of data:

https://api.intrinio.com/securities?page_number=2

Often times you will notice that there are limits to the amount of data available in a single call. This limit is 250 items per page in general, but adding a pager, page_number=2 in this case, allows you to pull multiple pages.

https://api.intrinio.com/financials/standardized?identifier=YUM&statement=income_statement&fiscal_period=Q2&fiscal_year=2015

This grabs YUM's income statement from Q2, 2015.

https://api.intrinio.com/companies?latest_filing_date=2017-03-06 That shows all companies with a new filing date on or after 2017-03-06, which is useful for determining which fundamentals need to be updated.

https://api.intrinio.com/data_point?ticker=AAPL&item=pricetoearnings

This call uses data_point, a data type that returns the most current piece of data. In this case, I have simplyed changed out "close_price" in the first API call in this post for "pricetoearnings" so that instead of the current stock price for Apple, I will see the current price to earnings ratio.

https://api.intrinio.com/data_point?ticker=$FEDFUNDS&item=level

This call returns the current federal funds interest rate from the federal reserve. Your API calls are not limited to just stocks- Intrinio covers 200,000 economic data series as well.

https://api.intrinio.com/historical_data?ticker=AAPL&item=pricetoearnings&start_date=2014-01-01&end_date=2015-01-01

This stock api call uses the historical data format to pull Apple's price to earnings ratio over the course of 2014. Historical data allows you to pull data as a time series or to pull data from a specific point in time.

https://api.intrinio.com/historical_data?identifier=$VIXCLS&item=level&start_date=2014-01-01&end_date=2015-01-01

Here, we combine the previous two calls to return economic data as a time series. In this case, its the VIX volatility index.

https://api.intrinio.com/prices?ticker=AAPL

Be careful with this one! This call will return the entire price history of Apple- thats a lot of data. You can use this data type to specify a specific date range or pull it all in at once.

https://api.intrinio.com/fundamentals/banks?ticker=STT&report=ubpr&date=2012-09-30

This call returns the FDIC call report for State Street Corporation, which provides banking services, from 2012-09-30. All banks must file call reports with the FDIC and the Intrinio API allows a developer to access any item from any call report for any bank.

https://api.intrinio.com/historical_data?ticker=$SIC.5410&item=pricetoearnings&frequency=yearly&stat=median

This call pulls in the median annual price to earnings ratio for the Oil and Gas industry for every year going back to 2007. Learning how to use SIC codes to pull data on sectors and industries is a lucrative method for obtaining benchmarking data.

https://api.intrinio.com/news?ticker=AAPL&ticker=MSFT

Here we move into the realm of dimensional calling, which is a single API call that returns multiple data points for a security, up to 100, or multiple securities for a datapoint, up to 100. This call will pull in all of the latest news for both Microsoft and Apple.

https://api.intrinio.com/data_point?ticker=AAPL,MSFT&item=last_price

In this call, instead of multiple items for a single stock we get a single item for multiple stocks. In this case, the real time stock price for Apple and Microsoft.

https://api.intrinio.com/data_point?ticker=AAPL&item=open_price,last_price,volume

This dimensional call uses the data_point endpoint to pull in 3 metrics for AAPL. Dimensional calls do not work with historical data, however they can save you time with data_point and news.

https://api.intrinio.com/news?identifier=GOOGL&page_size=5

That will limit your news to the most recent 5 articles.

https://api.intrinio.com/companies?page_number=1

This is a handy call that returns the first 250 companies that Intrinio covers, including the ticker symbols you can parse out to use in other API calls. Since the number of items that can be returned in a single call is limited to 250, and Intrinio covers way more than 250 tickers, you will need to change the "1" to "2" to get the second 250. This requires a loop to get the entire list.

https://api.intrinio.com/companies?identifier=AAPL

This call extends the previous call to get the basic company information for Apple.

http://blog.intrinio.com/stock-screener-api-intrinio/

This blog explains how to use the stock screener api, including sample calls for multiple screening parameters.

Sample Code

Once you have mastered the syntax for Intrinio stock API calls, you will want to use your coding language of choice to automatically input your API username and password and parse the data for use in your application. The API will work with any language and we are currently working to provide sample code for a larger number of them.

DISCLAIMER: Sample code generated by users is not supported by Intrinio.

This tutorial is designed to get you making a call in a browser, but it includes Ruby, Curl, and Javascript (node) examples.

Here is a user created wrapper of the API for Ruby.

This SDK is for developers working with C# .NET

Here is a blog showing how to use the API with R in RStudio.

Here is a more advanced blog showing functions to pull in big data frames in R

Here is a user generated R package for querying the API.

Check out this example of a user created Github repository with a Node.js, Javascript, and Json code base.

Python wrapper of the API on GitHub and via Python's ecosystem.

The Intrinio Excel add-in is open source, view the VBA code here.

You can download this code that shows how to access the IEX Websocket with Python.

This code that shows how to access the IEX websocket with .net.

This github repository shows how to access the IEX Websocket with Ruby.

This SDK is for NodeJS and shows how to access the IEX Websocket as well.

If you work with Python, here is some code that will return the last 8 quarterly statements for a specific stock:

If you are working with Swift to build apps for Apple, here is some code to get you started:

PHP code including stock api calls in a WordPress site:

 

  • Wilson

    Nice API it is, I am really enjoying to use it.
    However, I have found an inconsistency on your API response.

    For example,
    https://api.intrinio.com/data_point?identifier=AAPL&item=52_week_high,accruedinvestmentincome
    returnes
    {
    “data”: [
    {
    “identifier”: “AAPL”,
    “item”: “52_week_high”,
    “value”: 120.81
    },
    {
    “identifier”: “AAPL”,
    “item”: “accruedinvestmentincome”,
    “value”: 0
    }
    ],
    “result_count”: 2,
    “api_call_credits”: 2
    }

    Very well designed, and structured.

    But
    https://api.intrinio.com/data_point?identifier=AAPL&item=52_week_high
    returns
    {
    “identifier”: “AAPL”,
    “item”: “52_week_high”,
    “value”: 122.1
    }

    Quite different structure, is it?

    For programming and standard respect, it d be better be in first API call response format.

    Just a small opinion.

    Thanks,
    WIlson.

  • Rachel Carpenter

    Wilson, we’re so glad you’re enjoying the API! I will send this feedback over to our development team. Very much appreciated. Keep us posted with ideas and feedback!