Skip to content

Instantly share code, notes, and snippets.

@solancer
Forked from iros/API.md
Last active February 20, 2018 10:23

Revisions

  1. solancer revised this gist Feb 20, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion EXAMPLE.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@

    `GET`

    * **URL Params**
    * **URL Params / Authorization Headers in case applicable**

    **Required:**

  2. @iros iros revised this gist Aug 22, 2012. 2 changed files with 105 additions and 1 deletion.
    57 changes: 56 additions & 1 deletion API.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,56 @@
    | title | _Name of your API Call_ |
    **Title**
    ----
    <_Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple)._>

    * **URL**

    <_The URL Structure (path only, no root url)_>

    * **Method:**

    <_The request type_>

    `GET` | `POST` | `DELETE` | `PUT`

    * **URL Params**

    <_If URL params exist, specify them in accordance with name mentioned in URL section. Separate into optional and required. Document data constraints._>

    **Required:**

    `id=[integer]`

    **Optional:**

    `photo_id=[alphanumeric]`

    * **Data Params**

    <_If making a post request, what should the body payload look like? URL Params rules apply here too._>

    * **Success Response:**

    <_What should the status code be on success and is there any returned data? This is useful when people need to to know what their callbacks should expect!_>

    * **Code:** 200 <br />
    **Content:** `{ id : 12 }`

    * **Error Response:**

    <_Most endpoints will have many ways they can fail. From unauthorized access, to wrongful parameters etc. All of those should be liste d here. It might seem repetitive, but it helps prevent assumptions from being made where they should be._>

    * **Code:** 401 UNAUTHORIZED <br />
    **Content:** `{ error : "Log in" }`

    OR

    * **Code:** 422 UNPROCESSABLE ENTRY <br />
    **Content:** `{ error : "Email Invalid" }`

    * **Sample Call:**

    <_Just a sample call to your endpoint in a runnable format ($.ajax call or a curl request) - this makes life easier and more predictable._>

    * **Notes:**

    <_This is where all uncertainties, commentary, discussion etc. can go. I recommend timestamping and identifying oneself when leaving comments here._>
    49 changes: 49 additions & 0 deletions EXAMPLE.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    **Show User**
    ----
    Returns json data about a single user.

    * **URL**

    /users/:id

    * **Method:**

    `GET`

    * **URL Params**

    **Required:**

    `id=[integer]`

    * **Data Params**

    None

    * **Success Response:**

    * **Code:** 200 <br />
    **Content:** `{ id : 12, name : "Michael Bloom" }`

    * **Error Response:**

    * **Code:** 404 NOT FOUND <br />
    **Content:** `{ error : "User doesn't exist" }`

    OR

    * **Code:** 401 UNAUTHORIZED <br />
    **Content:** `{ error : "You are unauthorized to make this request." }`

    * **Sample Call:**

    ```javascript
    $.ajax({
    url: "/users/1",
    dataType: "json",
    type : "GET",
    success : function(r) {
    console.log(r);
    }
    });
    ```
  3. @iros iros created this gist Aug 22, 2012.
    1 change: 1 addition & 0 deletions API.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    | title | _Name of your API Call_ |