Programming
Radzivon Alkhovik
Low-code automation enthusiast
July 23, 2024
A low-code platform blending no-code simplicity with full-code power 🚀
Get started free
July 23, 2024
•
8
min read

What is Jira REST API: How to Leverage the REST API and Secure Jira API Key

Radzivon Alkhovik
Low-code automation enthusiast
Table of contents

Jira, Atlassian's versatile issue tracking and project management platform, has become an indispensable tool for countless development teams worldwide. While its user-friendly interface makes it easy to manage projects and track issues, Jira's true power lies in its extensive customization options and integration capabilities. Central to this is the Jira REST API, which opens up a world of possibilities for automating tasks, building custom apps, and seamlessly integrating Jira with other tools in your development ecosystem. In this comprehensive guide, we'll dive deep into the Jira REST API, explore its capabilities, and walk through practical examples to help you get started.

Key Takeaways: The Jira REST API is a versatile tool for automating tasks, building custom apps, and integrating Jira with other development tools across both Cloud and Server/Data Center versions. It offers a wide range of capabilities including issue management, bulk operations, and custom reporting, with support for advanced features like pagination and data expansion. While there are some differences between versions, the API's core functionality remains consistent, allowing teams to efficiently customize Jira to their specific needs and integrate it seamlessly with their development ecosystem.

You can try Jira Without Using API on Latenode

What is Jira API?

At its core, an API (Application Programming Interface) is a set of protocols and tools that specify how software components should interact. In the context of Jira, the API allows external applications to interact with Jira programmatically, enabling the retrieval and manipulation of data, as well as the execution of actions within Jira. Jira provides two types of APIs:

What is Java API

The Jira Java API is a powerful tool for developers building custom Jira applications or plugins. It provides direct access to the Jira server's underlying Java objects and methods, allowing deep integration and customization. However, this level of access is only available for on-premise Jira installations (Server or Data Center) where you have direct access to the server. If you're working with Jira Cloud or building a standalone integration, the REST API is the way to go.

What is REST API

REST (Representational State Transfer) is an architectural style that defines a set of constraints for creating web services. A REST API exposes a set of HTTP endpoints that can be accessed by sending requests with specific HTTP methods (GET, POST, PUT, DELETE) to perform operations on resources.

The Jira REST API follows this architecture, providing a comprehensive set of endpoints to interact with almost every aspect of Jira, from issues and projects to agile boards and dashboards. It returns data in JSON format and supports a variety of authentication methods to ensure secure access.

One of the key advantages of the REST API is its platform independence - you can call the API from any device or application that can make HTTP requests, regardless of the programming language used. This makes it the ideal choice for building integrations between Jira and other tools, or for scripting interactions with Jira from the command line.

What can you do with Jira REST API?

The possibilities are nearly endless. Here are just a few examples of what you can achieve with the Jira REST API:

  • Automate Issue Creation: Integrate Jira with your error tracking system or customer support tool to automatically create issues in Jira when certain events occur, complete with all relevant details.
  • Sync Data Between Systems: Keep Jira in sync with other tools in your development pipeline, such as source control systems, CI/CD tools, or test management suites. The API allows you to reflectchanges in Jira to other systems and vice versa.
  • Bulk Operations: Need to update a large number of issues at once? The REST API supports bulk create, update, and delete operations, saving you countless hours of manual work.
  • Custom Dashboards and Reports: Retrieve data from Jira and use it to build custom dashboards, reports, or data visualizations tailored to your team's specific needs.
  • Extend Jira's Functionality: Build custom apps and integrations that extend Jira's capabilities, add new features, or streamline workflows specific to your organization.
  • Migrate Data: Moving from another issue tracking system to Jira? Use the API to programmatically import your existing data into Jira.
  • Backup and Archive: Set up scripts to regularly back up your Jira data or archive old projects and issues.

These are just a few examples - the Jira REST API provides an extensive set of endpoints that cover nearly every feature and function available in Jira's user interface. If you can do it in Jira, chances are you can do it via the API.

Key differences between Jira Cloud REST API and Data Center REST API

