Python client for Sailthru API
sailthru-client的Python项目详细描述
sailthru python client
==
==
有关安装说明、文档和示例,请访问:
[http://getstarted.sailthru.com/new for developers overview/api client library/python](http://getstarted.sailthru.com/new for developers overview/api client library/python)
根据[请求](http://docs.python requests.org/en/latest/)
2.6、2.7、3.3+
安装(python 2.7.x测试)安装(python2.7.x测试)
>使用[pip安装(http://www.pip-installer.org/):
运行测试
>安装tox,然后键入:
<
下面是一个如何检查速率限制和节流的示例基于此的api调用。有关速率限制的更多信息,请参见[sailthru文档](https://getstarted.sailthru.com/new for developers overview/api/api-technical details/rate-limiting)
``python
sailthru-client=sailthru-client(api-key,api-secret)
进行一些API调用…
rate_limit_info=sailthru_client.get_last_rate_limit_info('user','post')
get_last_rate_limit_info如果之前未触发给定的端点/方法,则返回none
如果rate_limit_info不是none:
limit=rate_limit_info['limit'];
remaining=rate_limit_info['remaining';
reset_timestamp=rate_limit_info[“reset”];
根据上一个速率限制信息限制api调用
如果剩余,则<;=0:
seconds_直到重置=reset_timestamp-time.time()
在下一个用户api调用之前睡眠或执行其他业务逻辑
time.sleep(seconds_直到重置);
```
==
==
有关安装说明、文档和示例,请访问:
[http://getstarted.sailthru.com/new for developers overview/api client library/python](http://getstarted.sailthru.com/new for developers overview/api client library/python)
根据[请求](http://docs.python requests.org/en/latest/)
2.6、2.7、3.3+
安装(python 2.7.x测试)安装(python2.7.x测试)
>使用[pip安装(http://www.pip-installer.org/):
运行测试
>安装tox,然后键入:
<
下面是一个如何检查速率限制和节流的示例基于此的api调用。有关速率限制的更多信息,请参见[sailthru文档](https://getstarted.sailthru.com/new for developers overview/api/api-technical details/rate-limiting)
``python
sailthru-client=sailthru-client(api-key,api-secret)
进行一些API调用…
rate_limit_info=sailthru_client.get_last_rate_limit_info('user','post')
get_last_rate_limit_info如果之前未触发给定的端点/方法,则返回none
如果rate_limit_info不是none:
limit=rate_limit_info['limit'];
remaining=rate_limit_info['remaining';
reset_timestamp=rate_limit_info[“reset”];
根据上一个速率限制信息限制api调用
如果剩余,则<;=0:
seconds_直到重置=reset_timestamp-time.time()
在下一个用户api调用之前睡眠或执行其他业务逻辑
time.sleep(seconds_直到重置);
```