非官方authrocket api客户端
authrocket的Python项目详细描述
非官方客户。扩展请求库, 提供一些帮助函数。
另请参见
Requests文档。
提出请求
importauthrocket# Create an API object.# Config values can be found on your realm's integration page.api=authrocket.API(url="https://api-e1.authrocket.com/v1/",key="ko_XYZ",# Must start with `ko_`, rather than old-style `key_`realm_id="rl_ABC")# Fetch the first page of users.response=api.get("users")printresponse.json()
分页
使用iter_from_pages处理分页响应:
foruserinapi.iter_from_pages("GET","users"):printuser
路径变量
有些api通过路径获取变量,例如“users/123”。而不是使用 字符串插值,应该通过^{tt2}传递这些$ 争论-更安全。例如:
response=api.get("user/{id}",variables={"id":"123"})printresponse.json()