While the Jira REST API provides largely the same capabilities across Jira Cloud, Server, and Data Center, there are a few key differences to be aware of:

  • Authentication: Jira Cloud uses OAuth 2.0 or API tokens for authentication, providing a secure and standards-based method for granting access to the API. Jira Data Center, on the other hand, primarily uses basic authentication or session cookies.
  • API Versioning: The Jira Cloud REST API is versioned (currently at version 3), allowing Atlassian to evolve and improve the API over time without breaking existing integrations. Jira Data Center, however, does not have explicit versioning - the API is tied to the specific Jira version.
  • Rate Limiting: To ensure fair usage and maintain performance, Jira Cloud enforces stricter rate limits on API requests compared to Data Center. Integrations need to be designed with these limits in mind and implement appropriate throttling and error handling.
  • URL Format: The endpoint URLs for the REST API differ slightly between Cloud and Data Center. For Jira Cloud, the base URL is in the format https://your-domain.atlassian.net/rest/api/3/, while for Data Center it is https://your-jira-instance.com/rest/api/latest/.

Despite these differences, the core concepts and usage patterns for the REST API remain largely the same across deployments. The skills and knowledge you gain working with one version of the API will be readily transferable to others.

What do you need to work with Jira REST API?

To get started with the Jira REST API, you'll need:

  • A Jira Instance: This could be a Jira Cloud site or a self-hosted Jira Server or Data Center instance. You'll need admin access to set up and manage your API integrations.
  • Authentication Credentials: Depending on your Jira deployment, this could be an OAuth 2.0 token, an API token, or basic auth credentials (username and password).
  • API Client: To make HTTP requests to the API, you'll need an API client. This could be a dedicated API testing tool like Postman, a command-line tool like cURL, or the HTTP library in your programming language of choice (e.g., Python's requests library or JavaScript's fetch API).
  • Reference of Jira API Documentation: Atlassian provides extensive documentation for the Jira REST API, detailing each endpoint, its parameters, and example requests and responses. Keep this close at hand as you explore the API.

With these elements in place, you're ready to start making your first API requests.

How to use Jira REST API 

Let's walk through a practical example of using the Jira REST API to create, retrieve, update, and search for issues. We'll be using Postman for our examples, but the principles apply to any API client.

Step 1: Create a Jira Cloud Account

If you don't already have a Jira instance to work with, the easiest way to get started is to sign up for a free Jira Cloud instance at https://www.atlassian.com/software/jira. Once your site is set up, create a new project to work with.

Step 2: Generate a Jira API Token

To authenticate our API requests, we'll use an API token. Here's how to generate one:

  1. Log in to your Atlassian account and navigate to https://id.atlassian.com/manage-profile/security/api-tokens.
  2. Click "Create API token", give your token a descriptive label, and click "Create".
  1. Copy the generated token and store it securely. You won't be able to view it again after leaving this page.

Step 3: Make your first API request with Postman

Let's start by retrieving the details of an existing issue:

  1. Open Postman and create a new request.
  2. Set the HTTP method to GET and enter the URL for the issue detail endpoint, replacing your-domain with your Jira site's domain and ISSUE-KEY with the key of an issue in your project: https://your-domain.atlassian.net/rest/api/3/issue/ISSUE-KEY
  3. Under the "Authorization" tab, select "Basic Auth" as the type. Enter your Atlassian account's email address as the username and paste your API token as the password.
  4. Click "Send". If everything is set up correctly, you should see a JSON response with the full details of the specified issue, including its fields, comments, attachments, and more.

Step 4: Create an issue

Now let's create a new issue via the API:

  1. In Postman, change the HTTP method to POST and update the URL to the issue creation endpoint: https://your-domain.atlassian.net/rest/api/3/issue
  2. Under the "Headers" tab, add a new key-value pair: "Content-Type" and "application/json". This tells Jira that we're sending a JSON payload.

Switch to the "Body" tab, select the "raw" radio button, and enter the following JSON, replacing the project.key, issuetype.name, summary, and description values as appropriate:



 json

{
  "fields": {
    "project": {
      "key": "YOUR_PROJECT_KEY"
    },
    "issuetype": {
       "name": "Task"
    },
    "summary": "Issue created via REST API",
    "description": {
      "type": "doc",
      "version": 1,
      "content": [
        {
          "type": "paragraph",
          "content": [
            {
              "type": "text",
              "text": "This is a test issue created using the Jira REST API."
            }
          ]
        }
      ]
    }
  }
}

