Bugzilla:REST API: Difference between revisions

no edit summary
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<div style="border: thin dotted #aaa; padding:5px;">
<div style="border: thin dotted #aaa; padding:5px;">
'''This page documents the new native REST API scheduled for release in Bugzilla 5.0 and currently available on [https://bugzilla.mozilla.org/ bugzilla.mozilla.org].'''
'''This page documents the new native REST API available since Bugzilla 5.0 and currently available on [https://bugzilla.mozilla.org/ bugzilla.mozilla.org].''' This is the currently recommended solution for integrating Bugzilla with third-party applications.


'''If you are running your own Bugzilla, version 4.4 (the current stable version) or below, you might be interested in an alternate solution, [[Bugzilla:BzAPI|BzAPI]]. This is separate server software that interfaces with Bugzilla and provides a similar interface to the new native REST API. BzAPI supports Bugzilla versions 3.4 and higher. BzAPI's documentation used to live here but [[Bugzilla:BzAPI|has moved]].'''</div><br>
'''[[Bugzilla:BzAPI|BzAPI]] is an alternate, deprecated REST API that can be used with older Bugzilla installations (although upgrading to the latest Bugzilla version is always recommended). This is separate server software that interfaces with Bugzilla and provides a similar interface to the new native REST API. BzAPI supports Bugzilla versions 3.4 and higher. BzAPI's documentation used to live here but [[Bugzilla:BzAPI|has moved]].'''</div><br>


= Bugzilla's REST API =
= Bugzilla's REST API =
Line 8: Line 8:
== Summary ==
== Summary ==


Bugzilla 5.0+ has a native REST API, an HTTP version of its XMLRPC and JSONRPC APIs. It is [http://bugzilla.readthedocs.org/en/latest/api/index.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.
Bugzilla 5.0 has a native REST API, an HTTP version of its XMLRPC and JSONRPC APIs. It is [http://bmo.readthedocs.org/en/latest/api/index.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.


Although the native REST API is not in any released Bugzilla version yet, it has been backported to [[BMO]] and is available for use there.  On BMO, the previous REST API, [[Bugzilla:BzAPI|BzAPI]], is considered '''DEPRECATED'''. There exists a [[Bugzilla:BzAPI:CompatLayer|compatibility layer]] to help transition away from the BzAPI server.
This native REST API has been backported to [[BMO]] and is available for use there.  On BMO, the previous REST API, [[Bugzilla:BzAPI|BzAPI]], is considered '''DEPRECATED'''. There exists a [[Bugzilla:BzAPI:CompatLayer|compatibility layer]] to help transition away from the BzAPI server.


== Background ==
== Background ==
Line 22: Line 22:
== Documentation ==
== Documentation ==


The REST API is [http://bugzilla.readthedocs.org/en/latest/api/ documented] along with the other WebServices and Bugzilla's internal interfaces. '''[Note that the API documentation was completely rewritten in late 2014 to be much more readable]'''
The REST API is [http://bmo.readthedocs.org/en/latest/api/ documented] along with the other WebServices and Bugzilla's internal interfaces. '''[Note that the API documentation was completely rewritten in late 2014 to be much more readable]'''


=== Examples of native REST API use ===
=== Examples of native REST API use ===
Line 82: Line 82:
====with two factor authentication====
====with two factor authentication====


If you have two factor authentication on your Bugzilla account (which is recommended), then you will not be able to call the login endpoint. Instead [https://bugzilla.mozilla.org/userprefs.cgi?tab=apikey create a new API key]. Then that API key can be passed as a token. For example in Python:
If you have two factor authentication on your Bugzilla account (which is recommended), then you will not be able to call the login endpoint. Instead [https://bugzilla.mozilla.org/userprefs.cgi?tab=apikey create a new API key]. Then that API key can be passed to each request. For example in Python:


  >>> r = requests.get('https://bugzilla.mozilla.org/rest/bug', params={'id': '1214433', 'token': 'the-api-key-from-the-bugzilla-userprefs-page'})
  >>> r = requests.get('https://bugzilla.mozilla.org/rest/bug', params={'id': '1214433', 'api_key': 'the-api-key-from-the-bugzilla-userprefs-page'})
  >>> print res.json()['bugs'][0]['id']
  >>> print res.json()['bugs'][0]['id']
  1214433
  1214433


[[category:Bugzilla]]
[[category:Bugzilla]]
Confirmed users
1,198

edits