How to query Gerrit with search query over HTTP and get JSON back?

3,731 views
Skip to first unread message

Christoffer Pettersson

unread,
May 29, 2012, 4:16:31 AM5/29/12
to Repo and Gerrit Discussion
I know you can SSH to gerrit and send queries and get JSON back.

However, I read in a blog (which I can't find now), that is it
possible to use a hidden functionality in the web interface to do the
same thing over HTTP. Meaning you can create an URL with query
parameters and Gerrit will return JSON.

Anyone know how to do that? Any example URL would be nice.

Peter Jönsson P

unread,
May 29, 2012, 5:25:23 AM5/29/12
to Christoffer Pettersson, Repo and Gerrit Discussion
Hi!

There where some functionality for that before. It has now been "formalized" into a more RESTful API. But you will need to be running a non-released version that you compile yourself. Documentation here:

https://gerrit-review.googlesource.com/Documentation/rest-api.html

// peter

Christoffer Pettersson

unread,
May 29, 2012, 5:41:15 AM5/29/12
to Repo and Gerrit Discussion
Hm, this looks interesting, but I am unsure this is what I actually
saw in the blog.

He did something like http://gerrit/?q=status:merged and got back JSON
results.

I really wish I could find that blog entry again :-)

// Christoffer



On May 29, 11:25 am, Peter Jönsson P <peter.p.jons...@ericsson.com>
wrote:

Thomas Broyer

unread,
May 29, 2012, 8:07:39 AM5/29/12
to repo-d...@googlegroups.com


On Tuesday, May 29, 2012 11:41:15 AM UTC+2, Christoffer Pettersson wrote:
Hm, this looks interesting, but I am unsure this is what I actually
saw in the blog.

He did something like http://gerrit/?q=status:merged and got back JSON
results.

I really wish I could find that blog entry again :-)

Shawn Pearce

unread,
May 29, 2012, 10:11:34 AM5/29/12
to Christoffer Pettersson, Repo and Gerrit Discussion
In 2.4 and earlier you can do:

curl http://review.example.com/query?q=status:open

and get back JSON results. This format and this URL are now deprecated
and going away.

In master (2.5 and later) the request is now:

curl -H 'Accept-Type: application/json'
http://review.example.com/changes/?q=status:open

This is what the web UI uses to display search results and user
dashboards. The format of the results is different from the older
/query URL.

Christoffer Pettersson

unread,
May 29, 2012, 11:39:57 AM5/29/12
to Shawn Pearce, Repo and Gerrit Discussion
This exactly what I was after, thank you :-)

// Christoffer
Reply all
Reply to author
Forward
0 new messages