python yapi sdk
Project description
python-yapi
Python Client for YApi based on HTTP Api.
Install
pip install python-yapi
Simple Use
Register and Login
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
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')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python_yapi-0.1.3.tar.gz
(17.8 kB
view details)
File details
Details for the file python_yapi-0.1.3.tar.gz
.
File metadata
- Download URL: python_yapi-0.1.3.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c95b89ea9434c95b15a51b77adb59d6b4a34300eef848f56d362bbd5593df6c |
|
MD5 | 0cab5ae2ab5c384ebb5aa4649bed6e6e |
|
BLAKE2b-256 | d08fd532bf02dc69a0c7171ecb700d9bac184874681d085e0f721e6aa1610c2b |