### Querying Examples Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Examples demonstrating how to use the querying language for various scenarios. ```APIDOC ## Querying Examples Objects can be filtered based on their properties. In principle, every element in an object's JSON document schema can be used as a filter criterion. Note that while the array of objects in a paginated response is wrapped in an envelope with a `values` element, this prefix should not be included in the query fields (so use `/2.0/repositories/foo/bar/issues?q=state="new"`, not `/2.0/repositories/foo/bar/issues?q=values.state="new"`). ### Traversing Embedded Objects Fields that contain embedded instances of other object types (e.g. owner is an embedded user object, while parent is an embedded repository) can be traversed recursively. For instance: `parent.owner.nickname = "bitbucket"` ### Pull Request Filtering To find pull requests which merge into master, come from a fork of the repo rather than a branch inside the repo, and on which I am a reviewer: `source.repository.full_name != "main/repo" AND state = "OPEN" AND reviewers.nickname = "evzijst" AND destination.branch.name = "master"` URL encoded example: `/2.0/repositories/main/repo/pullrequests?q=source.repository.full_name+%21%3D+%22main%2Frepo%22+AND+state+%3D+%22OPEN%22+AND+reviewers.nickname+%3D+%22evzijst%22+AND+destination.branch.name+%3D+%22master%22` ### Issue Filtering To find new or on-hold issues related to the UI, created or updated in the last day (SF local time), that have not yet been assigned to anyone: `state IN ("new", "on hold") AND assignee = null AND component = "UI" and updated_on > 2015-11-11T00:00:00-07:00` URL encoded example: `/2.0/repositories/main/repo/issues?q=state%20IN%20%28%22new%22%2C%20%22on%20hold%22%29%20AND%20assignee%20%3D%20null%20AND%20component%20%3D%20%22UI%22%20and%20updated%5Fon%20%3E%202015%2D11%2D11T00%3A00%3A00%2D07%3A00` ### Tag Filtering To find all tags with the string "2015" in the name: `name ~ "2015"` Example endpoint: `/2.0/repositories/{username}/{slug}/refs/tags?q=name+%7E+%222015%22` ### Branch Filtering Or all my branches: `name ~ "erik/"` Example endpoint: `/2.0/repositories/{username}/{slug}/refs/?q=name+%7E+%22erik%2F%22` ``` -------------------------------- ### Issue Tracker Query Examples Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Example filter queries for the issue tracker endpoint. ```text (state = "open" OR state = "new") AND assignee = null reporter.nickname != "evzijst" AND priority >= "major" (title ~ "unicode" OR content.raw ~ "unicode") AND created_on > 2015-10-04T14:00:00-07:00 ``` -------------------------------- ### URL Encoded Query Example Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Demonstrates how to pass a query string and sort parameter in a URL. ```text /2.0/repositories/foo/bar/issues?q=state="new"&sort=-updated_on ``` -------------------------------- ### CORS OPTIONS Request Example Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Shows a CORS preflight OPTIONS request to bitbucket.org with an origin header. The response includes CORS-specific headers like Access-Control-Allow-Origin and Access-Control-Allow-Methods. ```bash curl -i https://api.bitbucket.org -H "origin: http://bitbucket.com" -X OPTIONS ``` ```http HTTP/1.1 302 FOUND Server: nginx/1.6.2 Vary: Cookie Cache-Control: max-age=900 Content-Type: text/html; charset=utf-8 Access-Control-Expose-Headers: Accept-Ranges, Content-Encoding, Content-Length, Content-Type, ETag, Last-Modified Strict-Transport-Security: max-age=31536000 Date: Tue, 21 Jun 2016 18:04:30 GMT Access-Control-Max-Age: 86400 Location: http://confluence.atlassian.com/x/IYBGDQ X-Served-By: app-111 Access-Control-Allow-Origin: * X-Static-Version: 2c820eb0d2b3 ETag: "d41d8cd98f00b204e9800998ecf8427e" X-Content-Type-Options: nosniff X-Render-Time: 0.00371098518372 Connection: keep-alive X-Version: 2c820eb0d2b3 X-Frame-Options: SAMEORIGIN X-Request-Count: 357 Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS Access-Control-Allow-Headers: Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, Origin, Range, X-CsrftokenX-Requested-With X-Cache-Info: not cacheable; request wasn't a GET or HEAD Content-Length: 0 ``` -------------------------------- ### Team Members Response Example Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro This is an example of the JSON response when fetching team members. It includes details such as creation date, display name, links to related resources, and user information. ```json { "page": 1, "pagelen": 50, "size": 2, "values": [ { "created_on": "2011-12-20T16:34:07.132459+00:00", "display_name": "tutorials account", "links": { "avatar": { "href": "https://bitbucket.org/account/tutorials/avatar/32/" }, "followers": { "href": "https://api.bitbucket.org/2.0/users/tutorials/followers" }, "following": { "href": "https://api.bitbucket.org/2.0/users/tutorials/following" }, "hooks": { "href": "https://api.bitbucket.org/2.0/users/tutorials/hooks" }, "html": { "href": "https://bitbucket.org/tutorials/" }, "repositories": { "href": "https://api.bitbucket.org/2.0/repositories/tutorials" }, "self": { "href": "https://api.bitbucket.org/2.0/users/tutorials" }, "snippets": { "href": "https://api.bitbucket.org/2.0/snippets/tutorials" } }, "location": null, "type": "user", "username": "tutorials", "nickname": "tutorials", "account_status": "active", "uuid": "{c788b2da-b7a2-404c-9e26-d3f077557007}", "website": "https://tutorials.bitbucket.org/" }, { "created_on": "2013-12-10T14:44:13+00:00", "display_name": "Dan Stevens [Atlassian]", "links": { "avatar": { "href": "https://bitbucket.org/account/dans9190/avatar/32/" }, "followers": { "href": "https://api.bitbucket.org/2.0/users/dans9190/followers" }, "following": { "href": "https://api.bitbucket.org/2.0/users/dans9190/following" }, "hooks": { "href": "https://api.bitbucket.org/2.0/users/dans9190/hooks" }, "html": { "href": "https://bitbucket.org/dans9190/" }, "repositories": { "href": "https://api.bitbucket.org/2.0/repositories/dans9190" }, "self": { "href": "https://api.bitbucket.org/2.0/users/dans9190" }, "snippets": { "href": "https://api.bitbucket.org/2.0/snippets/dans9190" } }, "location": null, "type": "user", "username": "dans9190", "nickname": "dans9190", "account_status": "active", "uuid": "{1cd06601-cd0e-4fce-be03-e9ac226978b7}", "website": "" } ] } ``` -------------------------------- ### Fetch user details via cURL Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Example request to retrieve information for a specific Bitbucket user. ```bash $ curl https://api.bitbucket.org/2.0/users/tutorials ``` -------------------------------- ### CORS General Request Example Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Demonstrates a general request from an API to bitbucket.com with a specified origin header. This request results in a 302 Found redirect. ```bash curl -i https://api.bitbucket.org -H "origin: http://bitbucket.com" ``` ```http HTTP/1.1 302 FOUND Server: nginx/1.6.2 Vary: Cookie Cache-Control: max-age=900 Content-Type: text/html; charset=utf-8 Strict-Transport-Security: max-age=31536000 Date: Tue, 21 Jun 2016 17:54:37 GMT Location: http://confluence.atlassian.com/x/IYBGDQ X-Served-By: app-110 X-Static-Version: 2c820eb0d2b3 ETag: "d41d8cd98f00b204e9800998ecf8427e" X-Content-Type-Options: nosniff X-Render-Time: 0.00379920005798 Connection: Keep-Alive X-Version: 2c820eb0d2b3 X-Frame-Options: SAMEORIGIN X-Request-Count: 383 X-Cache-Info: cached Content-Length: 0 ``` -------------------------------- ### Bitbucket Repository Object Response Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro This is an example of the JSON response received when querying for repository details. It includes information such as creation date, description, owner, and project details. ```json { "created_on": "2013-11-08T01:11:03.222520+00:00", "description": "", "fork_policy": "allow_forks", "full_name": "1team/moxie", "has_issues": false, "has_wiki": false, "is_private": false, "language": "", "links": { "avatar": { "href": "https://bitbucket.org/1team/moxie/avatar/32/" }, "branches": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/refs/branches" }, "clone": [ { "href": "https://bitbucket.org/1team/moxie.git", "name": "https" }, { "href": "ssh://git@bitbucket.org/1team/moxie.git", "name": "ssh" } ], "commits": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/commits" }, "downloads": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/downloads" }, "forks": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/forks" }, "hooks": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/hooks" }, "html": { "href": "https://bitbucket.org/1team/moxie" }, "pullrequests": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/pullrequests" }, "self": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie" }, "tags": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/refs/tags" }, "watchers": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/watchers" } }, "name": "moxie", "owner": { "display_name": "the team", "links": { "avatar": { "href": "https://bitbucket.org/account/1team/avatar/32/" }, "html": { "href": "https://bitbucket.org/1team/" }, "self": { "href": "https://api.bitbucket.org/2.0/teams/1team" } }, "type": "team", "username": "1team", "uuid": "{aa559944-83c9-4963-a9a8-69ac8d9cf5d2}" }, "project": { "key": "PROJ", "links": { "avatar": { "href": "https://bitbucket.org/account/user/1team/projects/PROJ/avatar/32" }, "html": { "href": "https://bitbucket.org/account/user/1team/projects/PROJ" } }, "name": "Untitled project", "type": "project", "uuid": "{ab52aaeb-16ad-4fb0-bb1d-47e4f00367ff}" }, "scm": "git", "size": 33348, "type": "repository", "updated_on": "2013-11-08T01:11:03.263237+00:00", "uuid": "{21fa9bf8-b5b2-4891-97ed-d590bad0f871}", "website": "" } ``` -------------------------------- ### Get User by Username Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Retrieve a user's profile information by specifying their username in the API call. ```APIDOC ## GET /2.0/users/{username} ### Description Retrieves the profile information for a specific user identified by their username. ### Method GET ### Endpoint /2.0/users/{username} ### Parameters #### Path Parameters - **username** (string) - Required - The username of the user to retrieve. ### Request Example ```bash curl https://api.bitbucket.org/2.0/users/tutorials ``` ### Response #### Success Response (200) - **username** (string) - The user's username. - **nickname** (string) - The user's nickname. - **account_status** (string) - The current status of the user's account. - **website** (string) - The user's website URL. - **display_name** (string) - The user's display name. - **uuid** (string) - The user's unique identifier. - **links** (object) - Links to related resources. - **created_on** (string) - The date and time the user account was created. - **location** (string) - The user's location. - **type** (string) - The type of object, typically 'user'. #### Response Example ```json { "username": "tutorials", "nickname": "tutorials", "account_status": "active", "website": "https://tutorials.bitbucket.org/", "display_name": "tutorials account", "uuid": "{c788b2da-b7a2-404c-9e26-d3f077557007}", "links": { "self": { "href": "https://api.bitbucket.org/2.0/users/tutorials" }, "repositories": { "href": "https://api.bitbucket.org/2.0/repositories/tutorials" }, "html": { "href": "https://bitbucket.org/tutorials" }, "followers": { "href": "https://api.bitbucket.org/2.0/users/tutorials/followers" }, "avatar": { "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Nov/25/tutorials-avatar-1563784409-6_avatar.png" }, "following": { "href": "https://api.bitbucket.org/2.0/users/tutorials/following" } }, "created_on": "2011-12-20T16:34:07.132459+00:00", "location": "Santa Monica, CA", "type": "user" } ``` ``` -------------------------------- ### Self link structure Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Example of a self-referencing link object containing a rel key and an href. ```json "self": { "href": "https://api.bitbucket.org/api/2.0/users/tutorials" } ``` -------------------------------- ### Recursive Field Traversal Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Example of traversing embedded object properties in a query. ```text parent.owner.nickname = "bitbucket" ``` -------------------------------- ### Get Repository by Team and Repository Name Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro This endpoint retrieves repository information using the team name and repository name. ```APIDOC ## GET /api/v2.0/repositories/{team_name}/{repository_name} ### Description Retrieves information about a specific repository using its team name and repository name. ### Method GET ### Endpoint /api/v2.0/repositories/{team_name}/{repository_name} ### Parameters #### Path Parameters - **team_name** (string) - Required - The name of the team that owns the repository. - **repository_name** (string) - Required - The name of the repository. ### Request Example ```bash curl https://api.bitbucket.org/2.0/repositories/1team/moxie ``` ### Response #### Success Response (200) - **created_on** (string) - The creation date of the repository. - **description** (string) - The description of the repository. - **fork_policy** (string) - The fork policy of the repository. - **full_name** (string) - The full name of the repository (team_name/repository_name). - **has_issues** (boolean) - Indicates if the repository has issue tracking enabled. - **has_wiki** (boolean) - Indicates if the repository has wiki enabled. - **is_private** (boolean) - Indicates if the repository is private. - **language** (string) - The primary programming language of the repository. - **links** (object) - Links to related resources. - **name** (string) - The name of the repository. - **owner** (object) - Information about the repository owner. - **project** (object) - Information about the project the repository belongs to. - **scm** (string) - The source control management system used (e.g., git). - **size** (integer) - The size of the repository in bytes. - **type** (string) - The type of the object (repository). - **updated_on** (string) - The last updated date of the repository. - **uuid** (string) - The unique identifier (UUID) of the repository. - **website** (string) - The URL of the repository's website. #### Response Example ```json { "created_on": "2013-11-08T01:11:03.222520+00:00", "description": "", "fork_policy": "allow_forks", "full_name": "1team/moxie", "has_issues": false, "has_wiki": false, "is_private": false, "language": "", "links": { "avatar": { "href": "https://bitbucket.org/1team/moxie/avatar/32/" }, "branches": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/refs/branches" }, "clone": [ { "href": "https://bitbucket.org/1team/moxie.git", "name": "https" }, { "href": "ssh://git@bitbucket.org/1team/moxie.git", "name": "ssh" } ], "commits": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/commits" }, "downloads": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/downloads" }, "forks": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/forks" }, "hooks": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/hooks" }, "html": { "href": "https://bitbucket.org/1team/moxie" }, "pullrequests": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/pullrequests" }, "self": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie" }, "tags": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/refs/tags" }, "watchers": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/watchers" } }, "name": "moxie", "owner": { "display_name": "the team", "links": { "avatar": { "href": "https://bitbucket.org/account/1team/avatar/32/" }, "html": { "href": "https://bitbucket.org/1team/" }, "self": { "href": "https://api.bitbucket.org/2.0/teams/1team" } }, "type": "team", "username": "1team", "uuid": "{aa559944-83c9-4963-a9a8-69ac8d9cf5d2}" }, "project": { "key": "PROJ", "links": { "avatar": { "href": "https://bitbucket.org/account/user/1team/projects/PROJ/avatar/32" }, "html": { "href": "https://bitbucket.org/account/user/1team/projects/PROJ" } }, "name": "Untitled project", "type": "project", "uuid": "{ab52aaeb-16ad-4fb0-bb1d-47e4f00367ff}" }, "scm": "git", "size": 33348, "type": "repository", "updated_on": "2013-11-08T01:11:03.263237+00:00", "uuid": "{21fa9bf8-b5b2-4891-97ed-d590bad0f871}", "website": "" } ``` ``` -------------------------------- ### Get User by UUID Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Retrieve a user's profile information by specifying their UUID in the API call. The response is identical to calling with a username. ```APIDOC ## GET /2.0/users/{uuid} ### Description Retrieves the profile information for a specific user identified by their UUID. The response structure is the same as when using a username. ### Method GET ### Endpoint /2.0/users/{uuid} ### Parameters #### Path Parameters - **uuid** (string) - Required - The UUID of the user to retrieve. This should be URL-encoded if it contains special characters. ### Request Example ```bash curl https://api.bitbucket.org/2.0/users/%7Bc788b2da-b7a2-404c-9e26-d3f077557007%7D ``` ### Response #### Success Response (200) - **username** (string) - The user's username. - **nickname** (string) - The user's nickname. - **account_status** (string) - The current status of the user's account. - **website** (string) - The user's website URL. - **display_name** (string) - The user's display name. - **uuid** (string) - The user's unique identifier. - **links** (object) - Links to related resources. - **created_on** (string) - The date and time the user account was created. - **location** (string) - The user's location. - **type** (string) - The type of object, typically 'user'. #### Response Example ```json { "username": "tutorials", "nickname": "tutorials", "account_status": "active", "website": "https://tutorials.bitbucket.org/", "display_name": "tutorials account", "uuid": "{c788b2da-b7a2-404c-9e26-d3f077557007}", "links": { "self": { "href": "https://api.bitbucket.org/2.0/users/tutorials" }, "repositories": { "href": "https://api.bitbucket.org/2.0/repositories/tutorials" }, "html": { "href": "https://bitbucket.org/tutorials" }, "followers": { "href": "https://api.bitbucket.org/2.0/users/tutorials/followers" }, "avatar": { "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Nov/25/tutorials-avatar-1563784409-6_avatar.png" }, "following": { "href": "https://api.bitbucket.org/2.0/users/tutorials/following" } }, "created_on": "2011-12-20T16:34:07.132459+00:00", "location": "Santa Monica, CA", "type": "user" } ``` ``` -------------------------------- ### Add Content-Length Header for PUT Request Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro When encountering a '411 Length Required' response, add the 'Content-Length' header to your PUT request. This example demonstrates setting it to 0. ```bash curl -r PUT --header "Content-Length: 0" -u user:app_password https://api.bitbucket.org/1.0/emails/rap@atlassian.com ``` -------------------------------- ### Get Repository by UUID and Team Name Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro This endpoint retrieves repository information using the repository's UUID and the team name. This method is useful when you know both the team and the repository's unique identifier. ```APIDOC ## GET /api/v2.0/repositories/{team_name}/{repository_uuid} ### Description Retrieves repository information using the team name and the repository's UUID. This method is useful when you know both the team and the repository's unique identifier. ### Method GET ### Endpoint /api/v2.0/repositories/{team_name}/{repository_uuid} ### Parameters #### Path Parameters - **team_name** (string) - Required - The name of the team that owns the repository. - **repository_uuid** (string) - Required - The unique identifier (UUID) of the repository. ### Request Example ```bash curl https://api.bitbucket.org/2.0/repositories/1team/%7B21fa9bf8-b5b2-4891-97ed-d590bad0f871%7D ``` ### Response #### Success Response (200) - **created_on** (string) - The creation date of the repository. - **description** (string) - The description of the repository. - **fork_policy** (string) - The fork policy of the repository. - **full_name** (string) - The full name of the repository (team_name/repository_name). - **has_issues** (boolean) - Indicates if the repository has issue tracking enabled. - **has_wiki** (boolean) - Indicates if the repository has wiki enabled. - **is_private** (boolean) - Indicates if the repository is private. - **language** (string) - The primary programming language of the repository. - **links** (object) - Links to related resources. - **name** (string) - The name of the repository. - **owner** (object) - Information about the repository owner. - **project** (object) - Information about the project the repository belongs to. - **scm** (string) - The source control management system used (e.g., git). - **size** (integer) - The size of the repository in bytes. - **type** (string) - The type of the object (repository). - **updated_on** (string) - The last updated date of the repository. - **uuid** (string) - The unique identifier (UUID) of the repository. - **website** (string) - The URL of the repository's website. #### Response Example ```json { "created_on": "2013-11-08T01:11:03.222520+00:00", "description": "", "fork_policy": "allow_forks", "full_name": "1team/moxie", "has_issues": false, "has_wiki": false, "is_private": false, "language": "", "links": { "avatar": { "href": "https://bitbucket.org/1team/moxie/avatar/32/" }, "branches": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/refs/branches" }, "clone": [ { "href": "https://bitbucket.org/1team/moxie.git", "name": "https" }, { "href": "ssh://git@bitbucket.org/1team/moxie.git", "name": "ssh" } ], "commits": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/commits" }, "downloads": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/downloads" }, "forks": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/forks" }, "hooks": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/hooks" }, "html": { "href": "https://bitbucket.org/1team/moxie" }, "pullrequests": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/pullrequests" }, "self": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie" }, "tags": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/refs/tags" }, "watchers": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/watchers" } }, "name": "moxie", "owner": { "display_name": "the team", "links": { "avatar": { "href": "https://bitbucket.org/account/1team/avatar/32/" }, "html": { "href": "https://bitbucket.org/1team/" }, "self": { "href": "https://api.bitbucket.org/2.0/teams/1team" } }, "type": "team", "username": "1team", "uuid": "{aa559944-83c9-4963-a9a8-69ac8d9cf5d2}" }, "project": { "key": "PROJ", "links": { "avatar": { "href": "https://bitbucket.org/account/user/1team/projects/PROJ/avatar/32" }, "html": { "href": "https://bitbucket.org/account/user/1team/projects/PROJ" } }, "name": "Untitled project", "type": "project", "uuid": "{ab52aaeb-16ad-4fb0-bb1d-47e4f00367ff}" }, "scm": "git", "size": 33348, "type": "repository", "updated_on": "2013-11-08T01:11:03.263237+00:00", "uuid": "{21fa9bf8-b5b2-4891-97ed-d590bad0f871}", "website": "" } ``` ``` -------------------------------- ### Get Repository by UUID and Empty Field Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro This endpoint retrieves repository information using the repository's UUID and an empty field for the team name. This is useful when the team name might change. ```APIDOC ## GET /api/v2.0/repositories/%7B%7D/{repository_uuid} ### Description Retrieves repository information using its UUID, with an empty string for the team name. This method is useful for resolving repositories even if the team name changes. ### Method GET ### Endpoint /api/v2.0/repositories/%7B%7D/{repository_uuid} ### Parameters #### Path Parameters - **%7B%7D** (string) - Required - An empty string, representing the absence of a team name. - **repository_uuid** (string) - Required - The unique identifier (UUID) of the repository. ### Request Example ```bash curl https://api.bitbucket.org/2.0/repositories/%7B%7D/%7B21fa9bf8-b5b2-4891-97ed-d590bad0f871%7D ``` ### Response #### Success Response (200) - **created_on** (string) - The creation date of the repository. - **description** (string) - The description of the repository. - **fork_policy** (string) - The fork policy of the repository. - **full_name** (string) - The full name of the repository (team_name/repository_name). - **has_issues** (boolean) - Indicates if the repository has issue tracking enabled. - **has_wiki** (boolean) - Indicates if the repository has wiki enabled. - **is_private** (boolean) - Indicates if the repository is private. - **language** (string) - The primary programming language of the repository. - **links** (object) - Links to related resources. - **name** (string) - The name of the repository. - **owner** (object) - Information about the repository owner. - **project** (object) - Information about the project the repository belongs to. - **scm** (string) - The source control management system used (e.g., git). - **size** (integer) - The size of the repository in bytes. - **type** (string) - The type of the object (repository). - **updated_on** (string) - The last updated date of the repository. - **uuid** (string) - The unique identifier (UUID) of the repository. - **website** (string) - The URL of the repository's website. #### Response Example ```json { "created_on": "2013-11-08T01:11:03.222520+00:00", "description": "", "fork_policy": "allow_forks", "full_name": "1team/moxie", "has_issues": false, "has_wiki": false, "is_private": false, "language": "", "links": { "avatar": { "href": "https://bitbucket.org/1team/moxie/avatar/32/" }, "branches": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/refs/branches" }, "clone": [ { "href": "https://bitbucket.org/1team/moxie.git", "name": "https" }, { "href": "ssh://git@bitbucket.org/1team/moxie.git", "name": "ssh" } ], "commits": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/commits" }, "downloads": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/downloads" }, "forks": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/forks" }, "hooks": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/hooks" }, "html": { "href": "https://bitbucket.org/1team/moxie" }, "pullrequests": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/pullrequests" }, "self": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie" }, "tags": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/refs/tags" }, "watchers": { "href": "https://api.bitbucket.org/2.0/repositories/1team/moxie/watchers" } }, "name": "moxie", "owner": { "display_name": "the team", "links": { "avatar": { "href": "https://bitbucket.org/account/1team/avatar/32/" }, "html": { "href": "https://bitbucket.org/1team/" }, "self": { "href": "https://api.bitbucket.org/2.0/teams/1team" } }, "type": "team", "username": "1team", "uuid": "{aa559944-83c9-4963-a9a8-69ac8d9cf5d2}" }, "project": { "key": "PROJ", "links": { "avatar": { "href": "https://bitbucket.org/account/user/1team/projects/PROJ/avatar/32" }, "html": { "href": "https://bitbucket.org/account/user/1team/projects/PROJ" } }, "name": "Untitled project", "type": "project", "uuid": "{ab52aaeb-16ad-4fb0-bb1d-47e4f00367ff}" }, "scm": "git", "size": 33348, "type": "repository", "updated_on": "2013-11-08T01:11:03.263237+00:00", "uuid": "{21fa9bf8-b5b2-4891-97ed-d590bad0f871}", "website": "" } ``` ``` -------------------------------- ### Retrieve Specific Pull Request Data Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Combine filters with partial responses using `?fields=values.id,values.reviewers.nickname,values.state&q=author.uuid%3D%22%7Bd301aafa-d676-4ee0-88be-962be7417567%7D%22` to get a list of pull request IDs, reviewer nicknames, and states for a specific author. This omits all other data. ```bash /2.0/repositories/bitbucket/bitbucket/pullrequests?fields=values.id,values.reviewers.nickname,values.state&q=author.uuid%3D%22%7Bd301aafa-d676-4ee0-88be-962be7417567%7D%22 { "values": [ { "reviewers": [ { "nickname": "abhin" }, { "nickname": "dtao" }, { "nickname": "csomme" } ], "state": "OPEN", "id": 11355 }, { "reviewers": [ { "nickname": "csomme" }, { "nickname": "abhin" }, { "nickname": "dstevens" } ], "state": "MERGED", "id": 11347 }, { "reviewers": [ { "nickname": "csomme" }, { "nickname": "jmooring" }, { "nickname": "zdavis" }, { "nickname": "flexbox" } ], "state": "OPEN", "id": 11344 } ] } ``` -------------------------------- ### Repository links with multiple clone options Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Demonstrates how a single rel key can contain an array of objects, using the name element to distinguish between different clone protocols. ```json "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/evzijst/bitbucket" }, "clone": [ { "href": "https://api.bitbucket.org/evzijst/bitbucket.git", "name": "https" }, { "href": "ssh://git@bitbucket.org/erik/bitbucket.git", "name": "ssh" } ], ... } ``` -------------------------------- ### Clone Repository with Access Token Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Use an access token as Basic HTTP Auth credentials to clone a repository securely over HTTPS. The literal string 'x-token-auth' is required as a username. ```bash git clone https://x-token-auth:{access_token}@bitbucket.org/user/repo.git ``` -------------------------------- ### List Issues using curl (1.0 API) Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Use this command to list all issues on a specific Bitbucket repository using the 1.0 API. ```bash curl https://api.bitbucket.org/1.0/repositories/tutorials/tutorials.bitbucket.org/issues ``` -------------------------------- ### List Issues using curl (2.0 API) Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Use this command to list all issues on a specific Bitbucket repository using the 2.0 API. ```bash curl https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org ``` -------------------------------- ### Call Repository API with Team and Repository Name Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro Use this method to call the repository API when you know the team name and repository name. ```bash curl https://api.bitbucket.org/2.0/repositories/1team/moxie ``` -------------------------------- ### Call Repository API with UUID and Team Name Source: https://developer.atlassian.com/cloud/bitbucket/rest/intro This method demonstrates calling the repository API using both the team name and the repository's UUID. This provides a way to reference a repository even if its name changes, as long as the team name remains the same. ```bash curl https://api.bitbucket.org/2.0/repositories/1team/%7B21fa9bf8-b5b2-4891-97ed-d590bad0f871%7D ```