BMO/REST: Difference between revisions

From MozillaWiki
< BMO
Jump to navigation Jump to search
(Making the native rest api docs the default)
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
= Bugzilla's REST API =
#REDIRECT [[Bugzilla: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 BzAPI proxy.
 
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 data for a single bug
: https://bugzilla.mozilla.org/rest/bug/35
 
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 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
# 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 the token to get authenticated searches
# e.g. to pull all the tracked bugs for FF31
>>> url = 'https://bugzilla.mozilla.org/rest/bug'
>>> u = url + "?token=272345-L1KydUNCwq&f1=cf_tracking_firefox31&o1=equals&v1=%2B&include_fields=assigned_to, id"
>>> search_results = requests.get(u)
>>> search_results.text
u'{"bugs":[{"assigned_to":"dtownsend+bugmail@oxymoronical.com","id":639524},{"assigned_to":"ehsan@mozilla.com","id":798158},{"assigned_to":"gkrizsanits@mozilla.com","id":821809}]}'

Latest revision as of 17:09, 7 July 2014

Redirect to: