Bootstrap FreeKB - Atlassian - List Confluence Pages using curl
Atlassian - List Confluence Pages using curl

Updated:   |  Atlassian articles

This assumes you have already created an API token and have a base 64 encoded string of the API token. Check out my article FreeKB - Atlassian - Create API token.

Using the base64 encoded string, you should now be able to submit a GET request and get JSON response. For example, to GET Confluence Pages.

More GET request examples here => The Confluence Cloud REST API

curl \
--silent \
--request GET \
--header "Accept: application/json" \
--header "Authorization: Basic <base64 encoded string>" \
--url "https://acme.atlassian.net/wiki/api/v2/pages"| jq

 

Something like this should be returned.

{
  "results": [
    {
      "parentId": null,
      "spaceId": "15335479",
      "ownerId": "557058:a9d57db5-f0d2-4c9b-b526-18382bec4da0",
      "createdAt": "2022-10-13T20:11:24.718Z",
      "authorId": "557058:a9d57db5-f0d2-4c9b-b526-18382bec4da0",
      "parentType": null,
      "version": {
        "number": 2,
        "message": "",
        "minorEdit": false,
        "authorId": "557058:a9d57db5-f0d2-4c9b-b526-18382bec4da0",
        "createdAt": "2024-10-13T20:11:30.241Z",
        "ncsStepVersion": null
      },
      "lastOwnerId": null,
      "position": 39,
      "body": {},
      "status": "current",
      "title": "my page",
      "id": "15335585",
      "_links": {
        "editui": "/pages/resumedraft.action?draftId=15335585",
        "webui": "/spaces/A1/overview",
        "edituiv2": "/spaces/A1/pages/edit-v2/15335585",
        "tinyui": "/x/oQDq"
      }
    }
  ],
  "_links": {
    "next": "/wiki/api/v2/pages?cursor=eyJpZCI6IjE1MzM1NTg1IiwiY29udGVudE9yZGVyIjoiaWQiLCJjb250ZW50T3JkZXJWYWx1ZSI6MTUzMzU1ODV9",
    "base": "https://acme.atlassian.net/wiki"
  }
}

 

By default, the first 25 pages will be returned. Notice in the above output there is a "next" endpoint. The "next" endpoint can be used to return the next 25 pages.

curl \
--silent \
--request GET \
--header "Accept: application/json" \
--header "Authorization: Basic <base64 encoded string>" \
--url "https://acme.atlassian.net/wiki/api/v2/pages?cursor=eyJpZCI6IjE1MzM1NTg1IiwiY29udGVudE9yZGVyIjoiaWQiLCJjb250ZW50T3JkZXJWYWx1ZSI6MTUzMzU1ODV9"| jq

 

The limit parameter can be used to return a specific number of spaces. The value must be between 1 - 250.

curl \
--silent \
--request GET \
--header "Accept: application/json" \
--header "Authorization: Basic <base64 encoded string>" \
--url "https://acme.atlassian.net/wiki/api/v2/pages?limit=1"| jq

 

If you want to return pages in a space, you can submit a GET request to the spaces endpoint to get the space ID.

curl \
--request GET \
--header "Accept: application/json" \
--header "Authorization: Basic <base64 encoded string>" \
--url "https://acme.atlassian.net/wiki/api/v2/spaces"| jq

 

For example, let's say the space ID is 12345678. You can then submit a GET request to the pages endpoint including the space-id URL paramater to only return the pages in the space.

curl \
--silent \
--request GET \
--header "Accept: application/json" \
--header "Authorization: Basic <base64 encoded string>" \
--url "https://acme.atlassian.net/wiki/api/v2/pages?space-id=12345678"| jq

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter e5734d in the box below so that we can be sure you are a human.