<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="utf-8" /><title>API design style guide — APIJSON Doc 1.0.0 documentation</title><link rel="stylesheet" href="../_static/alabaster.css" type="text/css" /><link rel="stylesheet" href="../_static/pygments.css" type="text/css" /><link rel="stylesheet" type="text/css" href="../_static/contentui.css" /><script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script><script type="text/javascript" src="../_static/jquery.js"></script><script type="text/javascript" src="../_static/underscore.js"></script><script type="text/javascript" src="../_static/doctools.js"></script><script type="text/javascript" src="../_static/language_data.js"></script><script type="text/javascript" src="../_static/contentui.js"></script><link rel="index" title="Index" href="../genindex.html" /><link rel="search" title="Search" href="../search.html" /><link rel="prev" title="API design style guide" href="design_rules.html" /><link rel="stylesheet" href="../_static/custom.css" type="text/css" /><meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" /></head><body><div class="document"><div class="documentwrapper"><div class="bodywrapper"><div class="body" role="main"><div class="section" id="api-design-style-guide"><h1>API design style guide<a class="headerlink" href="#api-design-style-guide" title="Permalink to this headline">¶</a></h1><div class="section" id="methods-and-api-endpoints"><h2>1. Methods and API endpoints<a class="headerlink" href="#methods-and-api-endpoints" title="Permalink to this headline">¶</a></h2><p><strong>GET</strong> : A general way to get counts. You can use dev tools to make edits in a web browser.</p><p>Base_url/get/</p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><blockquote><div><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>{TableName{// conditions.}}// eg. To get a post with id = 235:{"Post"{"id": 235}}</pre></div></div></div></blockquote></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><blockquote><div><div class="highlight-json notranslate"><div class="highlight"><pre><span></span> {TableName:{ ... },"code":200,"msg":"success"}// eg.{"Moment":{ "id":235, "userId":38710, "content":".."},"code":200,"msg":"success"}</pre></div></div></div></blockquote></div></div><p><strong>HEAD</strong> : A general way to get counts. You can use dev tools to make edits in a web browser.</p><p>Base_url/head/</p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>{TableName:{...}}// eg. Get the number of posts posted by the user with id =38710:{"Post":{"userId":38710}}</pre></div></div></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>{TableName:{"code":200, "msg":"success", "count":10},"code":200,"msg":"success"}// eg.{"Post":{"code":200, "msg":"success", "count":10},"code":200,"msg":"success"}</pre></div></div></div></div><p><strong>GETS</strong> : Get data with high security and confidentiality like bank accounts, birth date.</p><p>Base_url/gets/</p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><blockquote><div><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>// You need to add "tag": tag with the same level of post{}. Others are the same as **GET**.</pre></div></div></div></blockquote></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><blockquote><div><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>// Same as **GET**</pre></div></div></div></blockquote></div></div><p><strong>HEADS</strong> : Get counts of confidential data(eg. bank account).</p><p>Base_url/heads/</p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>// You need to add "tag": tag with the same level of post{}. Others are the same as HEAD.</pre></div></div></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>// Same as HEAD.</pre></div></div></div></div><p><strong>POST</strong> : Add new data to the database.</p><p>Base_url/post/</p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>{TableName:{...},"tag":tag}// The id in {...} is generated automatically when table is built and can’t be set by the user.// eg. A user with id = 38710 posts a new post:{"Post":{"userId":38710,"content":"APIJSON,let interfaces and documents go to hell !"},"tag":"Moment"}</pre></div></div></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span> {TableName:{"code":200,"msg":"success","id":38710},"code":200,"msg":"success"}// eg.{"Moment":{"code":200,"msg":"success","id":120},"code":200,"msg":"success"}</pre></div></div></div></div><p><strong>PUT</strong> : Make changes to a specific item. Only change the part sent to server.</p><p>Base_url/put/</p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span> {TableName:{"id":id,...},"tag":tag}// You can also add multiple id as id{}.// eg. Make changes to post content with id= 235:{"Post":{"id":235,"content":"APIJSON,let interfaces and documents go to hell !"},"tag":"Post"}</pre></div></div></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><blockquote><div><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>\\ Same as POST.</pre></div></div></div></blockquote></div></div><p><strong>DELETE</strong> : Delete data.</p><p>Base_url/delete/</p><div class="content-tabs docutils container"><div class="tab-content docutils container" id="tab-tab1"><p class="tab-title">Request</p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>{TableName:{"id":id},"tag":tag}// You can also add multiple id as id{}.// Or Delete contents with multiple id:{"Comment":{"id{}":[100,110,120]},"tag":"Comment[]"}</pre></div></div></div><div class="tab-content docutils container" id="tab-tab2"><p class="tab-title">Response</p><div class="highlight-json notranslate"><div class="highlight"><pre><span></span>{TableName:{"id":id},"tag":tag}// You can also add multiple id as id{}.// Or Delete contents with multiple id:{"Comment":{"id{}":[100,110,120]},"tag":"Comment[]"}</pre></div></div></div></div><p><strong>Note:</strong></p><blockquote><div><ol class="arabic simple"><li><p>TableName means the name of the table where you get data. It’ll respond with a JSON Object(the form is {....})with columns inside.</p></li><li><p>"tag":tag is needed when methods are not GET or HEAD. The tag after the colon is the key in JSON Object of making requests. Generally, it’s the name of the table you’re looking for.</p></li><li><p>GET, HEAD are methods for general data requests.They support versatile JSON Object structure. Other methods are used for requesting confidential data and the requesting JSON Object needs to be in the same form/order as that in the database. Otherwise, the request shall be denied.</p></li><li><p>GETS and GET, HEADS and HEAD return the same type of data. But the request form is a little different.</p></li><li><p>For HTTP, all API methods (get,gets,head,heads,post,put,delete) make requests with HTTP POST.</p></li><li><p>All JSON Objects here are with {...} form. You can put items or objects in it.</p></li><li><p>Each object in the database has a unique address.</p></li></ol></div></blockquote></div></div></div></div></div><div class="sphinxsidebar" role="navigation" aria-label="main navigation"><div class="sphinxsidebarwrapper"><h1 class="logo"><a href="../index.html">APIJSON Doc</a></h1><h3>Navigation</h3><p class="caption"><span class="caption-text">Quick Start</span></p><ul><li class="toctree-l1"><a class="reference internal" href="../introduction/introduction.html">Features</a></li><li class="toctree-l1"><a class="reference internal" href="../quick_start/server_deployment/server_deployment.html">Server-side Development</a></li><li class="toctree-l1"><a class="reference internal" href="../quick_start/client_deployment/client_deployment.html">Client-side Development</a></li></ul><p class="caption"><span class="caption-text">Documentation</span></p><ul class="current"><li class="toctree-l1"><a class="reference internal" href="design_rules.html">API design style guide</a></li><li class="toctree-l1 current"><a class="current reference internal" href="#">API design style guide</a><ul><li class="toctree-l2"><a class="reference internal" href="#methods-and-api-endpoints">1. Methods and API endpoints</a></li></ul></li></ul><div class="relations"><h3>Related Topics</h3><ul><li><a href="../index.html">Documentation overview</a><ul><li>Previous: <a href="design_rules.html" title="previous chapter">API design style guide</a></li></ul></li></ul></div><div id="searchbox" style="display: none" role="search"><h3 id="searchlabel">Quick search</h3><div class="searchformwrapper"><form class="search" action="../search.html" method="get"><input type="text" name="q" aria-labelledby="searchlabel" /><input type="submit" value="Go" /></form></div></div><script type="text/javascript">$('#searchbox').show(0);</script></div></div><div class="clearer"></div></div><div class="footer">©2019, Ruoran Wang.|Powered by <a href="http://sphinx-doc.org/">Sphinx 2.1.2</a>& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>|<a href="../_sources/documentation/forms.rst.txt"rel="nofollow">Page source</a></div></body></html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。