Company Name Search

with an introduction to the dataset

Author

Sam Rush

Introduction to the Financial API

This data set allows you search for ticker symbols, company names, and what currency is used. This data is useful for retrieving ticker symbols when you know the full or partial company name, but not the symbol identifier. The company that I took a look at was Apple. The information here could be useful in someone who wants to invest in Apple, but they do not know the symbol identifier. You can learn more about the data by going to this website: https://site.financialmodelingprep.com/developer/docs/stable

Setting Up

The first step in accessing and setting up this API is going to that website linked above and sign up for a free account. After signing up, you will be given an API key. This key is important. The end point for this can be found on the website under the subheading of Company Search Name. Insert your own API key.

library(tidyverse)
library(jsonlite)
library(magrittr)
library(httr)

Running Code

The next step is to define the query. In this case, I will be looking at AAPL. If you want to look at a different company, put their ticker name in place of AAPL. Next, build the API request URL. Follow the code below. Check this code by using the print function. Then use the get request in order to retrieve the data. This URL will bring you the API that you created. Copy and paste this into Firefox.

query <- "query=AAPL"
fmp_api_url <- paste0(fmp_endpoint, query, "&", api_key)

print(fmp_api_url)
[1] "https://financialmodelingprep.com/stable/search-name?query=AAPL&apikey=ulosAP8hi3QnVfmJjyToEW9Cbi5IYSV7"
fmp_response <- fmp_api_url %>%
  GET()

Double Checking and Visual

The next step is checking to make sure that what you have done has worked. Check the status. If 200 pops up, than that means it was successful. If it does not, this is when you try to troubleshoot. Go back to the top of the document and try to follow along. Next, follow the code to bring in JSON and make sure that the content is defined as text. Then print the data. This will give you a table in R.

print(fmp_response$status_code)
[1] 200
fmp_data <- fmp_response %>%
  content(as = "text") %>%
  fromJSON(flatten = TRUE) %>%
  as_tibble()

print(fmp_data)
# A tibble: 6 × 5
  symbol  name                                currency exchangeFullName exchange
  <chr>   <chr>                               <chr>    <chr>            <chr>   
1 APLY.NE Apple (AAPL) Yield Shares Purpose … CAD      CBOE CA          NEO     
2 APLY    YieldMax AAPL Option Income Strate… USD      New York Stock … AMEX    
3 AAPD    Direxion Daily AAPL Bear 1X Shares  USD      NASDAQ Global M… NASDAQ  
4 AAPU    Direxion Daily AAPL Bull 1.5X Shar… USD      NASDAQ Global M… NASDAQ  
5 AAPS.L  Leverage Shares -3x Short Apple (A… USD      London Stock Ex… LSE     
6 AAPY    Kurv Yield Premium Strategy Apple … USD      New York Stock … AMEX    

Improvements for the Future

I originally wanted to use a different endpoint defined as Analyst Estimates. This would have shown the stock price, revenue, and other key data when it comes to the stock market. Unfortunately, this data is only accessible through a pay wall. That data could be used following a similar guide to this one. You would have to change the endpoint and pay the cost to get this data.

The echo: false option disables the printing of code (only output is displayed).