RESTful API的API游乐场
项目描述
一个django应用,用于创建RESTful API的API探索器。
适用于任何RESTful API。例如,您可以使用此应用程序创建基于tastypie的API的API探索器。
演示: http://api-playground-demo.hipo.biz
说明
要运行此应用程序,请按照以下步骤操作
从pip安装
pip install django-api-playground
或从源安装
pip install git+git://github.com/Hipo/Django-API-Playground.git
添加到已安装的应用程序
INSTALLED_APPS =( # ... 'apiplayground', )
安装完成。现在您可以定义API模式。
第一步,创建一个URL
# urls.py from api.playgrounds import ExampleAPIPlayground urlpatterns = patterns('', (r'api-explorer/', include(ExampleAPIPlayground().urls)), )
第二步,定义您的API的子类
# api/playgrounds.py from apiplayground import APIPlayground class ExampleAPIPlayground(APIPlayground): schema = { "title": "API Playground", "base_url": "http://localhost/api/", "resources": [ { "name": "/feedbacks", "description": "This resource allows you to manage feedbacks.", "endpoints": [ { "method": "GET", "url": "/api/feedbacks/{feedback-id}", "description": "Returns a specific feedback item" }, { "method": "POST", "url": "/api/feedbacks/", "description": "Creates new feedback item", "parameters": [{ "name": "title", "type": "string" }, { "name": "resource", "type": "string" }, { "name": "description", "type": "string" }] } ] }, ] }
这就完成了。更详细的文档即将推出。