Confluence Server REST API: given a list of ids, how to get their metadata in one query?

Hello everyone, we make extensive use of confluence server REST API and, currently, need to solve the following problem:

Given a list of page ids, how to get each page’s properties?

Currently, our solution simply iterates through this list and retrieves the properties of each page by leveraging:

https://docs.atlassian.com/ConfluenceServer/rest/7.18.3/#content-getContentById

i.e.:

GET 

http://base.url/rest/api/content/{id}?expand=metadata.labels,body.view,etc

Where {id} is the id of a page.

This results in poor perfomance and creates a ton of connections.

What I am looking for is something like:

GET 

http://base.url/rest/api/content?expand=metadata.labels,body.view,etc&id={list_of_ids}

Where {list_of_ids} is a comma-separated list of pages.

But, currently, this functionality is unfortunately missing, is there any other way to get the desired outcome?

Technical details about our setup:
Confluence server:
Version: 7.4.11
BuildNumber: 11943

As for page ids, they belong to different spaces and generally have almost nothing in common, except that they are hosted on one confluence server.

Hi @GustawBobowski

you can use search content API - https://docs.atlassian.com/ConfluenceServer/rest/7.18.3/#content-search

URL/rest/api/content/search?cql=id = 123 or id = 456 or id = 789&expand=expand=metadata.labels,body.view

Cheers
Adam

1 Like

Thank you!

This seems to be what I need:
cql=id in (id1,id2,...idN)

However, are there any limits to how many elements can be in the list?

The default is 25, but you can get more results when you add &limit=100

The maximum is probably 500 but you can verify it in the API response itself

Cheers
Adam

1 Like