Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Client library for interacting with Gerrit's REST API

Project Description

Pygerrit2 provides a simple interface for clients to interact with Gerrit Code Review via the REST API.


Pygerrit2 is compatible with Python 2.6 and Python 2.7. Support for Python 3 is experimental.

Pygerrit2 depends on the requests library.


To install pygerrit2, simply:

$ pip install pygerrit2


This simple example shows how to get the user’s open changes. Authentication to Gerrit is done via HTTP Basic authentication, using an explicitly given username and password:

>>> from requests.auth import HTTPBasicAuth
>>> from import GerritRestAPI
>>> auth = HTTPBasicAuth('username', 'password')
>>> rest = GerritRestAPI(url='', auth=auth)
>>> changes = rest.get("/changes/?q=owner:self%20status:open")

Note that is is not necessary to add the /a/ prefix on the endpoint URLs. This is automatically added when the API is instantiated with an authentication object.

If the user’s HTTP username and password are defined in the .netrc file:

machine login MyUsername password MyPassword

then it is possible to authenticate with those credentials:

>>> from import GerritRestAPI
>>> from import HTTPBasicAuthFromNetrc
>>> url = ''
>>> auth = HTTPBasicAuthFromNetrc(url=url)
>>> rest = GerritRestAPI(url=url, auth=auth)
>>> changes = rest.get("/changes/?q=owner:self%20status:open")

Note that the HTTP password is not the same as the SSH password. For instructions on how to obtain the HTTP password, refer to Gerrit’s HTTP upload settings documentation.

Also note that in Gerrit version 2.14, support for HTTP Digest authentication was removed and only HTTP Basic authentication is supported. When using pygerrit2 against an earlier Gerrit version, it may be necessary to replace the HTTPBasic… classes with the corresponding HTTPDigest… versions.

Refer to the example script for a full working example.

Release History

This version
History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(19.8 kB) Copy SHA256 Hash SHA256
Source None Dec 16, 2017

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate