Getting project information for a list of projects from the Jira Cloud API

Hi,

If I have a list of project ids (or keys), is it possible to get project information for each of them in a single call to the API?

The kind of project information I want is that returned from: GET /rest/api/3/project/search, but I don’t see a way to pass a list of project ids to this to filter the response. I could get all of them and then filter out the ones I don’t need, but it would be much more ideal to be able to get just the ones I need.

I could also make a call to GET /rest/api/3/project/{projectIdOrKey} for each one, but that’s a lot of unnecessary calls so the performance would be poor. The list of ids could potentially be quite large.

I’m guessing this isn’t possible. Any ideas of how to achieve this would be appreciated.

Hi @MorganCollins1,

The GET /rest/api/3/project/search resource has a query query parameter that is close to what you’re looking for. It filters projects by key or name which may cause extra results to be returned. For example if you have the following projects:

[{
  key: 'foo'
  name: 'Foo'
}, {
  key: 'bar'
  name: 'Bar'
}, {
  key: 'fb'
  name: 'Foo bar'
}]

Then /rest/api/3/project/search?filter=foo will return project projects foo and fb.

Regards,
Dugald

Hi @dmorrow ,

Sure, that makes sense, but from what I understand from this query is it’s a single query for all projects, where the query is part of the key or the name. That’s not quite what I’m looking for. Let’s say I want to get a list of projects where project keys are:

[{
    key: 'FOO',
    name: 'Foo'
}, 
{
    key: 'FOOQ',
    name: 'Fooq'
}, 
{
    key: 'BAR',
    name: 'Bar'
}]

What about if I wanted BAR and FOO? There’s no part of these two projects where the key or name is the same, and also I don’t want ‘FOO’ and anything else that contains ‘FOO’, I just want ‘FOO’. I also don’t really care about the name, because I have a list of keys for the projects I want, I only want to filter by that property.

Really, I want something like the query parameter to filter the response, but I’d like to just pass it a list of keys, like this: projectKey=FOO,BAR. Then it would return the projects that match this key.

From what I can gather, this isn’t possible currently, right?

Hi @MorganCollins1,

Yes, I agree, the query capability I described isn’t sufficient for your needs as you are wanting to specify multiple project IDs or keys. To be clear, I don’t think there is a solution meeting your needs other than querying all projects and filtering the returned results.

Regards,
Dugald

Hi @dmorrow,

Well, thanks for confirming it for me. For some context, it’s for use within a Jira plugin. Potentially, the amount of projects in the instance could be extremely large whilst the amount of projects I need information for is much smaller, so getting all projects and filtering is also a solution which could lead to poor performance. We can work around this issue, it’d be nice if it was supported in the future, though.

Thanks!
Morgan.

Thanks @MorganCollins1,

I have submitted a feature request for this. Please see https://ecosystem.atlassian.net/browse/ACJIRA-2219.

Regards,
Dugald