Final Project Presentation

Pedro Camacho
14/abril/2017

This presentation is for the final project on the “developing data products” part of the Data Science specialization.

Downloading financial information

This presentation is about the following shiny app https://www.shinyapps.io/admin/#/application/172373.

Using the intrinio api

Steps:

  • Get an api id and key: this is free (the app uses credentials)
  • Get url end: this is the base of the URL construction
  • Decide the information you want to retrieve
  • Read api documentation to see what to add to the url end. it could be ticket name, years, specific calculation and so on.

Reading into R

  • With the previous api construction call we obtain a json file.
  • Depending on the type of information been asked, the json could have different structures.
  • Also depending what information you are looking for you would parse the information different.
  • In our case we are parsing the table structure withing the json.

Example

  • The following is an example of the procedures described above
base <- "https://api.intrinio.com/financials/standardized?identifier="
end <- "AAPL&statement=income_statement&fiscal_year=2015&fiscal_period=FY"
username <- "56e432e5f2755204fc7dca8dbea46c35" 
password <- "6c2293b7d2772de2693255dffaea1011"
apicall <- paste(base, end, sep = "")
apicall #this is the URL to retrieve the json file
[1] "https://api.intrinio.com/financials/standardized?identifier=AAPL&statement=income_statement&fiscal_year=2015&fiscal_period=FY"

Example (cont)

With the URL and using the get function we retrieve the information as follows:

library(httr); library(jsonlite)
call <- GET(apicall, authenticate(username,password, type = "basic"))
unlist <- suppressMessages(unlist(content(call, as = "text"))) #unlisting the file
json <- fromJSON(unlist) #parsing the json

After this we have a information that can be editable using simple R commands, in this case a vector with the information for year 2015. The app does this api call for the selected years and put them together on a table.