# python-yapi
Python Client for [YApi](https://github.com/YMFE/yapi) based on HTTP Api.
![Languate - Python](https://img.shields.io/badge/language-python-blue.svg)
![PyPI - License](https://img.shields.io/pypi/l/python-yapi)
![PyPI](https://img.shields.io/pypi/v/python-yapi)
![PyPI - Downloads](https://img.shields.io/pypi/dm/python-yapi)
## Install
```shell
pip install python-yapi
```
## Simple Use
### Register and Login
```python
from python_yapi import YApi
yapi = YApi(base_url='http://localhost:3000')
username, email, password = 'Kevin', 'kevin@126.com', 'abc123'
yapi.register(username, email, password) # return a dict
yapi.login( email, password) # return a dict
```
### Simple Use
```python
import json
from python_yapi import YApi
yapi = YApi(base_url='http://localhost:3000')
email, password = 'kevin@126.com', 'abc123'
yapi.login(email, password)
# Create a private project in user default group, with auto basepath, random color and random icon.
project = yapi.add_project('Demo Project')
project_id = project['_id']
# Create a private "GET" interface in project default category with a sample json response.
yapi.add_interface(project_id=project_id,
title='Calc Add',
method='GET',
path='/add',
req_query=[
{"name": "a", "required": "1", "example": "1", "desc": "变量a"},
{"name": "b", "required": "1", "example": "2", "desc": "变量b"},
],
res_body_type="json",
res_body=json.dumps({"code": 0, "message": "success", "data": {"result": "3"}}),
res_body_is_json_schema=False,
status='done')
# Create a private "POST" interface in project default category with a sample json data and a sample json response.
yapi.add_interface(project_id=project_id,
title='Calc Sub',
method='POST',
path='/sub',
req_headers=[{"name": "Content-Type", "value": "application/json"}],
req_body_type="json",
req_body_other=json.dumps({"a": "5", "b": "1"}),
req_body_is_json_schema=False,
res_body_type="json",
res_body=json.dumps({"code": 0, "message": "success", "data": {"result": "4"}}),
res_body_is_json_schema=False,
status='done')
```
Raw data
{
"_id": null,
"home_page": "https://github.com/hanzhichao/python-yapi",
"name": "python-yapi",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "yapi,python-yapi,pyyapi,yapi-client",
"author": "Han Zhichao",
"author_email": "superhin@126.com",
"download_url": "https://files.pythonhosted.org/packages/d0/8f/d532bf02dc69a0c7171ecb700d9bac184874681d085e0f721e6aa1610c2b/python_yapi-0.1.3.tar.gz",
"platform": null,
"description": "# python-yapi\nPython Client for [YApi](https://github.com/YMFE/yapi) based on HTTP Api.\n\n\n![Languate - Python](https://img.shields.io/badge/language-python-blue.svg)\n![PyPI - License](https://img.shields.io/pypi/l/python-yapi)\n![PyPI](https://img.shields.io/pypi/v/python-yapi)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/python-yapi)\n\n## Install\n```shell\npip install python-yapi\n```\n\n## Simple Use\n\n### Register and Login\n```python\nfrom python_yapi import YApi\nyapi = YApi(base_url='http://localhost:3000')\n\nusername, email, password = 'Kevin', 'kevin@126.com', 'abc123'\n\nyapi.register(username, email, password) # return a dict\nyapi.login( email, password) # return a dict\n```\n\n\n### Simple Use\n\n```python\nimport json\n\nfrom python_yapi import YApi\n\nyapi = YApi(base_url='http://localhost:3000')\nemail, password = 'kevin@126.com', 'abc123'\nyapi.login(email, password)\n\n# Create a private project in user default group, with auto basepath, random color and random icon.\nproject = yapi.add_project('Demo Project')\nproject_id = project['_id']\n\n# Create a private \"GET\" interface in project default category with a sample json response.\nyapi.add_interface(project_id=project_id,\n title='Calc Add',\n method='GET',\n path='/add',\n req_query=[\n {\"name\": \"a\", \"required\": \"1\", \"example\": \"1\", \"desc\": \"\u53d8\u91cfa\"},\n {\"name\": \"b\", \"required\": \"1\", \"example\": \"2\", \"desc\": \"\u53d8\u91cfb\"},\n ],\n res_body_type=\"json\",\n res_body=json.dumps({\"code\": 0, \"message\": \"success\", \"data\": {\"result\": \"3\"}}),\n res_body_is_json_schema=False,\n status='done')\n\n# Create a private \"POST\" interface in project default category with a sample json data and a sample json response.\nyapi.add_interface(project_id=project_id,\n title='Calc Sub',\n method='POST',\n path='/sub',\n req_headers=[{\"name\": \"Content-Type\", \"value\": \"application/json\"}],\n req_body_type=\"json\",\n req_body_other=json.dumps({\"a\": \"5\", \"b\": \"1\"}),\n req_body_is_json_schema=False,\n\n res_body_type=\"json\",\n res_body=json.dumps({\"code\": 0, \"message\": \"success\", \"data\": {\"result\": \"4\"}}),\n res_body_is_json_schema=False,\n status='done')\n```\n",
"bugtrack_url": null,
"license": "MIT license",
"summary": "python yapi sdk",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/hanzhichao/python-yapi"
},
"split_keywords": [
"yapi",
"python-yapi",
"pyyapi",
"yapi-client"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d08fd532bf02dc69a0c7171ecb700d9bac184874681d085e0f721e6aa1610c2b",
"md5": "0cab5ae2ab5c384ebb5aa4649bed6e6e",
"sha256": "5c95b89ea9434c95b15a51b77adb59d6b4a34300eef848f56d362bbd5593df6c"
},
"downloads": -1,
"filename": "python_yapi-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "0cab5ae2ab5c384ebb5aa4649bed6e6e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17800,
"upload_time": "2023-07-03T08:36:10",
"upload_time_iso_8601": "2023-07-03T08:36:10.849522Z",
"url": "https://files.pythonhosted.org/packages/d0/8f/d532bf02dc69a0c7171ecb700d9bac184874681d085e0f721e6aa1610c2b/python_yapi-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-03 08:36:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hanzhichao",
"github_project": "python-yapi",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "python-yapi"
}