Get snippets of current user

GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets
CODE
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets
CODE
Sample response
{
  "size": 1,
  "limit": 25,
  "isLastPage": true,
  "values": [{
    "guid": "87dec410f4404d4ca43dc4772a8bd0f0",
    "name": "Example Snippet",
    "description": "Example description...",
    "categories": [{
      "guid": "2f7c939e273f4d29b60f08f9a508298a",
      "name": "Example Category"
    }],
    "isVisible": true,
    "isPublic": false,
    "userId": 1,
    "createdAt": 1379175213548,
    "updatedAt": 1379175745710,
    "files": [{
      "guid": "bda2ce737fce4cc19ba00cafc5c9f33d",
      "name": "example.sql",
      "content": "SELECT * FROM examples"
    }],
    "comments": [{
        "guid": "6b90147977bb42f782610f0211a94cfc",
        "text": "This is a comment...",
        "userId": 1,
        "createdAt": 1431174442000,
        "updatedAt": 1431174442000
    }]
  }],
  "start": 0
}
JSON

Get starred snippets of current user

GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/starred
CODE
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/starred
CODE
Sample response
{
  "size": 1,
  "limit": 25,
  "isLastPage": true,
  "values": [{
    "snippet": {
      "guid": "87dec410f4404d4ca43dc4772a8bd0f0",
      "name": "Example Snippet",
      "description": "Example description...",
      "categories": [{
        "guid": "2f7c939e273f4d29b60f08f9a508298a",
        "name": "Example Category"
      }],
      "isVisible": true,
      "isPublic": false,
      "userId": 1,
      "createdAt": 1379175213548,
      "updatedAt": 1379175745710,
      "files": [{
        "guid": "bda2ce737fce4cc19ba00cafc5c9f33d",
        "name": "example.sql",
        "content": "SELECT * FROM examples"
      }],
      "comments": [{
          "guid": "6b90147977bb42f782610f0211a94cfc",
          "text": "This is a comment...",
          "userId": 1,
          "createdAt": 1431174442000,
          "updatedAt": 1431174442000
      }]
    },
    "userId": 1,
    "starredAt": 1379177521715
  }],
  "start": 0
}
CODE

Browse snippets

GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/browse
CODE
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/browse
CODE
Sample response
{
  "size": 1,
  "limit": 25,
  "isLastPage": true,
  "values": [{
    "guid": "87dec410f4404d4ca43dc4772a8bd0f0",
    "name": "Example Snippet",
    "description": "Example description...",
    "categories": [{
      "guid": "2f7c939e273f4d29b60f08f9a508298a",
      "name": "Example Category"
    }],
    "isVisible": true,
    "isPublic": false,
    "userId": 1,
    "createdAt": 1379175213548,
    "updatedAt": 1379175745710,
    "files":[{
      "guid": "bda2ce737fce4cc19ba00cafc5c9f33d",
      "name": "example.sql",
      "content": "SELECT * FROM examples"
    }],
    "comments": [{
        "guid": "6b90147977bb42f782610f0211a94cfc",
        "text": "This is a comment...",
        "userId": 1,
        "createdAt": 1431174442000,
        "updatedAt": 1431174442000
    }]
  }],
  "start": 0
}
JSON

Browse snippets of user

GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/browse?username={username}
CODE
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/browse?username=johndoe
CODE
Sample response
{
  "size": 1,
  "limit": 25,
  "isLastPage": true,
  "values": [{
    "guid": "87dec410f4404d4ca43dc4772a8bd0f0",
    "name": "Example Snippet",
    "description": "Example description...",
    "categories": [{
      "guid": "2f7c939e273f4d29b60f08f9a508298a",
      "name": "Example Category"
    }],
    "isVisible": true,
    "isPublic": false,
    "userId": 1,
    "createdAt": 1379175213548,
    "updatedAt": 1379175745710,
    "files":[{
      "guid": "bda2ce737fce4cc19ba00cafc5c9f33d",
      "name": "example.sql",
      "content": "SELECT * FROM examples"
    }],
    "comments": [{
        "guid": "6b90147977bb42f782610f0211a94cfc",
        "text": "This is a comment...",
        "userId": 1,
        "createdAt": 1431174442000,
        "updatedAt": 1431174442000
    }]
  }],
  "start": 0
}
CODE

Get snippets of category

GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/categories/{guid}
CODE
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/categories/2f7c939e273f4d29b60f08f9a508298a
CODE
Sample response
{
  "size": 1,
  "limit": 25,
  "isLastPage": true,
  "values": [{
    "snippet": {
      "guid": "87dec410f4404d4ca43dc4772a8bd0f0",
      "name": "Example Snippet",
      "description": "Example description...",
      "categories": [{
        "guid": "2f7c939e273f4d29b60f08f9a508298a",
        "name": "Example Category"
      }],
      "isVisible": true,
      "isPublic": false,
      "userId": 1,
      "createdAt": 1379175213548,
      "updatedAt": 1379175745710,
      "files": [{
        "guid": "bda2ce737fce4cc19ba00cafc5c9f33d",
        "name": "example.sql",
        "content": "SELECT * FROM examples"
      }],
      "comments": [{
          "guid": "6b90147977bb42f782610f0211a94cfc",
          "text": "This is a comment...",
          "userId": 1,
          "createdAt": 1431174442000,
          "updatedAt": 1431174442000
      }]
    },
    "userId": 1,
    "starredAt": 1379177521715
  }],
  "start": 0
}
JSON

