2 1.4 API
Simon Vieille heeft deze pagina aangepast 2018-10-09 16:32:12 +02:00

Version < v1.7.0

Create a new gist

POST /{locale}/api/create Params:

  • form[title]: String (required, can be empty)
  • form[type]: String (required) Values: html, css, javascript, php, sql, xml, yaml, perl, c, asp, python, bash, actionscript3, text
  • form[content]: String (required)

Responses:

  • Code 405: Method Not Allowed
  • Code 400: Bad Request
  • Code 200: A json which contains gist's information. Example:
{
    "url": "https:\/\/gist.deblan.org\/en\/view\/55abcfa7771e0\/f4afbf72967dd95e3461490dcaa310d728d6a97d",
    "gist": {
        "Id": 66,
        "Title": "test prod",
        "Cipher": false,
        "Type": "javascript",
        "File": "55abcfa7771e0",
        "CreatedAt": "2015-07-19T16:26:15Z",
        "UpdatedAt": "2015-07-19T16:26:15Z"
    }
}

Update an existing gist

POST /{locale}/api/update/{id} Params:

  • {id}: Gist Id (required)
  • form[content]: String (required)

Responses:

  • Code 405: Method Not Allowed
  • Code 400: Bad Request
  • Code 200: A json which contains gist's information. Example:
{
    "url": "https:\/\/gist.deblan.org\/en\/view\/55abcfa7771e0\/abcgi72967dd95e3461490dcaa310d728d6adef",
    "gist": {
        "Id": 66,
        "Title": "test prod",
        "Cipher": false,
        "Type": "javascript",
        "File": "55abcfa7771e0",
        "CreatedAt": "2015-07-19T16:26:15Z",
        "UpdatedAt": "2015-07-19T16:30:15Z"
    }
}

Version >= v1.7.0

Invalid response codes:

  • Code 401: Unauthorized
  • Code 403: API not enabled
  • Code 405: Method Not Allowed
  • Code 400: Bad Request

List gists

GET /{locale}/api/list/{apiToken}

Response example:

[
    {
        "id": 66,
        "title": "test prod",
        "cipher": false,
        "type": "javascript",
        "file": "55abcfa7771e0",
        "createdAt": "2015-07-19T16:26:15Z",
        "updatedAt": "2015-07-19T16:30:15Z"
        "url": "https:\/\/gist.deblan.org\/en\/view\/55abcfa7771e0\/abcgi72967dd95e3461490dcaa310d728d6adef",
    },
    {
        "id": 67,
        "title": "test prod 2",
        "cipher": false,
        "type": "javascript",
        "file": "xyzbcfa7771e0",
        "createdAt": "2015-08-19T16:26:15Z",
        "updatedAt": "2015-08-19T16:30:15Z"
        "url": "https:\/\/gist.deblan.org\/en\/view\/5byzbcfa7771e0\/def72967dd95e346koq0dcaa310d728d6artu",
    },
    ...
]

Create a new gist

POST /{locale}/api/create/{apiToken} Params:

  • form[title]: String (required, can be empty)
  • form[type]: String (required) Values: html, css, javascript, php, sql, xml, yaml, perl, c, asp, python, bash, actionscript3, text
  • form[content]: String (required)

Response example:

{
    "url": "https:\/\/gist.deblan.org\/en\/view\/55abcfa7771e0\/f4afbf72967dd95e3461490dcaa310d728d6a97d",
    "gist": {
        "id": 66,
        "title": "test prod",
        "cipher": false,
        "type": "javascript",
        "file": "55abcfa7771e0",
        "createdAt": "2015-07-19T16:26:15Z",
        "updatedAt": "2015-07-19T16:26:15Z"
    }
}

Update an existing gist

POST /{locale}/api/update/{id}/{apiToken} Params:

  • {id}: Gist Id (required)
  • form[content]: String (required)

Response example:

{
    "url": "https:\/\/gist.deblan.org\/en\/view\/55abcfa7771e0\/abcgi72967dd95e3461490dcaa310d728d6adef",
    "gist": {
        "id": 66,
        "title": "test prod",
        "cipher": false,
        "type": "javascript",
        "file": "55abcfa7771e0",
        "createdAt": "2015-07-19T16:26:15Z",
        "updatedAt": "2015-07-19T16:30:15Z"
    }
}

Delete an existing gist

POST /{locale}/api/delete/{id}/{apiToken}

Response code 200:

{"error":false}

Response code 400:

{"message":"Invalid Gist", "error":true}

Previous: 1.3-Upgrade / Next: 1.5-Console