本文介绍了当我拥有应用程序密钥时,为什么在SODA API上限制为1,000行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将消费者金融保护局(CFPB)加载到Python 3.4中的Pandas数据框中.我的代码有效,但是似乎通过SODA API限制为1000行.我正在使用应用令牌并在此引用URL

I'm trying to load the Consumer Financial Protection Bureau (CFPB) into a Pandas Data Frame in Python 3.4. My code works, however it appears that I'm limited to 1,000 rows through the SODA API. I'm using an app token and referencing the URL here

df = pd.read_json('http://data.consumerfinance.gov/resource/x94z-ydhh.json?$$app_token=XXXXXXXXXXXXXXXX')

数据结构是完美的,但是我仅限于1000行数据(应该接近300,000行数据).

The data structure is perfect, however I'm limited to only 1,000 rows of data (should be closer to 300,000 rows of data).

当我通过浏览器(带有应用程序令牌)访问相同的URL时,似乎它也仅拉入1000行.我的印象是,使用应用令牌可以访问整个数据集,这是不正确的吗?

When I access the same URL through a browser (with app token), it appears it is pulling in only 1,000 rows as well. I was under the impression that with an App Token you could access the entire data set, is that incorrect?

推荐答案

查看有关$limit参数的文档

Check out the docs on the $limit parameter

注意::$ limit的最大值为50,000条记录,如果超过该限制,您将收到400错误的请求响应.

Note: The maximum value for $limit is 50,000 records, and if you exceed that limit you'll get a 400 Bad Request response.

因此,您只是获得了默认数量的记录.

So you're just getting the default number of records back.

将无法通过单个 API调用获得全部300,000条记录-这将使用$limit $offset

You will not be able to get all 300,000 records in a single API call - this will take multiple calls using $limit together with $offset

尝试:

http://data.consumerfinance.gov/resource/x94z-ydhh.json?$limit=50000&$$app_token=XXXXXXXXXXXXXXXX

这篇关于当我拥有应用程序密钥时,为什么在SODA API上限制为1,000行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 23:20