使用api buddy从控制台探索api
api-budd的Python项目详细描述
API好友
Right now, only OAuth2 authentication is supported. It's the most common, and current gold standard for security best practices. Also most APIs use it. That said, I have no beef with all the APIs out there using something else, so feel free to open a ticket if you want something else supported. ?
You can also always manually set headers.
安装
只要你有python 3.7或更高版本(我建议使用pyenv),只要:
pip install api-buddy
用法
首先,在首选项中指定您正在探索的api
# ~/.api-buddy.yamlapi_url:https://some.api.com
那就很简单了:
api get some-endpoint
=>200{"look":"I haz data","thx":"API Buddy"}
http方法默认为get
:
api this-endpoint # same as first example
您可以添加key=val格式的查询参数:
api get \ my/favorite/endpoint \first_name=cosmo \last_name=kramer
您还可以添加json格式的请求正文数据:
api post \ some-endpoint \'{"id": 1, "field": "value"}'
注意单引号。您可以跨多行展开此帐户:
api post \ some-endpoint \'{ "id": 1, "field": "value" }'
Preferences ?
参数
http_method
:(可选,默认值=get
)要在请求中使用的http方法。- 它应该是:
get
post
patch
put
delete
- 它应该是:
endpoint
:(必选)到api端点的相对路径。- 也就是说,您不需要在这里再次键入基本api url。
params
:(可选)查询参数列表key=val
data
:(可选)请求正文数据的json字符串。- 您不能将此与
get
一起使用,因为http。
- 您不能将此与
选项
-h
,--help
:显示帮助消息-v
,--version
:显示安装的版本
开发
需要:
开始工作的步骤:
- 使用
bin/setup
构建并创建本地venv
- 确保一切都与
bin/test
一起工作
- 使用
poetry run api --help
尝试本地cli
- 使用
bin/list
查找其他管理命令