我正在使用来自US Treasury的API数据。我使用了httr
包中的GET()
函数和jsonlite
包中的fromJSON()
函数。下面是一个API示例:
library(httr)
library(jsonlite)
url <- https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/avg_interest_rates
data1 <- GET(url)
data2 <- fromJSON(rawToChar(data1$content))
data2 <- data.frame((data1$data))
问题是我只能看到前100个观测值的数据。输出量:
str(data3)
'data.frame': 100 obs. of 11 variables:
$ record_date : chr "2001-01-31" "2001-01-31" "2001-01-31" "2001-01-31" ...
$ security_type_desc : chr "Marketable" "Marketable" "Marketable" "Marketable" ...
$ security_desc : chr "Treasury Notes" "Treasury Bonds" "Treasury Inflation-Indexed Notes" "Treasury Inflation-Indexed Bonds" ...
$ avg_interest_rate_amt : chr "6.096" "8.450" "3.772" "3.866" ...
$ src_line_nbr : chr "2" "3" "4" "5" ...
$ record_fiscal_year : chr "2001" "2001" "2001" "2001" ...
$ record_fiscal_quarter : chr "2" "2" "2" "2" ...
$ record_calendar_year : chr "2001" "2001" "2001" "2001" ...
$ record_calendar_quarter: chr "1" "1" "1" "1" ...
$ record_calendar_month : chr "01" "01" "01" "01" ...
$ record_calendar_day : chr "31" "31" "31" "31" ...
我需要整个可用的数据(不仅仅是前100个观察结果),我无法找出问题所在。API本身不对数据进行限制或强加限制。你能帮帮我吗
1条答案
按热度按时间nuypyhwy1#
正如我在上面的评论中所暗示的,这是一个 * 服务器端 * 限制。https://fiscaldata.treasury.gov/datasets/average-interest-rates-treasury-securities/average-interest-rates-on-u-s-treasury-securities上的API文档描述了分页,例如通过请求
您请求并获得大小为1000条记录的集的第一页和第二页。