2

I am trying to export JIRA tasks via API and I hit a wall on excel due to JIRA only allowing a 1000 limit. I can do an export manually to CSV and get over 1000 results and was wondering if anyone had any luck with large JIRA exports via REST API and can help point me in the right direction on this.

Guessing an export to CSV then pull into excel for reporting might work?

Thanks!

user1304228
  • 189
  • 1
  • 4
  • 12

3 Answers3

3

JIRA's REST API supports pagination to prevent that clients of the API can put too much load on the application. This means you cannot just pull in all issue data with 1 REST call.

You can only retrieve "pages" of max 1000 issues using the paging query parameters startAt and maxResults. See the Pagination section here.

If you run a JIRA standalone server then you can tweak the maximum number of results that JIRA returns, but for a cloud instance this is not possible. See this KB article for more info.

GlennV
  • 3,471
  • 4
  • 26
  • 39
1

using jira-python (according to your tag)

# search_issues can only return 1000 issues, so if there are more we have to search again, thus startAt=count
issues = []
count = 0
while True:
    tmp_issues = jira_connection.search_issues('', startAt=count, maxResults=count + 999)
    if len(tmp_issues) == 0:
        # Since Python does not offer do-while, we have to break here.
        break
    issues.extend(tmp_issues)
    count += 999
SgtDroelf
  • 331
  • 1
  • 18
0

The code below will fetch results 200 records at a time, till all records are exported.

you can export max 1000 records at a go by updating the page size, it will recursively fetch 1000 records until everything is exported

var windowSlider = 200

    const request = require('request')
const fs = require('fs')
const chalk = require('chalk')


var windowSlider = 200

var totlExtractedRecords = 0;
fs.writeFileSync('output.txt', '')

const option = {
    url: 'https://jira.yourdomain.com/rest/api/2/search',
    json: true,
    qs: {
        jql: "project in (xyz)",
        maxResults: 200,
        startAt: 0,
    }
}

const callback = (error, response) => {
    const body = response.body

    console.log(response.body)

    const dataArray = body.issues
    const total = body.total


    totlExtractedRecords = dataArray.length + totlExtractedRecords

    if (totlExtractedRecords > 0) {
        option.qs.startAt = windowSlider + option.qs.startAt
    }

    dataArray.forEach(element => {
        fs.appendFileSync('output.txt', element.key + '\n')
    })

    console.log(chalk.red.inverse('Total extracted data : ' + totlExtractedRecords))
    console.log(chalk.red.inverse('Total data: ' + total))

    if (totlExtractedRecords < total) {
        console.log('Re - Running with start as ' + option.qs.startAt)
        console.log('Re - Running with maxResult as ' + option.qs.maxResults)
        request(option, callback).auth('api-reader', 'APITOKEN', true)
    }
}


request(option, callback).auth('api-reader', 'APITOKEN', true)