repository Resource

Overview

Use this resource to get information associated with an individual Bitbucket Cloud repository. You can use these calls with public or private repositories. Private repositories require the caller to authenticate with an account that has the appropriate authorization. You can also use the UUID of the repository for more information see, Universally Unique Identifier.

GET a repository

Returns a single repository.

Parameter
Required?
Description
ownerYesThe accountname of the repo owner.
repo_slugYesThe repository slug.
GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}
Click here to expand...
{
    "scm": "hg",
    "has_wiki": true,
    "description": "Site for tutorial101 files",
    "links": {
        "watchers": {
            "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/watchers"
        },
        "commits": {
            "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/commits"
        },
        "self": {
            "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org"
        },
        "html": {
            "href": "https://bitbucket.org/tutorials/tutorials.bitbucket.org"
        },
        "avatar": {
            "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2012/Nov/28/tutorials.bitbucket.org-logo-1456883302-9_avatar.png"
        },
        "forks": {
            "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/forks"
        },
        "clone": [{
            "href": "https://bitbucket.org/tutorials/tutorials.bitbucket.org",
            "name": "https"
        }, {
            "href": "ssh://hg@bitbucket.org/tutorials/tutorials.bitbucket.org",
            "name": "ssh"
        }],
        "pullrequests": {
            "href": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/pullrequests"
        }
    },
    "fork_policy": "allow_forks",
    "name": "tutorials.bitbucket.org",
    "language": "html/css",
    "created_on": "2011-12-20T16:35:06.480042+00:00",
    "full_name": "tutorials/tutorials.bitbucket.org",
    "has_issues": true,
    "owner": {
        "username": "tutorials",
        "display_name": "tutorials account",
        "uuid": "{c788b2da-b7a2-404c-9e26-d3f077557007}",
        "links": {
            "self": {
                "href": "https://api.bitbucket.org/2.0/users/tutorials"
            },
            "html": {
                "href": "https://bitbucket.org/tutorials"
            },
            "avatar": {
                "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Nov/25/tutorials-avatar-1563784409-6_avatar.png"
            }
        }
    },
    "updated_on": "2014-11-03T02:24:08.409995+00:00",
    "size": 76182262,
    "is_private": false,
    "uuid": "{9970a9b6-2d86-413f-8555-da8e1ac0e542}"
}

POST a new repository

To create a new repository, POST directly to the desired URL, providing a JSON request body that contains the properties of the new repository.

Parameter
Required?
Description
ownerYesThe account of the repo owner.
repo_slugYesThe repository slug.

The POST body should match the repository object layout, but only a subset of its properties need to be specified:

Field nameDescription
scmThe SCM type for the new repo. Either "hg" or "git". When omitted, the type of your most recently created repository will be used (optional).

name

The name for the repository. When omitted, this assumes that value of the repo_slug part of the URL (optional).
is_privateWhether the repository should be public (false) or private (true).
descriptionThe human readable description of the repository (optional).
fork_policy

Control the rules for forking this repository. Available values are:

  • allow_forks: unrestricted forking
  • no_public_forks: restrict forking to private forks (forks cannot be made public later)
  • no_forks: deny all forking
languageThe programming language used in the repository. Must be a valid (lowercase) item as shown in the drop-down list on the repository's admin page (optional).
has_issuesWhether the repository should have an issue tracker (optional – defaults to false).
has_wikiWhether the repository should have a wiki (optional – defaults to false).
POST https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug
$ curl -X POST -v -u username:password -H "Content-Type: application/json" \
  https://api.bitbucket.org/2.0/repositories/teamsinspace/new-repository4 \
  -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }'

DELETE a repository

Removes a repository and any associated Wiki and Issue tracker. A 204 NO CONTENT message is returned on success.

This is a destructive action which completely deletes the repository, issue tracker, and wiki. Be sure you have backed up all the data you need before deleting a repository.

Parameter
Required?
Description
ownerYesThe account name of the repo owner.
repo_slugYesThe repository slug.
DELETE https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug} 

GET a list of watchers

Gets the list of accounts watching a repository. 

