Skip to main content

python yapi sdk

Project description

python-yapi

Python Client for YApi based on HTTP Api.

Languate - Python PyPI - License PyPI PyPI - Downloads

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 hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page