Puede obtener esos datos en Intrinio en R también. Hay documentación, incluyendo cómo hacer realmente las llamadas a la API en R con ejemplos, aquí . Aquí hay un ejemplo de sacar la cuenta de resultados de Apple para el primer trimestre de 2017- sólo hay que obtenga sus propias claves API y añadirlos al código (es gratis):
#Cleaning up the environment
rm(list=ls())
#Skip this installation if you already have httr installed. This package makes using APIs in R easier
install.packages("httr")
#Require the package so you can use it
require("httr")
#Skip this installation if you already have jsonlite installed. This package makes parsing JSON easy
install.packages("jsonlite")
#Require the package so you can use it
require("jsonlite")
#Create variables for your usename and password, get those at intrinio.com/login.
#Replace them here or the code won't run! They need to be in ""
username <- "Your_API_Username_Here"
password <- "Your_API_Password_Here"
#These variables will be pasted together to make our API call. You can replace the "stock" variable with any US ticker symbol
base <- "https://api.intrinio.com/"
endpoint <- "financials/standardized"
stock <- "identifier=AAPL"
statement <- "statement=income_statement"
fiscal_period <- "fiscal_period=Q1"
fiscal_year <- "fiscal_year=2017"
#Pasting them together to make the API call.
call1 <- paste(base,endpoint,"?",stock,"&", statement, "&", fiscal_period, "&", fiscal_year, sep="")
#This line of code uses the httr package's GET function to query Intrinio's API, passing your username and password as variables
get_prices <- GET(call1, authenticate(username,password, type = "basic"))
#The content function parses the API response to text. You can parse to other formats, but this format is the easiest to work with. Text is equivalent to JSON
get_prices_text <- content(get_prices, "text")
#This line of code uses the JSONlite function fromJSON to parse the JSON into a flat form. Flat means rows and coloumns instead of nested JSON
get_prices_json <- fromJSON(get_prices_text, flatten = TRUE)
#Converting the data to a dataframe
get_prices_df <- as.data.frame(get_prices_json)
El resultado es un marco de datos con el siguiente aspecto:
Ahora que puede obtener las declaraciones a través de la API (de forma gratuita), puede dedicarse a analizarlas.