Once registraion is done with the New York times developer website, we will receive a key to access datasets in developer website. For each section a key needs to be requested.
# First let's fetch movie dataset paramenters using GET method
# From API documentation, we can pass order by field
nytimes_movie_get <- GET("https://api.nytimes.com/svc/movies/v2/reviews/all.json",
query = list(api_key = "5ca6581c5c0c4d22a89d258eaeb17846", order = "by-title",
offset = 20))
nytimes_movie_get## Response [https://api.nytimes.com/svc/movies/v2/reviews/all.json?api_key=5ca6581c5c0c4d22a89d258eaeb17846&order=by-title&offset=20]
## Date: 2016-10-28 19:17
## Status: 200
## Content-Type: application/json; charset=UTF-8
## Size: 12 kB
# Lets convert JSON to dataframe
nytimes_movie_df <- fromJSON("https://api.nytimes.com/svc/movies/v2/reviews/all.json?api_key=5ca6581c5c0c4d22a89d258eaeb17846") %>%
data.frame()
head(nytimes_movie_df, 1)## status
## 1 OK
## copyright
## 1 Copyright (c) 2016 The New York Times Company. All Rights Reserved.
## has_more num_results results.display_title results.mpaa_rating
## 1 TRUE 20 Gimme Danger R
## results.critics_pick results.byline
## 1 1 STEPHEN HOLDEN
## results.headline
## 1 Review: Iggy Pop Bares All, and Nothing, in Gimme Danger
## results.summary_short
## 1 Jim Jarmuschs reverent documentary on Iggy Pop, a provocateur, is prim: It includes no retrospective scenes of drug use or the bandmates fights.
## results.publication_date results.opening_date results.date_updated
## 1 2016-10-27 2016-10-28 2016-10-28 12:44:42
## results.link.type
## 1 article
## results.link.url
## 1 http://www.nytimes.com/2016/10/28/movies/gimme-danger-review-iggy-pop.html
## results.link.suggested_link_text results.multimedia.type
## 1 Read the New York Times Review of Gimme Danger mediumThreeByTwo210
## results.multimedia.src
## 1 https://static01.nyt.com/images/2016/10/28/arts/28GIMME/28GIMME-mediumThreeByTwo210-v2.jpg
## results.multimedia.width results.multimedia.height
## 1 210 140
In this API call, we will fetch NYtimes symantic dataset
# Get Semantic JSON
nytimes <- GET("https://api.nytimes.com/svc/semantic/v2/concept/search.json", query = list(api_key = "5ca6581c5c0c4d22a89d258eaeb17846",
query = "Active"))
# Lets convert JSON to dataframe
nytimes.semantic.df <- fromJSON("https://api.nytimes.com/svc/semantic/v2/concept/search.json?api_key=5ca6581c5c0c4d22a89d258eaeb17846&query=Active") %>%
data.frame()
head(nytimes.semantic.df, 2)## status
## 1 OK
## 2 OK
## copyright
## 1 Copyright (c) 2015 The New York Times Company. All Rights Reserved.
## 2 Copyright (c) 2015 The New York Times Company. All Rights Reserved.
## num_results results.concept_id results.concept_name results.is_times_tag
## 1 185 1131128 3Cinteractive LLC NA
## 2 185 1131808 ABC Interactive NA
## results.concept_status results.vernacular results.concept_type
## 1 Active 3Cinteractive nytd_org
## 2 Active ABC Interactive nytd_org
## results.concept_created results.concept_updated
## 1 2013-02-26 02:06:27 2014-07-29 18:14:06
## 2 2013-02-26 02:06:32 2014-07-29 18:14:07
# Keys are passed to header of the URL
key <- c("M28yQdX0TI2adVJZmO2yu8T1dnrw5hZfZ9z15Cqi")
names(key) <- "X-API-Key"
presidential_get <- GET("https://api.propublica.org/campaign-finance/v1/2016/president/totals.json",
add_headers(.headers = key), content_type_json())
# Convert in into JSON
presidential_get.df <- content(presidential_get) %>%
.$results %>% toJSON() %>% fromJSON()
head(presidential_get.df, 2)## slug candidate_name name party committee
## 1 clinton Clinton, Hillary Hillary Clinton D committees/C00575795.json
## 2 trump Trump, Donald J. Donald J. Trump R committees/C00580100.json
## committee_id total_receipts total_disbursements cash_on_hand
## 1 C00575795 513004224 450563244 62440979
## 2 C00580100 254946268 238951814 15994454
## date_coverage_to date_coverage_from candidate_id
## 1 2016-10-19 2015-04-01 P00003392
## 2 2016-10-19 2015-04-02 P80001571
## contributions_less_than_200 contributions_200_499 contributions_500_1499
## 1 184304100 49396763 75102001
## 2 85357467 24975445 21180308
## contributions_1500_2699 contributions_max net_primary net_primary_pct
## 1 37324774 141096600 -121526151 -23.7
## 2 6082949 19502100 -44063657 -17.3
## contributions_less_than_200_pct contributions_max_pct burn_rate
## 1 51 39 94.7449
## 2 74.6 17 161.5867
## total_contributions independent_expenditures_support
## 1 361327173 43618093
## 2 114481262 34459927
## independent_expenditures_oppose
## 1 68809673
## 2 220770199
This website can be used to fetch many information of persons via his email and phonenumber.
Likelihood of a person presence according fullcontact
#Get key from fullcontact
names(fullkey) <- "X-FullContact-APIKey"
#Full contact info likelihood
fullcontact_get.df.new <- GET("https://api.fullcontact.com/v2/name/normalizer.json?q=Hillary%20Clinton",add_headers(.headers =fullkey),content_type_json()) %>% content(.) %>% toJSON() %>% fromJSON()
paste("Likelihood of the person is ",fullcontact_get.df.new$likelihood*100,"%")## [1] "Likelihood of the person is 96.7 %"