Skip to end of metadata
Go to start of metadata

Overview

The /users endpoint gets a user account's profile information. Individual accounts have the following fields:

FieldDescription
usernameThe name associated with the account.
kindThe string "user".
websiteThe first name associated with account.
display_nameThe name displayed on the UI.
linksResources associated with the account.
created_onThe account resource identifier.
location
Where the user is located.

GET the user profile

Gets the public information associated with a user. If the user's profile is private, the caller must be authenticated as the account holder to view this information.  This call takes the following parameter:

ParameterRequiredDescription
username
YesThe user's name.
GET https://bitbucket.org/api/2.0/users/{username}
 Click to expand and view a response...
{
  "username": "tutorials",
  "kind": "user",
  "website": "https://tutorials.bitbucket.org/",
  "display_name": "first name last",
  "links":  {
    "self":  {
      "href": "https://api.bitbucket.org/2.0/users/tutorials"
    },
    "repositories":  {
      "href": "https://api.bitbucket.org/2.0/users/tutorials/repositories"
    },
    "html":  {
      "href": "https://api.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/Jul/17/tutorials-avatar-1826704565-4_avatar.png"
    },
    "following":  {
      "href": "https://api.bitbucket.org/2.0/users/tutorials/following"
    }
  },
  "created_on": "2011-12-20T16:34:07.132459+00:00",
  "location": "San Francisco, CA"
}

GET the list of followers

Gets the list of accounts following the user.  This call takes the following parameters:

ParameterRequiredDescription
username
YesThe user's name.
GET https://bitbucket.org/api/2.0/users/{username}/followers
 Click to expand and view a response...
{
  "pagelen": 10,
  "values": [
    {
      "username": "RagnarArdal",
      "kind": "user",
      "website": null,
      "display_name": "Ragnar Árdal",
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/users/RagnarArdal"
        },
        "repositories": {
          "href": "https://api.bitbucket.org/2.0/users/RagnarArdal/repositories"
        },
        "html": {
          "href": "https://api.bitbucket.org/RagnarArdal"
        },
        "followers": {
          "href": "https://api.bitbucket.org/2.0/users/RagnarArdal/followers"
        },
        "avatar": {
          "href": "https://secure.gravatar.com/avatar/27ca0dc0bb96722af4f0222f6260fbb5?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2Fb376619db485%2Fimg%2Fdefault_avatar%2F32%2Fuser_blue.png&s=32"
        },
        "following": {
          "href": "https://api.bitbucket.org/2.0/users/RagnarArdal/following"
        }
      },
      "created_on": "2013-04-19T19:10:54.044200+00:00",
      "location": null
    },
    {
      "username": "ericko",
      "kind": "user",
      "website": "",
      "display_name": "ericko",
      "links": {
        "self": {
          "href": "https://api.bitbucket.org/2.0/users/ericko"
        },
        "repositories": {
          "href": "https://api.bitbucket.org/2.0/users/ericko/repositories"
        },
        "html": {
          "href": "https://api.bitbucket.org/ericko"
        },
        "followers": {
          "href": "https://api.bitbucket.org/2.0/users/ericko/followers"
        },
        "avatar": {
          "href": "https://secure.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2Fb376619db485%2Fimg%2Fdefault_avatar%2F32%2Fuser_blue.png&s=32"
        },
        "following": {
          "href": "https://api.bitbucket.org/2.0/users/ericko/following"
        }
      },
      "created_on": "2013-10-20T16:29:04.388755+00:00",
      "location": ""
    }
  ],
  "page": 1,
  "size": 2
}

GET a list of accounts the user is following

Gets a list of accounts the user is following. This call takes the following parameters:

ParameterRequiredDescription
username
YesThe user's name.
GET https://bitbucket.org/api/2.0/users/{username}/following
 Click to expand and view a response...
{
  "pagelen": 10,
  "values":  [
     {
      "username": "jdoklovic",
      "kind": "user",
      "website": "http://www.sysbliss.com/",
      "display_name": "Jonathan Doklovic",
      "links":  {
        "self":  {
          "href": "https://api.bitbucket.org/2.0/users/jdoklovic"
        },
        "repositories":  {
          "href": "https://api.bitbucket.org/2.0/users/jdoklovic/repositories"
        },
        "html":  {
          "href": "https://api.bitbucket.org/jdoklovic"
        },
        "followers":  {
          "href": "https://api.bitbucket.org/2.0/users/jdoklovic/followers"
        },
        "avatar":  {
          "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2010/Sep/30/jd_profile_avatar.jpg"
        },
        "following":  {
          "href": "https://api.bitbucket.org/2.0/users/jdoklovic/following"
        }
      },
      "created_on": "2010-09-30T13:44:45.049874+00:00",
      "location": "Minneapolis, MN"
    },
     {
      "username": "atlassian_tutorial",
      "kind": "team",
      "website": "",
      "display_name": "Atlassian Tutorials",
      "links":  {
        "self":  {
          "href": "https://api.bitbucket.org/2.0/teams/atlassian_tutorial"
        },
        "repositories":  {
          "href": "https://api.bitbucket.org/2.0/teams/atlassian_tutorial/repositories"
        },
        "html":  {
          "href": "https://api.bitbucket.org/atlassian_tutorial"
        },
        "followers":  {
          "href": "https://api.bitbucket.org/2.0/teams/atlassian_tutorial/followers"
        },
        "avatar":  {
          "href": "https://secure.gravatar.com/avatar/eb4e0ad6934518b3e335345a4ceeef21?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2Fbc85d1577e04%2Fimg%2Fdefault_team_avatar%2F32%2Fteam_blue.png&s=32"
        },
        "members":  {
          "href": "https://api.bitbucket.org/2.0/teams/atlassian_tutorial/members"
        },
        "following":  {
          "href": "https://api.bitbucket.org/2.0/teams/atlassian_tutorial/following"
        }
      },
      "created_on": "2011-11-29T05:38:01.075233+00:00",
      "location": ""
    },
     {
      "username": "cat_vasja",
      "kind": "team",
      "website": "",
      "display_name": "cat_vasja",
      "links":  {
        "self":  {
          "href": "https://api.bitbucket.org/2.0/teams/cat_vasja"
        },
        "repositories":  {
          "href": "https://api.bitbucket.org/2.0/teams/cat_vasja/repositories"
        },
        "html":  {
          "href": "https://api.bitbucket.org/cat_vasja"
        },
        "followers":  {
          "href": "https://api.bitbucket.org/2.0/teams/cat_vasja/followers"
        },
        "avatar":  {
          "href": "https://secure.gravatar.com/avatar/e16be80e861baccc5ed4691737faeb05?d=https%3A%2F%2Fd3oaxc4q5k2d6q.cloudfront.net%2Fm%2Fbc85d1577e04%2Fimg%2Fdefault_team_avatar%2F32%2Fteam_blue.png&s=32"
        },
        "members":  {
          "href": "https://api.bitbucket.org/2.0/teams/cat_vasja/members"
        },
        "following":  {
          "href": "https://api.bitbucket.org/2.0/teams/cat_vasja/following"
        }
      },
      "created_on": "2012-10-09T19:45:37.292078+00:00",
      "location": "Deutschland"
    }
  ],
  "page": 1,
  "size": 3
}

GET the user's repositories

Gets the list of the user's repositories. Private repositories only appear on this list if the caller is authenticated and is authorized to view the repository. This call takes the following parameters:

ParameterRequiredDescription
username
YesThe user's name.
GET https://bitbucket.org/api/2.0/repositories/{username}
 Click to expand and view a response...