Parameter
Required?
Description
ownerYesThe account of the repo owner.
repo_slugYesThe repository slug.
GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/watchers
Click here to expand...
{
    "pagelen": 10,
    "next": "https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/watchers?page=2",
    "values": [{
        "username": "tutorials",
        "display_name": "tutorials account",
        "uuid": "{c788b2da-b7a2-404c-9e26-d3f077557007}",
        "links": {
            "self": {
                "href": "https://api.bitbucket.org/2.0/users/tutorials"
            },
            "html": {
                "href": "https://bitbucket.org/tutorials"
            },
            "avatar": {
                "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Nov/25/tutorials-avatar-1563784409-6_avatar.png"
            }
        ...
    }, 
    }],
    "page": 1,
    "size": 35
}

GET a list of forks

Gets the list of repository forks, This call returns a repository object for each fork.

Parameter
Required?
Description
ownerYesThe account of the repo owner.
repo_slugYesThe repository slug.
GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo_slug}/forks
Click here to expand...
{
    "pagelen": 10,
    "next": "https://api.bitbucket.org/2.0/repositories/tutorials/bucket-o-sand/forks?page=2",
    "values": [{
        "scm": "git",
        "has_wiki": false,
        "description": "",
        "links": {
            "watchers": {
                "href": "https://api.bitbucket.org/2.0/repositories/Hitol/tutorial/watchers"
            },
            "commits": {
                "href": "https://api.bitbucket.org/2.0/repositories/Hitol/tutorial/commits"
            },
            "self": {
                "href": "https://api.bitbucket.org/2.0/repositories/Hitol/tutorial"
            },
            "html": {
                "href": "https://bitbucket.org/Hitol/tutorial"
            },
            "avatar": {
                "href": "https://d3oaxc4q5k2d6q.cloudfront.net/m/83c512cdf761/img/language-avatars/default_16.png"
            },
            "forks": {
                "href": "https://api.bitbucket.org/2.0/repositories/Hitol/tutorial/forks"
            },
            "clone": [{
                "href": "https://dan-test@bitbucket.org/Hitol/tutorial.git",
                "name": "https"
            }, {
                "href": "ssh://git@bitbucket.org/Hitol/tutorial.git",
                "name": "ssh"
            }],
            "pullrequests": {
                "href": "https://api.bitbucket.org/2.0/repositories/Hitol/tutorial/pullrequests"
            }
        },
        "fork_policy": "allow_forks",
        "name": "Tutorial",
        "language": "",
        "created_on": "2014-08-29T21:29:52.483296+00:00",
        "parent": {
            "links": {
                "self": {
                    "href": "https://api.bitbucket.org/2.0/repositories/tutorials/bucket-o-sand"
                },
                "html": {
                    "href": "https://bitbucket.org/tutorials/bucket-o-sand"
                },
                "avatar": {
                    "href": "https://d3oaxc4q5k2d6q.cloudfront.net/m/83c512cdf761/img/language-avatars/default_16.png"
                }
            },
            "uuid": "{7d5f444f-5575-4cc2-9ed3-65c3f7bcc711}",
            "full_name": "tutorials/bucket-o-sand",
            "name": "bucket-o-sand"
        },
        "full_name": "Hitol/tutorial",
        "has_issues": false,
        "owner": {
            "username": "Hitol",
            "display_name": "Hitol",
            "uuid": "{3a8750bd-65e3-4089-b125-1e2b53f1578d}",
            "links": {
                "self": {
                    "href": "https://api.bitbucket.org/2.0/users/Hitol"
                },
                "html": {
                    "href": "https://bitbucket.org/Hitol"
                },
                "avatar": {
                    "href": "https://secure.gravatar.com/avatar/340ea1dc0a5e7603181cf972a02bf1cb?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2F83c512cdf761%2Fimg%2Fdefault_avatar%2F32%2Fuser_blue.png&s=32"
                }
            }
        },
        "updated_on": "2014-08-29T21:29:52.520672+00:00",
        "size": 75703,
        "is_private": false,
        "uuid": "{2329cc2e-2180-4619-b2eb-879cc8466c75}"
    }, ],
    "page": 1,
    "size": 336
}
Last modified on Dec 21, 2015

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.