HAPI

HAPI is an API used for carrying out common tasks in Jira. These can include managing or searching for issues, updating fields and more. HAPI is not a new a programming language, it's essentially plain Groovy, but it gives you a simpler alternative to Jira's regular API and you can mix and match HAPI calls with Jira API.


Visit ScriptRunner HQ to find out more about HAPI. 


Check out our HAPI walkthrough video for a demonstration of how to use HAPI.

Who is HAPI for?

Whether you're a complete beginner or an experienced developer, HAPI is for you and your business. It increases productivity and efficiency by allowing you to create automations and customizations faster than ever and helping you understand the code better.

For example, look how simple the HAPI script is for creating an issue:

groovy
Issues.create('ABC', 'Task') { setSummary('my first HAPI') }

We want all users to be able to script in ScriptRunner, not just those who are familiar with the Jira API and we think HAPI achieves that. HAPI does not require you to rewrite existing scripts. However, should you wish to make your current scripts more manageable then you might want to update them to use HAPI.

Permissions

HAPI respects the permissions of the current user by default. Using HAPI does not change any of the permissions ScriptRunner already has. 

Note that some operations in Jira are restricted for Atlassian Connect apps, and HAPI runs on ScriptRunner which is a Connect app. For example, read about group membership management.

This limitation is not specific to HAPI; it applies to all Connect apps, so even writing the REST request directly will not work when coming from ScriptRunner.

Completions

When using HAPI you'll notice helpful completions with available methods within the context of your operation.

Shortcut

If you need to display completions after they have disappeared, simply press the keyboard shortcut Control + Space.

Performance

HAPI has been developed with the performance needs of large instances in mind. Under the hood, HAPI optimises the usage of the Jira REST API. However, script execution time is limited, so handling larger datasets may result in time-outs before tasks are completed. HAPI is a powerful API so it will not complain when you try to perform larger tasks, such as when performing a JQL search over millions of issues. Nevertheless, this may hit the script time-out limits.

Keyboard shortcut

You will find the keyboard shortcut Control + Space very useful when using HAPI. This shortcut allows you to display completions when they disappear. There are a number of reasons you could want to display completions again. For example:

  • You’ve started typing and selected the wrong value, so you go back and delete some text and completions no longer display.
  • You’ve clicked out of the script console and when you return completions no longer display.
  • You’ve deleted a chosen option in a string and want to see what all of the options were again.

When viewing an autocomplete suggestion, pressing Control + Space again displays any associated Javadocs for the selected suggestion.

Example scripts

Our example scripts also include HAPI code samples, that way you can get started with just a click! We've added the example scripts you will find the most useful. 

Library

We've updated a number of Library scripts to include HAPI methods. If you have used any of these Library scripts in the past, you'll notice they're shorter and easier to understand because of HAPI.

Compatibility

HAPI is compatible with Jira Software and Jira Service Management (JSM).

Javadocs

See our Javadocs for a full list of HAPI classes and API methods.

On this page