,
     {
      "scm": "hg",
      "has_wiki": true,
      "description": "This repository is used by the Bitbucket tutorial documentation.  It is referenced from this page:\r\n\r\nhttps://confluence.atlassian.com/display/BITBUCKET/Split+a+Repository+in+Two ",
      "links":  {
        "watchers":  {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/hgsplitpractice/watchers"
        },
        "commits":  {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/hgsplitpractice/commits"
        },
        "self":  {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/hgsplitpractice"
        },
        "html":  {
          "href": "https://api.bitbucket.org/tutorials/hgsplitpractice"
        },
        "avatar":  {
          "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2012/Nov/28/hgsplitpractice-logo-129947197-5_avatar.png"
        },
        "forks":  {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/hgsplitpractice/forks"
        },
        "clone":  [
           {
            "href": "https://tutorials@bitbucket.org/tutorials/hgsplitpractice",
            "name": "https"
          },
           {
            "href": "ssh://hg@bitbucket.org/tutorials/hgsplitpractice",
            "name": "ssh"
          }
        ],
        "pullrequests":  {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/hgsplitpractice/pullrequests"
        }
      },
      "fork_policy": "allow_forks",
      "language": "",
      "created_on": "2012-11-27T19:19:33.315067+00:00",
      "full_name": "tutorials/hgsplitpractice",
      "has_issues": false,
      "owner":  {
        "username": "tutorials",
        "display_name": "first name last",
        "links":  {
          "self":  {
            "href": "https://api.bitbucket.org/2.0/users/tutorials"
          },
          "avatar":  {
            "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Jul/17/tutorials-avatar-1826704565-4_avatar.png"
          }
        }
      },
      "updated_on": "2013-02-04T17:04:13.612906+00:00",
      "size": 19065,
      "is_private": false,
      "name": "hgsplitpractice"
    },
     {
      "scm": "git",
      "has_wiki": false,
      "description": "Example scripts using OAuth to connect to Bitbucket. Please contribute more by issuing a Pull Request here!",
      "links":  {
        "watchers":  {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/oauth-examples/watchers"
        },
        "commits":  {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/oauth-examples/commits"
        },
        "self":  {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/oauth-examples"
        },
        "html":  {
          "href": "https://api.bitbucket.org/tutorials/oauth-examples"
        },
        "avatar":  {
          "href": "https://d3oaxc4q5k2d6q.cloudfront.net/m/bc85d1577e04/img/language-avatars/default_16.png"
        },
        "forks":  {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/oauth-examples/forks"
        },
        "clone":  [
           {
            "href": "https://tutorials@bitbucket.org/tutorials/oauth-examples.git",
            "name": "https"
          },
           {
            "href": "ssh://git@bitbucket.org/tutorials/oauth-examples.git",
            "name": "ssh"
          }
        ],
        "pullrequests":  {
          "href": "https://api.bitbucket.org/2.0/repositories/tutorials/oauth-examples/pullrequests"
        }
      },
      "fork_policy": "allow_forks",
      "language": "",
      "created_on": "2013-04-01T21:19:07.973032+00:00",
      "full_name": "tutorials/oauth-examples",
      "has_issues": false,
      "owner":  {
        "username": "tutorials",
        "display_name": "first name last",
        "links":  {
          "self":  {
            "href": "https://api.bitbucket.org/2.0/users/tutorials"
          },
          "avatar":  {
            "href": "https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2013/Jul/17/tutorials-avatar-1826704565-4_avatar.png"
          }
        }
      },
      "updated_on": "2013-04-01T21:20:22.492622+00:00",
      "size": 1794,
      "is_private": false,
      "name": "OAuth Examples"
    },
  ],
  "page": 1,
  "size": 2
}
  • No labels

