You can use the bitbucket 'src' REST resource to browse directories and view files.
Overview
This is a read-only resource.
Example of browsing a directory:
$ curl https://api.bitbucket.org/1.0/repositories/jespern/django-piston/src/tip/piston/
{
"diretories": [
"fixtures",
"templates"
],
"files": [
{
"path": "resource.py",
"revision": "5c2a4cd036ec",
"size": 8797,
"timestamp": "2009-09-10 10:28:58"
},
{
"path": "doc.py",
"revision": "80086e0a8022",
"size": 5738,
"timestamp": "2009-09-02 11:23:37"
},
# more ...
]
}
Example of viewing a file:
$ curl https://api.bitbucket.org/1.0/repositories/jespern/django-piston/src/tip/piston/utils.py
{
"data": "import time\nfrom django.http import HttpResponseNotAllowed, ...",
"node": "7970b070f884",
"path": "piston/utils.py"
}
Instead of getting the file formatted as JSON, you can get the raw file:
$ curl https://api.bitbucket.org/1.0/repositories/jespern/django-piston/raw/tip/piston/utils.py import time from django.http import HttpResponseNotAllowed, HttpResponseForbidden, HttpResponse, HttpResponseBadRequest from django.core....
Viewing Directories and Files
GET /repositories/USERNAME/REPO_SLUG/REVISION/PATH/
Reads either directories or files.
Parameters:
USERNAME: The owner username.REPO_SLUG: The slug of the repository.REVISION: The revision number.PATH: If path ends with/it will be interpreted as a directory and will return a list.
RELATED TOPICS
Labels






2 Comments
Hide/Show CommentsDec 27, 2011
Anonymous
the latest revision in this api can be fetched with the tip keyword which is a mercurial name, what about git ?
thanks
Jan 24, 2012
Anonymous
master
Add Comment