Get snippet by GUID

GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{guid}
CODE
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/87dec410f4404d4ca43dc4772a8bd0f0
CODE
Sample response
{
  "guid": "87dec410f4404d4ca43dc4772a8bd0f0",
  "name": "Example Snippet",
  "description": "Example description...",
  "categories": [{
    "guid": "2f7c939e273f4d29b60f08f9a508298a",
    "name": "Example Category"
  }],
  "isVisible": true,
  "isPublic": false,
  "userId": 1,
  "createdAt": 1379175213548,
  "updatedAt": 1379175745710,
  "files": [{
    "guid": "bda2ce737fce4cc19ba00cafc5c9f33d",
    "name": "example.sql",
    "content": "SELECT * FROM examples"
  }],
  "comments": [{
      "guid": "6b90147977bb42f782610f0211a94cfc",
      "text": "This is a comment...",
      "userId": 1,
      "createdAt": 1431174442000,
      "updatedAt": 1431174442000
  }]
}
JSON

Get comment by GUID

GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{snippetGuid}/comments/{commentGuid}
CODE
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/87dec410f4404d4ca43dc4772a8bd0f0/comments/6b90147977bb42f782610f0211a94cfc
CODE
Sample response
{
  "guid": "6b90147977bb42f782610f0211a94cfc",
  "text": "This is a comment...",
  "userId": 1,
  "createdAt": 1431174442000,
  "updatedAt": 1431174442000
}
JSON

Create snippet

POST http://{host}:{port}/{context}/rest/snippets/1.0/snippets
CODE
curl -X POST -u username:password -H "Content-Type:application/json" -d '{ "name" : "Example Snippet", "files" : [{ "name" : "example.sql", "content" : "SELECT * FROM examples" }] }' http://bitbucket.example.com/rest/snippets/1.0/snippets
CODE
Sample response
{
  "guid": "87dec410f4404d4ca43dc4772a8bd0f0",
  "name": "Example Snippet",
  "categories": [],
  "isVisible": true,
  "isPublic": false,
  "userId": 1,
  "createdAt": 1379175213548,
  "updatedAt": 1379175745710,
  "files": [{
    "guid": "bda2ce737fce4cc19ba00cafc5c9f33d",
    "name": "example.sql",
    "content": "SELECT * FROM examples"
  }],
  "comments": []
}
JSON

Create comment

POST http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{guid}/comments
CODE
curl -X POST -u username:password -H "Content-Type:application/json" -d '{ "text" : "This is a comment..." }' http://bitbucket.example.com/rest/snippets/1.0/snippets/87dec410f4404d4ca43dc4772a8bd0f0/comments
CODE
Sample response
{
  "guid": "6b90147977bb42f782610f0211a94cfc",
  "text": "This is a comment...",
  "userId": 1,
  "createdAt": 1431174442000,
  "updatedAt": 1431174442000
}
JSON

Update snippet

PUT http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{guid}
CODE
curl -X PUT -u username:password -H "Content-Type:application/json" -d '{ "name" : "Example Snippet", "description" : "Example description...", "categories" : [ "Example Category" ], "files" : [{ "name" : "example.sql", "content" : "SELECT * FROM examples" }] }' http://bitbucket.example.com/rest/snippets/1.0/snippets/87dec410f4404d4ca43dc4772a8bd0f0
CODE
Sample response
{
  "guid": "87dec410f4404d4ca43dc4772a8bd0f0",
  "name": "Example Snippet",
  "description": "Example description...",
  "categories": [{
    "guid": "2f7c939e273f4d29b60f08f9a508298a",
    "name": "Example Category"
  }],
  "isVisible": true,
  "isPublic": false,
  "userId": 1,
  "createdAt": 1379175213548,
  "updatedAt": 1379180600230,
  "files": [{
    "guid": "0c7e081403ba49b4a4c0113d2d9933a5",
    "name": "example.sql",
    "content": "SELECT * FROM examples"
  }],
  "comments": []
}
JSON

Update comment

PUT http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{snippetGuid}/comments/{commentGuid}
CODE
curl -X PUT -u username:password -H "Content-Type:application/json" -d '{ "text" : "This is another comment..." }' http://bitbucket.example.com/rest/snippets/1.0/snippets/87dec410f4404d4ca43dc4772a8bd0f0/comments/6b90147977bb42f782610f0211a94cfc
CODE
Sample response
{
  "guid": "6b90147977bb42f782610f0211a94cfc",
  "text": "This is a comment...",
  "userId": 1,
  "createdAt": 1431174442000,
  "updatedAt": 1431176876101
}
JSON

Delete snippet

DELETE http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{guid}
CODE
curl -X DELETE -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/87dec410f4404d4ca43dc4772a8bd0f0
CODE

Delete comment

DELETE http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{snippetGuid}/comments/{commentGuid}
CODE
curl -X DELETE -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/87dec410f4404d4ca43dc4772a8bd0f0/comments/6b90147977bb42f782610f0211a94cfc
CODE