Skip to content

Latest commit

 

History

History
128 lines (98 loc) · 1.9 KB

snippets.md

File metadata and controls

128 lines (98 loc) · 1.9 KB
title type order
Snippets
api
3

Snippets API

NOTE -- All parameters are mandatory unless otherwise noted.

Get all snippets

GET /snippets

Sample Response:

[
    {
        "object": "snippet",
        "id": "snp_Q33jTLFc2ayG9KrF2Vcm4F",
        "name": "My First Snippet",
        "body": "<h1>Welcome!</h1>",
        "created": 5858858124,
        "modified": 5938868250
    }
]

Get specific snippet

GET /snippets/(:id)

Sample Response:

{
    "object": "snippet",
    "id": "snp_Q33jTLFc2ayG9KrF2Vcm4F",
    "name": "My First Snippet",
    "body": "<h1>Welcome!</h1>",
    "created": 5858858124,
    "modified": 5938868250
}

Creating a new snippet

POST /snippets

Params:

  • name -- Name of the snippet
  • body -- Contents for the snippet

Sample Request:

{
    "name": "My First Snippet",
    "body": "<h1>Welcome!</h1>"
}

Sample Response:

{
    "success": true,
    "status": "OK",
    "snippet": {
        "object": "snippet",
        "id": "snp_Q33jTLFc2ayG9KrF2Vcm4F",
        "name": "My First Snippet",
        "body": "<h1>Welcome!</h1>",
        "created": 5858858124,
        "modified": 5938868250
    }
}

Update an existing snippet

PUT /snippets/(:id)

Params:

  • name -- Name of the snippet
  • body -- Contents for the snippet

Sample Request:

{
    "name": "My First Snippet",
    "body": "<h1>Welcome!</h1>"
}

Sample Response:

{
    "success": true,
    "status": "OK",
    "snippet": {
        "object": "snippet",
        "id": "snp_Q33jTLFc2ayG9KrF2Vcm4F",
        "name": "My First Snippet",
        "body": "<h1>Welcome!</h1>",
        "created": 5858858124,
        "modified": 5938868250
    }
}

Delete an existing snippet

DELETE /snippets/(:id)

Sample Response:

{
    "success": true,
    "status": "OK"
}