smashrun api的python客户端
smashrun-client的Python项目详细描述
用于Smashrunapi的python客户端。
安装
您可以使用pip:
pip install --pre smashrun-client
用法
认证
使用现有刷新令牌
client=Smashrun(client_id='my_client_id',client_secret='my_secret')client.refresh_token(refresh_token='my_refresh_token')
请求令牌
# use urn:ietf:wg:oauth:2.0:oob for applications that aren't a web appclient=Smashrun(client_id='my_client_id',client_secret='my_secret',redirect_uri='urn:ietf:wg:oauth:2.0:auto')auth_url=client.get_auth_url()code=raw_input("Go to '%s' and authorize this application. Paste the provided code here:"%auth_url[0])response=client.fetch_token(code=code)print(response['refresh_token'])
注意:上面的示例假设您运行的是python 2.x。 raw_input和input。
获取活动
使用Smashrun.get_activities获取活动列表(摘要):
activities=client.get_activities()# returns an iterator that handles paginating through the APIforactivityinactivities:printactivity['startDateTimeLocal']
获取特定活动
使用Smashrun.get_activity获取特定活动:
activity=client.get_activity(1234)printactivity['recordingKeys']
有关可以执行的操作的详细信息,请参见the code和Smashrun API
贡献
非常感谢您的贡献!随时提交请求或文件 我们的一个问题。