Changes

Jump to: navigation, search

Bugzilla:REST API

4,655 bytes added, 17:02, 7 July 2014
The old bzapi proxy page has moved (see https://wiki.mozilla.org/Bugzilla:BzAPI). This is the native REST API content from https://wiki.mozilla.org/index.php?title=BMO/REST&action=history
#REDIRECT = Bugzilla's REST API = == Summary == Bugzilla has a native REST API, an HTTP version of its XMLRPC and JSONRPC APIs. It is [http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Server/REST.html documented] along with the other WebServices and Bugzilla's internal interfaces. '''This is the preferred way to interface with Bugzilla from external apps''', web or otherwise. The previous REST API, [[Bugzilla:REST_API|BzAPI]], is considered '''DEPRECATED'''. There is a compatibility layer being created to help transition away from the BzAPI server; see the BzAPI wiki page for more. == Background == Until recently, Bugzilla supported only older technologies, namely XMLRPC and JSONRPC. The BMO team created a new REST API in the summer of 2013 to provide a modern Web interface to Bugzilla. Prior to the native REST API, a separate proxy service called [[Bugzilla:REST_API|BzAPI]] was created that provided a REST API using data obtained through the older RPC interfaces as well as various other Bugzilla data sources, including CSV representations. This was a great interim solution, but now that we have a native API, and since the system hosting the proxy is not maintained by Mozilla IT, the bzAPI service will be decommissioned at some point. See [[Bugzilla:API_Comparison]] for the differences and between bzAPI and the native API. To ease the transition, we are creating a native bzAPI compatibility layer ({{bug|880669}}) that will act exactly the same as bzAPI but will translate the queries to the native API layer. Thus clients who currently accesses BMO data via the proxy will just need to change the REST url to move to the built-in API. The path will be slightly different depending on which API you want to use: the native one, or the one compatible with the BzAPIproxy. There is discussion in {{bug|866927}} about making small changes to the current upstream API that bring it closer to the format used by the BzAPI proxy. We will create individual bugs as needed for any changes that are to be made. We also plan on versioning the different API changes so that users can still continue to use an older format rather than breaking their client code. == Documentation == The REST API is [http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Server/REST.html documented]along with the other WebServices and Bugzilla's internal interfaces. === Examples of native REST API use =======public data====Here are few examples of using the API (without logging in, so with public data) Get all data for a single bug: https://bugzilla.mozilla.org/rest/bug/35 However you almost always never need all data. Use "include_fields" to request just the data you need. Most of the calls to Bugzilla support "include_fields".: https://bugzilla.mozilla.org/rest/bug/35?include_fields=summary,status,resolution Get all comments for a single bug: https://bugzilla.mozilla.org/rest/bug/707428/comment Get history of all metadata changes for a single bug: https://bugzilla.mozilla.org/rest/bug/707428/history Get data for all the bugs in the 29 Branch: https://bugzilla.mozilla.org/rest/bug?version=29%20Branch Get data for all the bugs assigned to a particular user: https://bugzilla.mozilla.org/rest/bug?assigned_to=lhenry@mozilla.com Get data for all the bugs with the keyword "topcrash": https://bugzilla.mozilla.org/rest/bug?keywords=topcrash Get all the bugs that are mentored: https://bugzilla.mozilla.org/rest/bug?product=Input&f1=bug_mentor&o1=isnotempty  Get data about a particular product: https://bugzilla.mozilla.org/rest/product/firefox Get data about products and components: https://bugzilla.mozilla.org/rest/product/core?component=DOM Get data for a user: https://bugzilla.mozilla.org/rest/user?names=lhenry@mozilla.com ====with authentication==== First you need to call a /login with login=username&password=password ([http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Server/REST.html#AUTHENTICATION Docs]) # Python example, you get a token back that you can use for future calls >>> r = requests.get('https://bugzilla.mozilla.org/rest/login?login=username&password=password') >>> r <Response [200]> >>> r.text u'{"id":272475,"token":"272345-L1KydUNCwq"}'  # Use this token to get authenticated search results # e.g. to pull all the tracked bugs for FF31 >>> url = 'https://bugzilla.mozilla.org/rest/bug' # specify which fields you want so it's faster >>> u = url + "?token=272345-L1KydUNCwq&f1=cf_tracking_firefox31&o1=equals&v1=%2B&include_fields=id" >>> search_results = requests.get(u) >>> search_results.text u'{"bugs":[{"id":639524},{"id":798158},{"id":821809}]}'
Canmove, confirm
1,126
edits

Navigation menu