3. Click "Send". Jira will respond with a 201 Created status and the full details of the newly created issue.

Step 5: Update an issue

To update an existing issue, we use the PUT method:

  1. Change the HTTP method to PUT and update the URL to point to the issue you want to update: https://your-domain.atlassian.net/rest/api/3/issue/ISSUE-KEY

In the request body, include the fields you want to update, for example:



 json

{
  "fields": {
    "summary": "Updated summary",
    "description": {
      "type": "doc",
      "version": 1,
      "content": [
        {
          "type": "paragraph",
          "content": [
            {
              "type": "text",
              "text": "This issue has been updated via the REST API."
            }
          ]
        }
      ]
    }
  }
}


2. Click "Send". Jira will respond with a 204 No Content status to indicate the update was successful.

Step 6: Search for issues using JQL

Jira's powerful search capabilities are also accessible via the REST API using JQL (Jira Query Language):

  1. Change the HTTP method back to POST and update the URL to the search endpoint: https://your-domain.atlassian.net/rest/api/3/search

In the request body, include a JQL query and any additional parameters:



 json
Copy
{
  "jql": "project = YOUR_PROJECT_KEY AND status = 'To Do' ORDER BY created DESC",
  "fields": ["summary", "status", "assignee"],
  "maxResults": 10
}

 This query will return the 10 most recently created issues in the 'To Do' status from the specified project, including only the summary, status, and assignee fields.

  1. Click "Send". Jira will respond with a JSON array of issues matching your search criteria.

These examples just scratch the surface of what's possible with the Jira REST API. As you become more familiar with the available endpoints and parameters, you'll be able to build increasingly complex and powerful integrations.

You can Automate Jira Without Using API on Latenode

How to Automate Issue Creation and Updates in Jira Using Latenode

One of the most powerful applications of the Jira REST API is task creation and update automation. With Latenode, you can set up sophisticated workflows that automatically create and update tasks in Jira based on data from external sources or specific triggers. This ensures that information in your project management system remains current and timely, enhancing team efficiency.

For example, you could create a workflow that automatically creates a new task in Jira when an error message is received from a monitoring system, populating all necessary fields and assigning the task to the appropriate developer. As updates come in, the task can be automatically updated, and when the issue is resolved, it can be closed. This streamlined approach not only improves issue tracking but also saves your team time, allowing them to focus on solving problems rather than administrating them.

You can learn more about this script and the integration with Latenode in this article. The integration with Latenode offers a few key benefits:

  • Ease of Use Latenode simplifies the process of using Jira’s API, making it easier for non-technical users to automate project management tasks.
  • Flexible Pricing Users can choose between different Latenode plans, with varying costs and features, to best suit their needs.
  • Comprehensive Solutions Latenode’s integration with Jira provides access to a wide range of project management and issue tracking capabilities.
  • Customization Users can tailor Jira integrations to meet their specific needs, allowing for tailored automation solutions aligned with business goals.

Imagine every important email from a client automatically turning into a task in Jira. With Latenode, this becomes a reality. Our platform ensures the creation of a new task in the right project with populated fields based on the email content, guaranteeing that no important request is missed.

Here's an example of how a Latenode workflow automates Jira task creation and updates based on incoming email data from an external source.

This image would show a visual representation of the workflow in Latenode's interface, with connected nodes representing each step of the process from email receipt to Jira task creation.

This is just one example of how Latenode can transform your approach to using the Jira API with powerful automation. In fact, the platform's capabilities are virtually limitless - you can create any automation scenarios necessary to improve your business efficiency. Whether it's automatic task distribution, sending notifications, tracking key performance indicators, or any other tasks - Latenode provides the tools to bring them to life.

By leveraging Latenode's visual workflow builder and seamless integration with the Jira REST API, you can easily design and implement complex automation scenarios, increasing project management efficiency and accelerating your team's workflows.

If you need help or advice on how to create your own script or if you want to replicate this one, contact our Discord community, where the Low-code automation experts are located.

Jira REST API Pagination, Expansion and Ordering

As you start working with larger datasets in Jira, you'll need to be aware of how the REST API handles pagination, expansion of nested resources, and ordering of results.

Expansion

