一个用于vexdb api的瘦python包装器
vexdb的Python项目详细描述
python vexdb
一个用于vexdb api的瘦python包装器。
安装
注意:python vexdb只与python 3兼容!
使用pip安装:pip install vexdb
。
然后,import vexdb
访问包中的函数。
python vexdb需要urllib
和json
模块,这两个模块都应该随python版本一起提供。
功能
python vexdb为https://vexdb.io/the_data中列出的每个数据类型提供了两个函数,其中DataType
是Events
,Teams
,Matches
,Rankings
,SeasonRankings
,Awards
,或Skills
:
getDataType
-返回一个字典列表,每个字典对应于一个与提供的条件匹配的结果 作为函数参数。getNumDataType
-返回与作为函数参数提供的条件匹配的结果数。
对于每种类型的数据,getDataType
和getNumDataType
函数都有一个用于列出的所有参数的参数
在https://vexdb.io/the_data对应的页面上,除了limit_start
、limit_number
和nodata
。
所有参数都是可选的,有关每个参数的详细信息可以在每个参数的vexdb api网页上找到
数据类型。
getDataType
函数还有一个布尔参数get_all
,当设置为True
时,该参数将进行多个api调用
为了确保它返回所有匹配的结果,因为api可能不会返回大量查询的所有结果
(超过几千)火柴。默认值get_all
是False
,传递get_all=True
只是
对于具有大量预期结果的查询是必需的。
示例调用
返回2017-2018赛季8768A队所有比赛的列表:
vexdb.getMatches(team="8768A", season="In The Zone")
查找本季迄今为止颁发的所有奖项:
vexdb.getAwards(season="current")
查找美国每个高中VRC团队:
vexdb.getTeams(grade="High School", country="United States", get_all=True)
(注意使用get_all=True
,因为这将返回大量结果)
有关更深入的示例,请参阅example_scripts目录。
帮助文本
要列出每个包含的函数,请运行help(vexdb)
,其输出如下:
NAME
vexdb - Thin python wrapper for the VexDB API
FILE
/Users/john/Library/Python/2.7/lib/python/site-packages/vexdb.py
FUNCTIONS
getAwards(sku=None, name=None, team=None, season=None, get_all=False)
Return a list of awards matching the given criteria.
For sets of criteria that match a large number of awards (a few thousand or so),
a single request to the API will return only a limited number of results.
Passing get_all=True will ensure that all matching awards are returned by making
multiple requests if necessary.
getEvents(sku=None, program=None, date=None, season=None, city=None, region=None, country=None, team=None, status=None, get_all=False)
Return a list of events matching the given criteria.
For sets of criteria that match a large number of events (a few thousand or so),
a single request to the API will return only a limited number of events.
Passing get_all=True will ensure that all matching events are returned by making
multiple requests if necessary.
getMatches(sku=None, division=None, round=None, instance=None, matchnum=None, scheduled=None, field=None, team=None, scored=None, season=None, get_all=False)
Return a list of matches matching the given criteria.
For sets of criteria that match a large number of matches (a few thousand or so),
a single request to the API will return only a limited number of results.
Passing get_all=True will ensure that all matching matches are returned by making
multiple requests if necessary.
getNumAwards(sku=None, name=None, team=None, season=None)
Return the number of season rankings matching the given criteria
getNumEvents(sku=None, program=None, date=None, season=None, city=None, region=None, country=None, team=None, status=None)
Return the number of events matching the given criteria.
getNumMatches(sku=None, division=None, round=None, instance=None, matchnum=None, scheduled=None, field=None, team=None, scored=None, season=None)
Return the number of matches matching the given criteria
getNumRankings(sku=None, division=None, rank=None, team=None, season=None)
Return the number of rankings matching the given criteria
getNumSeasonRankings(program=None, season=None, team=None, vrating_rank=None)
Return the number of season rankings matching the given criteria
getNumSkills(sku=None, program=None, type=None, team=None, season=None, season_rank=None, rank=None)
Return the number of skills records matching the given criteria
getNumTeams(team=None, program=None, organisation=None, city=None, region=None, country=None, grade=None, is_registered=None, sku=None)
Return the number of teams matching the given criteria
getRankings(sku=None, division=None, rank=None, team=None, season=None, get_all=False)
Return a list of rankings matching the given criteria.
For sets of criteria that match a large number of rankings (a few thousand or so),
a single request to the API will return only a limited number of results.
Passing get_all=True will ensure that all matching rankings are returned by making
multiple requests if necessary.
getSeasonRankings(program=None, season=None, team=None, vrating_rank=None, get_all=False)
Return a list of season rankings matching the given criteria.
For sets of criteria that match a large number of season rankings (a few thousand or so),
a single request to the API will return only a limited number of results.
Passing get_all=True will ensure that all matching season rankings are returned by making
multiple requests if necessary.
getSkills(sku=None, program=None, type=None, team=None, season=None, season_rank=None, rank=None, get_all=False)
Return a list of skills records matching the given criteria.
For sets of criteria that match a large number of skills records (a few thousand or so),
a single request to the API will return only a limited number of results.
Passing get_all=True will ensure that all matching skills records are returned by making
multiple requests if necessary.
getTeams(team=None, program=None, organisation=None, city=None, region=None, country=None, grade=None, is_registered=None, sku=None, get_all=False)
Return a list of teams matching the given criteria.
For sets of criteria that match a large number of teams (a few thousand or so),
a single request to the API will return only a limited number of results.
Passing get_all=True will ensure that all matching teams are returned by making
multiple requests if necessary.
urlToJSON(url)
Makes a request to the specfied URL and returns a list of results.
urlToSize(url)
Makes a request to the specfied URL and returns the number of results.
Useful mostly when making calls with the 'nodata' perameter set to true.