Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Get snippets of current user

Code Block
GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets
Code Block
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets
Expand
titleSample response
Code Block
languagejson
{
  "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
}

Get starred snippets of current user

Code Block
GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/starred
Code Block
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/starred
Expand
titleSample response
Code Block
{
  "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
}

Browse snippets

Code Block
GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/browse
Code Block
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/browse
Expand
titleSample response
Code Block
languagejson
{
  "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
}

Browse snippets of user

Code Block
GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/browse?username={username}
Code Block
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/browse?username=johndoe
Expand
titleSample response
Code Block
{
  "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
}

Get snippets of category

Code Block
GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/categories/{guid}
Code Block
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/categories/2f7c939e273f4d29b60f08f9a508298a
Expand
titleSample response
Code Block
languagejson
{
  "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
}

Get snippet by GUID

Code Block
GET http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{guid}
Code Block
curl -u username:password -H "Content-Type:application/json" http://bitbucket.example.com/rest/snippets/1.0/snippets/87dec410f4404d4ca43dc4772a8bd0f0
Expand
titleSample response
Code Block
languagejson
{
  "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
  }]
}

Get comment by GUID

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

Create snippet

Code Block
POST http://{host}:{port}/{context}/rest/snippets/1.0/snippets
Code Block
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
Expand
titleSample response
Code Block
languagejson
{
  "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": []
}

Create comment

Code Block
POST http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{guid}/comments
Code Block
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
Expand
titleSample response
Code Block
languagejson
{
  "guid": "6b90147977bb42f782610f0211a94cfc",
  "text": "This is a comment...",
  "userId": 1,
  "createdAt": 1431174442000,
  "updatedAt": 1431174442000
}

Update snippet

Code Block
PUT http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{guid}
Code Block
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
Expand
titleSample response
Code Block
languagejson
{
  "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": []
}

Update comment

Code Block
PUT http://{host}:{port}/{context}/rest/snippets/1.0/snippets/{snippetGuid}/comments/{commentGuid}
Code Block
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
Expand
titleSample response
Code Block
languagejson
{
  "guid": "6b90147977bb42f782610f0211a94cfc",
  "text": "This is a comment...",
  "userId": 1,
  "createdAt": 1431174442000,
  "updatedAt": 1431176876101
}

Delete snippet

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

Delete comment

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