客户端实现
exist的Python项目详细描述
< H2> Python存在
存在API Python客户端实现
要求
- python>;=2.6、python>;=3.2或pypy。您可以从https://www.python.org/ 下载
- 皮普。如果您有python>;=2.7.9或>;=3.4,那么您已经有了pip。否则,请遵循以下说明:https://pip.pypa.io/en/latest/installing.html
安装
满足上述要求后,通过运行 从终端执行以下命令:
pip install exist
快速启动
使用pip install exist
安装Python的存在可与三种授权类型中的一种使用;Basic、OAuthe或APIIOTIONTIO/P>
要使用基本授权并存储返回的令牌,请在下面添加“用户名”和“密码” 命令:
exist authorize –username=<username> –password=<password>
如果您已经有一个令牌,请将其添加到以下命令中:
exist authorize –api_token=<token>
要使用oauth授权并存储返回的令牌,请在下面添加“app key”、“app secret”和“redirect url”(可选) 命令(注意:这需要应用程序直接注册到存在):
exist authorize –client_id=<app_key> –client_secret=<app_secret> –redirect_uri=<redirect_uri>
它将保存对文件进行进一步api调用所需的凭据。 被称为“存在。CFG”。这些证书应该保密。你可以用同样的 命令行客户端访问 存在API(http://developer.exist.io)。您还可以访问 使用python api的相同资源:
>>> from exist import Exist >>> exist = Exist(<client_id>, <client_secret>, <access_token>) >>> print(exist.user()) { "id": 1, "username": "josh", "first_name": "Josh", "last_name": "Sharp", "bio": "I made this thing you're using.", "url": "http://hellocode.co/", "avatar": "https://exist.io/static/media/avatars/josh_2.png", "timezone": "Australia/Melbourne", "local_time": "2020-07-31T22:33:49.359+10:00", "private": false, "imperial_units": false, "attributes": [ { "group": "steps", "priority": 1, "items": [ { "attribute": "steps", "label": "Steps", "value": 258, "service": "Fitbit", "priority": 1, "private": false, "value_type": 0, "value_type_description": "Integer" }, { "attribute": "floors", "label": "Floors", "value": 2, "service": "Fitbit", "priority": 2, "private": false, "value_type": 0, "value_type_description": "Integer" } ] } ] }
更多命令可从^ {TT3}$
的存在命令的帮助部分获得。路线图
- 测试(下一个)
- 编写API连接(正在进行中)