Many Jira resources contain references to other, nested resources. For example, an Issue contains references to its Project, Issuetype, Creator, Reporter, Assignee, Comments, Attachments, and more. By default, these nested resources are returned as stubs, containing only a few basic fields and a self link to the full resource.

If you need the full details of a nested resource, you can use the expand query parameter to request that Jira includes the full resource in the response. For example, to include the full details of an issue's project and assignee:



GET .../rest/api/3/issue/ISSUE-KEY?expand=project,assignee

You can expand multiple resources by comma-separating them. Be aware that expansions can significantly increase the size of the response payload, so use them judiciously.

Pagination

Requests that could potentially return a large number of results (like JQL searches) are paginated by default. The API will return a maximum number of results per page (defaulting to 50, but customizable up to 100) along with links to the next and previous pages.

You can control pagination using the startAt and maxResults parameters:

  • startAt: The index of the first result to return (0-based)
  • maxResults: The maximum number of results to return per page

For example, to retrieve the second page of results with a page size of 20:



GET .../rest/api/3/search?jql=project=YOUR_PROJECT_KEY&startAt=20&maxResults=20

Your application will need to handle making multiple requests to retrieve all pages of results.

Ordering

You can control the order of results using the orderBy parameter, which accepts a comma-separated list of fields to order by. Each field can be prefixed with a - to indicate descending order.

For example, to order issues by creation date descending, then by priority ascending:

GET .../rest/api/3/search?jql=project=YOUR_PROJECT_KEY&orderBy=-created,priority

Not all fields support ordering - refer to the documentation for the specific endpoint to see what's available.

Jira API usage examples

Here are a couple of more advanced examples demonstrating the power of the Jira REST API for bulk operations.

Bulk creating/updating issues from CSV

Suppose you have a CSV file containing data for multiple issues you want to create or update in Jira. You can use a tool like Postman to automate this process:

  1. In Postman, create a new request for the issue create or update endpoint.

In the Body tab, select the "raw" radio button and enter a template for your issue data, using variables for the fields that will come from your CSV:



{
  "fields": {
    "project": {"key": "{{project_key}}"},
    "issuetype": {"name": "{{issue_type}}"},
    "summary": "{{summary}}",
    "description": {
      "type": "doc",
      "version": 1,
      "content": [
        {
          "type": "paragraph",
          "content": [
            {
              "type": "text",
              "text": "{{description}}"
            }
          ]
        }
      ]
    },
    "assignee": {"name": "{{assignee}}"},
    "priority": {"name": "{{priority}}"}
  }
}

2. Switch to the "Pre-request Script" tab and add code to read your CSV file and set the corresponding variables:



const csvFile = pm.iterationData.readCSV();
pm.variables.set('project_key', csvFile[0]);
pm.variables.set('issue_type', csvFile[1]);
pm.variables.set('summary', csvFile[2]);
pm.variables.set('description', csvFile[3]);
pm.variables.set('assignee', csvFile[4]);
pm.variables.set('priority', csvFile[5]);

3. In the "Runner" window, select your CSV file as the data file and start the run. Postman will create a new request for each row in your CSV, substituting the variables from the file.

This is a powerful technique for bulk importing data into Jira from external sources.

Bulk creating/updating issues from JSON

If your source data is already in JSON format, you can use the bulk create/update endpoint to process multiple issues in a single request:

POST https://your-domain.atlassian.net/rest/api/3/issue/bulk

The request body should contain an array of issue create/update objects, each following the same format as a single issue create/update request:



{
  "issueUpdates": [
    {
      "fields": {
        "project": {"key": "PROJ1"},
        "issuetype": {"name": "Task"},
        "summary": "Issue 1",
        "description": {
          "type": "doc",
          "version": 1,
          "content": [
            {
              "type": "paragraph",
              "content": [
                {
                  "type": "text",
                  "text": "First issue created via bulk update"
                }
              ]
            }
          ]
        }
      }
    },
    {
      "fields": {
        "project": {"key": "PROJ2"},
        "issuetype": {"name": "Bug"},
        "summary": "Issue 2",
        "description": {
          "type": "doc",
          "version": 1,
          "content": [
            {
              "type": "paragraph",
              "content": [
                {
                  "type": "text",
                  "text": "Second issue created via bulk update"
                }
              ]
            }
          ]
        },
        "priority": {"name": "High"},
        "labels": ["bulk-import", "api-test"]
      }
    }
  ]
}

