带R的Lending Club API [英] Lending Club API with R

查看:114
本文介绍了带R的Lending Club API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用带有R的Lending Club的API提取数据: https://www.lendingclub.com/developers/lc-api.action

I am trying to pull data with Lending Club's API with R: https://www.lendingclub.com/developers/lc-api.action

但是我不确定该怎么做.这就是我现在拥有的,但是我不断收到未经授权的错误.我之所以打电话给Lending Club以获得API支持,是因为它没有指定放置API密钥的位置,不幸的是他们没有对其API的任何支持.他们说所有信息都在网站上.

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.

我有一个Lending Club帐户和一个API密钥.

I have an account with Lending Club and an API Key.

这是我的代码,我添加了一个& api-key =",因为我为不同的API使用了类似的东西.

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)

输出:

> 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

如果有人使用R使用Lending Club的API,请给我一些指导.谢谢!

If anyone has worked with Lending Club's API with R please give me some guidance. Thank you!

编辑//

多谢了,我对查询"参数还有另一个疑问.我添加了查询"showall",但是如何添加TRUE?

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")

推荐答案

我编写了一个与Lending Club API配合使用的程序包,这应该会使您更容易解决此问题.试试这个:

I wrote a package to work with the Lending Club API which should make this problem easier for you. Try this:

install.packages("LendingClub")
library(LendingClub)
LC_CRED<- MakeCredential(investorID, APIkey)
ListedLoans(showAll=TRUE)$content

通过阅读小插图,您可以看到更多示例:

You can see a few more examples by reading the vignette:

vignette("LendingClub")

这篇关于带R的Lending Club API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