I am trying to pull data with Lending Club's API with R: https://www.lendingclub.com/developers/lc-api.action
but I am unsure how to do it. This is what I have now but I keep getting an unauthorized error. I called Lending Club for API support because it did not specify where to put the API Key, unfortunately they do not have any support for their API. They said all the information is on the website.
I have an account with Lending Club and an API Key.
This is my code, I added an "&api-key=" because I have used something similar for a different API.
library(rjson)
library(RCurl)
library(jsonlite)
apikey <- "pP0tK321JWldXCMYHJ8VmIhMHuM="
url <- "https://api.lendingclub.com/api/investor/v1/loans/listing"
url <- paste0(url,"&api-key=",apikey)
getURL(url)
fromJSON(url)
output:
> getURL(url)
Error in function (type, msg, asError = TRUE) :
SSL certificate problem: self signed certificate in certificate chain
> fromJSON(url)
Error in download_raw(txt) : client error: (401) Unauthorized
If anyone has worked with Lending Club's API with R please give me some guidance. Thank you!
EDIT//
Thanks it works, I have another question regarding the "query" argument. I added a query "showall", but how do I add TRUE?
If you click the following link it will show the query options.
https://www.lendingclub.com/developers/listed-loans.action
rr <- GET("https://api.lendingclub.com/api/investor/v1/loans/listing",
add_headers(Authorization="key"), query = "showall")