sailplay.ru的api客户端
sailpla的Python项目详细描述
文档可在https://sailplay.readthedocs.org/上获得。拉动请求 通过文档增强和/或修复是非常棒的,非常受欢迎。
内容
Requirements
- python=2.6
Usage
Initialize API client
您应该有pin,商店部门id和商店部门密钥 服务。
from sailplay import SailPlayClient client = SailPlayClient(pin, store_department_id, store_department_key)
Additional params
client = SailPlayClient( pin, store_department_id, store_department_key, token="token-here", # Set token manually (default "") silence=True, # Dont fail on API errors (default False) loglevel="debug", # Set log level (default INFO) )
Working with api
sailplay有很好且简单的语法。看看:
# Get events list http://sailplay.ru/api/v2/events/list/ client.api.events.list() # Create a new user http://sailplay.ru/api/v2/users/add/?... client.api.users.add(user_phone='...', first_name='...', last_name='...') # Get info about user http://sailplay.ru/api/v2/users/info/?... client.api.users.info(user_phone='...') # Create purchase http://sailplay.ru/api/v2/purchases/new/?... client.api.purchases.new(**params) # You also could use getitem syntax for params client.api.users['custom-vars'](**params) # Same as client.api['users']['custom-vars'](**params) # And etc. I hope you make decision how the client works :)
目前,客户机选择API版本automaticaly。
Context manager
您可以在上下文中重新定义客户端设置:
with client.ctx(silence=True): # Errors will not be raised here client.api.users.add(user_phone='...', first_name='...', last_name='...')
Raw api request
您可以向sailplay api发出原始请求:
client.request(method='GET', url='/users/info', data={...})
好好编码!
Bug tracker
如果您有任何建议、错误报告或 烦恼请向问题追踪者报告 在https://github.com/klen/sailplay/issues
Contributing
在github开发起动机:https://github.com/klen/sailplay
Contributors
- klen(基里尔·克莱诺夫)
License
根据BSD license授权。