19 Comments

  1. The user's repositories return error 301.

    Request:

    GET /api/2.0/users/username/repositories



    Response:

    HTTP/1.1 301 MOVED PERMANENTLY

    Content-Language: en
    ETag:"d41d8cd98f00b204e9800998ecf8427e"
    X-Render-Time: 0.0239839553833
    Content-Length:0
    X-Served-By: app13
    Location: https://bitbucket.org/api/2.0/repositories/username
    X-Version: 6e1c93036913
    X-Request-Count:268
    Server:nginx/1.5.3
    X-Content-Type-Options:  nosniff
    X-Frame-Options: SAMEORIGIN
    Strict-Transport-Security:  max-age=2592000
    Date:  Sat, 16 Nov 2013 13:24:18 GMT
    Vary:  Authorization, Accept-Language, Cookie
    X-Static-Version:  f5a36db3429b
    Content-Type: text/html; charset=utf-8


    but this request work.

    GET /api/2.0/repositories/username


     

    1. A 301 is not an error. It merely redirects the client to a different URL. What HTTP client are you using? It should follow 301/302 redirects as per the HTTP spec.

  2. I use OAuth PHP Client and RestBrowser for my tests.

    Also i have Another Problem for access to public / private repositories of Authenticated Users.

    1. To OAuth PHP Class it return empty values.

      Request: GET /api/2.0/users/ [owner-username | authenticated-username ] /repositories

      Response:

       {"pagelen": 10, "values": [], "page": 1}

       

      but to restbrowser it return http status code 301.

       

       

       

      1. I'm unable reproduce this (does the user in your URL have any repos at all?).

        Can you raise a support issue by emailing (support@bitbucket.org) details about the actual URL, the user you are authenticating as and if possible a full dump of the wire-level request and response (which includes all the HTTP headers)?

      2. but to restbrowser it return http status code 301.

        301 means a redirect. You should follow the URL in the Location header. Have you tried that? If so, does that return the same 200 status code with empty values list? If so, can you provide a full wire-level capture of the request?

        The wire-level request can be see in the left pane of the restbrowser. Can you provide all headers please?

        1. 301 means a redirect. You should follow the URL in the Location header. Have you tried that?

          Yes, but i think "api/2.0/users/{username}/repositories" is more friendly.(smile)

  3. I have 2 users:

    Owner : The user which create own application and authenticating by consumer key & consumer secret .

    OAuth_User: The user which authenticating by Owner application .

     

    First Test ( get user repositories ):

    API Version: 2.0

    API URL : https://bitbucket.org/api/2.0/


    Owner

    TesterMethodRequestResponse
    RestbrowserGET/users/owner/repositories
    HTTP/1.1 301 MOVED PERMANENTLY
    PHP OAuth ClassGET/users/owner/repositories
    HTTP/1.1 200 OK
    {"pagelen": 10,"values": [],
    "page": 1
    }

     

    OAuth_User:

    TesterMethodRequestResponse
    RestbrowserGET/api/2.0/users/oauth_user/repositories
    HTTP/1.1 301 MOVED PERMANENTLY
    PHP OAuth ClassGET/api/2.0/users/oauth_user/repositories
    HTTP/1.1 200 OK
    {"pagelen": 10,"values": [],
    "page": 1
    }

    Second Test ( get access to public / private repository ):

    API Version: 2.0

    API URL : https://bitbucket.org/api/2.0/


    Owner:

    TesterMethodRequestResponse
    RestbrowserGET/repositories/owner/private_repo
    HTTP/1.1 200 OK
    {"scm": "git",
    "has_wiki": false,
     ...
    }

    Restbrowser

     

    GET/repositories/owner/public_repo
    HTTP/1.1 200 OK
    {"scm": "git",
    "has_wiki": false,
     ...
    }
    PHP OAuth Class GET /repositories/owner/private_repo
    HTTP/1.1 200 OK
    {"scm": "git",
    "has_wiki": false,
     ...
    }
    PHP OAuth Class GET /repositories/owner/public_repo
    HTTP/1.1 200 OK
    {"scm": "git",
    "has_wiki": false,
     ...
    }


    OAuth_User:

    TesterMethodRequestResponse
    RestbrowserGET/repositories/oauth_user/private_repo
    HTTP/1.1 403 FORBIDDEN

    Restbrowser

    GET/repositories/oauth_user/public_repo
    HTTP/1.1 403 FORBIDDEN

    PHP OAuth Class

    GET/repositories/oauth_user/private_repo
    HTTP/1.1 403 FORBIDDEN

    PHP OAuth Class

    GET/repositories/oauth_user/public_repo
    HTTP/1.1 403 FORBIDDEN




     

     

     

    1. Again, which users are involved? Can you give me the real URLs so I can reproduce the problem?

      Also, this is more of a support case than a documentation comment. Can we move it to the appropriate channel by emailing all the relevant details to: support@bitbucket.org?

  4. Erik van Zijst [Atlassian] Thanks a lot for helps. (smile)

    Owner = khosroblog

    OAuth_user = rss_samuel

    application-name = khosroblog

    1. rss_samuel is authenticated user from khosroblog application.
    2. khosroblog is authenticated user from khosroblog application.
    3. on the first test both users have problem.( server return empty values ).
    4. on the second test, khosroblog account not access to public / private repository from rss_samuel account.

    I have create a plugin for wordpress and answer to this issue very important for me. also I speak english very hard . (sad)

     

    1. For your php oauth library, can you capture the OAuth authorization header it is sending?

  5. Anonymous

    Hi, 

    how i can acquire user's profile after successful OAUTH process?

    I have only user's token and secret and no username.

    I tried `/api/2.0/users`  without username - it returns 404;  

    is there endpoint `/api/2.0/user` ?

     

    Or how i should solve this? 

  6. Ok, found temporary work-around: `/api/1.0/user`.

    Is there any plan to add similar endpoint for api2.0 - it's quite ugly to have methods that uses endpoints from different versions.

  7. I noticed the data returned for a user in V2 does not contain it's avatar URL unlike V1 where an avatar URL is included. Will the avatar url be added in the future?

    1. Yes, the avatar should be returned (e.g. hit https://api.bitbucket.org/2.0/users/evzijst).

      Or do you mean in other responses where a user shows up as part of a foreign key (e.g. owner in repository)?

      1. Ah, you know what, I see it's in the "links". My mistake, I over looked it.

  8. Anonymous

    How can I determine the username for the user who authenticated?

    1. Anonymous