This will create two issues in one request - a Task in the PROJ1 project and a Bug in the PROJ2 project. You can include up to 50 issues in a single bulk request.

The bulk endpoint is also useful for performing bulk transitions, updates, and deletions. For example, to transition multiple issues to the "Done" status:



{
  "transition": {
    "id": "31"
  },
  "issues": [
    {"key": "ISSUE-1"},
    {"key": "ISSUE-2"},
    {"key": "ISSUE-3"}
  ]
}

This assumes that "31" is the ID of your "Done" transition - you can find the available transitions for an issue type via the /rest/api/3/issue/{issueIdOrKey}/transitions endpoint.

Summary

The Jira REST API is an immensely powerful tool for integrating Jira with other systems, automating tasks, and extending Jira's capabilities. In this guide, we've covered the fundamentals of the API, including:

  • The difference between the Java and REST APIs, and when to use each
  • Key differences between the Cloud and Server/Data Center APIs
  • How to authenticate to the API using API tokens or Basic Auth
  • Making your first API requests using Postman
  • Creating, retrieving, updating, and searching for issues
  • Handling pagination, expansion, and ordering of results
  • Advanced use cases like bulk creation/update from CSV and JSON data

However, we've only just scratched the surface. The Jira REST API provides endpoints for working with nearly every aspect of Jira, from projects and boards to users and permissions. As you build your integrations, be sure to refer to the official Atlassian documentation for the most up-to-date and comprehensive information.

With the Jira REST API in your toolkit, the possibilities for what you can do with Jira are nearly endless. Whether you're building a custom reporting dashboard, synchronizing data with another system, or automating complex workflows, the API provides the flexibility and power you need to make it happen.

You can try Jira Without Using API on Latenode

FAQ

What authentication methods are supported by Jira REST API?

Jira Cloud supports OAuth 2.0 and API tokens for authentication. For OAuth, you'll need to register your application in Atlassian's developer console to obtain a client ID and secret. API tokens are a simpler option for scripts and personal integrations. Jira Server and Data Center support Basic Auth (username and password) and session-based authentication using cookies.

Is the Jira REST API different between Jira Cloud and Jira Data Center?

While the core endpoints and functionalities are largely the same, there are some key differences:

  • The base URL for the API is different - Cloud uses https://your-domain.atlassian.net/rest/api/3/, while Server/Data Center uses https://your-jira-instance.com/rest/api/latest/.
  • Cloud enforces stricter rate limits and requires authentication for all requests, while Server/Data Center has more lenient defaults.
  • Some advanced features, like the Agile and Service Desk APIs, have differences in the available endpoints and request/response formats between Cloud and Server/Data Center.

Always refer to the documentation specific to your Jira deployment to ensure you're using the correct URLs and parameters.

How to handle API rate limiting?

Jira Cloud enforces rate limits to ensure the stability and performance of the service. If you exceed the rate limit, you'll receive a 429 Too Many Requests response.

To avoid hitting rate limits:

  • Cache data where possible to avoid making repetitive requests.
  • Use pagination to retrieve large result sets over multiple requests instead of trying to retrieve everything at once.
  • Implement exponential backoff in your client code to progressively increase the delay between retries when a rate limit is encountered.
  • If you have a legitimate need for a higher rate limit, contact Atlassian support to discuss your options.

Server and Data Center deployments have rate limiting disabled by default, but administrators can choose to enable and configure rate limits if needed.

Can I use the Jira REST API for Server/Data Center?

Yes, Jira Server and Data Center have a REST API that is largely similar to the jira Cloud API. The main differences are:

  • The base URL uses /rest/api/latest/ instead of /rest/api/3/.
  • Some endpoints may have slightly different parameters or response formats.
  • Authentication is typically done via Basic Auth or session cookies rather than OAuth or API tokens.

Refer to the Server/Data Center-specific rest api documentation for the most accurate information for your version of Jira.

The Jira REST API is a powerful and flexible way to integrate Jira into your development workflow. Whether you're working in the cloud or managing your own server, the API provides the tools you need to automate, customize, and extend Jira to fit your team's unique needs. With a little exploration and experimentation, you'll be able to unlock the full potential of Jira and take your project management to the next level.

Related Blogs

Use case

Backed by