雅虎!幻想 API 最大计数?

Yahoo! Fantasy API Maximum Count?

我正在尝试让所有可用的球员获得 Yahoo! 返回的 JSON 的位置。幻想 API,使用此资源:

http://fantasysports.yahooapis.com/fantasy/v2/game/nfl/players;status=A;position=RB

似乎总是 returns 这个 API 最多 25 个玩家。我也尝试过使用 ;count=n 过滤器,但如果 n 高于 25,我仍然只能返回 25 名玩家。有人知道为什么吗?我怎样才能得到更多?

这是我的代码:

from yahoo_oauth import OAuth1

oauth = OAuth1(None, None, from_file='oauth.json', base_url='http://fantasysports.yahooapis.com/fantasy/v2/')

uri = 'league/nfl.l.91364/players;position=RB;status=A;count=100'

if not oauth.token_is_valid():
    oauth.refresh_access_token

response = oauth.session.get(uri, params={'format': 'json'})

我确实解决了这个问题。我发现最大的"count"是25,但是"start"这个参数才是这个操作的关键。 API 似乎为每个玩家附加了一个索引(不管它是如何排序的),而 "start" 参数是开始的索引。这可能看起来很奇怪,但我能找到的唯一方法是让所有玩家以 25 人为一组返回。所以我的代码解决方案如下所示:

from yahoo_oauth import OAuth1

oauth = OAuth1(None, None, from_file='oauth.json', base_url='http://fantasysports.yahooapis.com/fantasy/v2/')

done = False
start = 1
while(not done) :
    uri = 'league/nfl.l.<league>/players;position=RB;status=A;start=%s,count=25' % start

    if not oauth.token_is_valid():
        oauth.refresh_access_token

    response = oauth.session.get(uri, params={'format': 'json'})

    # parse response, get num of players, do stuff

    start += 25

    if numPlayersInResp < 25:
        done = True