使用 R 的 Lending Club API [英] Lending Club API with R

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

问题描述

我正在尝试使用 Lending Club 的 API 和 R 提取数据: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天全站免登陆