Skip to end of metadata
Go to start of metadata

Overview

Use this resource to get information associated with an individual 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.

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...

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).
forking_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

DELETE a repository

Removes 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://bitbucket.org/api/2.0/{owner}/{repo_slug}/watchers
 Click here to expand...

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://bitbucket.org/api/2.0/{owner}/{repo_slug}/forks
 Click here to expand...
  • No labels

8 Comments

  1. Anonymous

    When I try to create a new repository with a repo_slug containing a colon, I get back the error: "Invalid URL slug value. Slugs must be limited to ASCII word characters.". This seems weird because I can create repositories in bitbucket with a colon. Is there a way to create this repository through the API?

  2. Anonymous

    The name can contain a colon, the slug cannot.

  3. Anonymous

    How can I grant to other users access to repository?

  4. What's the difference between repo_slug and name? When I want to create a new repo with POST I need to post repo_slug, not name?

    And when I receive repo with GET I get no repo_slug?

    Seems to be a bit mixed(smile) How to make consistent java->json->java mapping when there seems to be no logic in names? Please let me (us) know if there is logic that I don't get(smile)

    1. repo_slug is how the repo should appear in the URL. name is how it appears on the pages.

    2. Mohammad is correct (thanks!) so in the url for the tutorials repository

      So in this example:

      https://bitbucket.org/teamsinspace/space-repository

      space-repository is the repo_slug

       

  5. forking_policy does not work as documented which implies \{ ... "forking_policy": "no_public_forks" ... \} for private only forking. Repositories are created allowing public forking. Adding \{ ... "no_public_forks": true ...\} to the payload gave me private only forking.

    1. I'm looking into this. Will try to get a response by tomorrow am, alternatively check in with our support team, or click the link for Get Support below.