Using JIRA’s REST API to Create a Dashboard

If you read this blog often, you’ll know that I am:

  • crazy about APIs
  • living with some accessibility issues

Put these two things together and what do you get? Actually don’t answer that! Today what you get is an example of integrating with JIRA’s REST API, because their recent “upgrade” locked me out of the issue listings pages completely and I really do need to be able to see a list of bugs! Their bug editing screen is quite usable, so it’s just the list that I need here, but you could easily call their other API methods as you need to.

These examples are PHP and use the PECL_HTTP extension, because it’s awesome, but these examples could be easily adapted to use another language or library.

What’s The REST URL?

We have hosted JIRA from Atlassian, which I think is now called Jira Studio, because they give free pretty-much-unlimited licenses to open source projects, and for that I don’t think I’ll ever be able to thank them enough. Not enough organisations recognise the value of open source!

Our “normal” JIRA URL:

The URL to access the RESTful service: Note this requires SSL.

Getting a List of Issues

This should be easy, but many services make it hard. Not this one, here’s my code:

$request = new HttpRequest();

$issue_list = json_decode($request->getResponseBody());

Now I have all the issues in $issue_list – this is paginated, you can control how many issues you get in a list; the default is 50 I think. You can also pass in any search query – basically the same as the search options that you see in JIRA itself. This uses a language called JQL, and you can find some JQL documents here.

I added some parameters to only show me open and reopened issues, so my code sample now looks like this:

$request = new HttpRequest();
$params = array(
    "jql" => "status in (open, reopened)"

$issue_list = json_decode($request->getResponseBody());

This just limits the results to what you’re interested in; you could easily add things assigned to yourself, or whatever suits your needs.

Displaying Results

To see what you’ve got, use print_r on that list of issues! With this information, I made a screen that looks like this (design is not my strong point!):

The simplest is perhaps just to show the code to generate this output – the “Link” actually goes to the web version of the bug since I can easily access that.

foreach($issue_list->issues as $issue) {
    echo "fields->issuetype->iconUrl . "\" alt=\"" 
        . $issue->fields->issuetype->name . "\" /> \n";
    echo "" . $issue->fields->summary . "\n";
    if(isset($issue->fields->assignee->displayName)) {
        echo " (" . $issue->fields->assignee->displayName . ")\n";
    echo "
\n"; echo "key . "\">Link \n"; $updated = new DateTime($issue->fields->updated); echo "last updated: " . $updated->format('jS M') . "\n"; echo "
\n"; echo "
\n"; }

Since I whipped up this script and will be using it as part of my dashboard of tools, I thought I’d share – I hadn’t seen any integration with JIRA before, but atlassian are focusing all their future efforts on this REST service and my first impressions are that it seems pretty good.

(this isn’t production code, you probably want to check responses and things before you unpack them, but this got me started and I hope it helps you too)

12 thoughts on “Using JIRA’s REST API to Create a Dashboard

  1. Atlassian are pretty good with their SOAP and now REST API’s. I’ve used them quite heavily for intranet/extranet portal projects. The Confluence API is great for surfacing content to users when they’re in other applications.

    • Steve: Thanks for this – I’m just picking up their APIs and it’s reassuring to hear from someone already ahead of me on that journey, cheers for commenting!

    • You do need to have their XML-RPC API enabled in your JIRA installation – ours is the hosted JIRA solution (I think it’s called JIRA Studio just now), and it was already enabled for that

    my name is Itai I’m trying to build an app that will write an issue to JIRA using REST API,
    I tried to implement it in PHP using CURL but i get an error telling me “The specified HTTP method is not allowed for the requested resource (Method Not Allowed).” can you take a look and tell me what am i doing wrong?:

    $headers = array(
    'Accept: application/json',
    'Content-Type: application/json',
    'Authorization: Basic YWRtaW46eWFoYWxh'

    $data = <<‘http://localhost:8084/rest/api/2/issue/’,
    //CURLOPT_HTTPGET =>true,

    CURLOPT_HTTPHEADER=> $headers,

    $ch_error = curl_error($handle);

    if ($ch_error) {
    echo “cURL Error: $ch_error”;
    } else {
    echo $result;



    • I haven’t created issues over the API, my guess is that either you’re posting to the wrong endpoint (so the API responds to say it doesn’t know what you’re asking it to do) or you’re not authenticated. Check those first and let us know how you get on

  3. This code really helped me but I was wondering how to get additional information to display. I also want to get the description for each issue. Is that something I set in $params?

  4. Pingback: How to implement JIRA api with ci application? | BlogoSfera

  5. Pingback: Lunch Links - JIRA BrewJIRA Brew

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.