Confluence REST API: Features, Types, Examples

on Confluence • October 26th, 2021 • Write for Hevo

Confluence REST API - Featured Image

The demand for APIs is booming in parallel with the increasing adoption of digital technologies. As companies strive to enhance the pace of their operations, streamline procedures, and provide a better overall customer experience across all industry verticals, APIs have become a focal point for the development of software solutions to achieve those goals. 

APIs allow various internet services to communicate with one another. With APIs, users can retrieve data from another program without having to deal with the user interface of the source application. 

APIs, for example, are used to provide navigation in mobile apps, authenticate consumer bank account information, and connect a patient’s data with third-party billing. 

Today, even team collaboration software like Confluence is offering API options to help companies create, share and collaborate on any content needed for work. 

In the following sections, we shall learn how Confluence REST APIs work, and their features along with some examples.

Table of Content

Introduction to Confluence

Confluence REST API: Confluence Logo
Image Source

Confluence is a team collaboration application by Atlassian that allows team members to communicate as a group by discussing tasks, recording decisions, commenting on documents, and more. 

When new team members join, Confluence provides them with context and history regarding the projects at hand and the team itself.

Confluence features a simple user interface and an editor that resembles standard desktop publishing (DTP) software or word processing tools like Microsoft Word. It offers page templates to assist users in creating content effortlessly. 

However, if developers want to move beyond existing templates, they can create templates from scratch.

Furthermore, Confluence comes with excellent connectors, allowing it to effortlessly integrate with the Atlassian ecosystem and make use of the Atlassian Marketplace’s hundreds of apps. 

It offers REST APIs that can help with either developing an app or integrating Confluence with another application.To know more about Confluence click here.

Simplify REST API ETL with Hevo’s No-code Data Pipeline

A fully managed No-code Data Pipeline platform like Hevo Data helps you integrate and load data from  100+ sources (including 40 Free Data Sources like REST APIs) to a destination of your choice in real-time in an effortless manner. 

Hevo with its minimal learning curve can be set up in just a few minutes allowing the users to load data without having to compromise performance. Its strong integration with umpteenth sources allows users to bring in data of different kinds, but there are times when you need to bring data from multiple different applications or from an in-house REST API, then you can use the REST API Source.

Sign up here for a 14-Day Free Trial!

Understanding REST Architecture

REST API - Architecture
Image Source

REST, which stands for Representational State Transfer, is a software architectural style that establishes a framework for client-server communication via the internet. 

REST is a set of software design restrictions that promotes system performance, scalability, simplicity, and dependability. In simpler words, REST architecture determines what APIs look like.

A REST (or RESTful) web application offers information about its resources without the need for massive processing capabilities. It also allows the client to perform operations on those resources, such as developing new resources or modifying available resources.

Any data in the web service that can be accessed and changed with HTTP queries to the REST API is referred to as a resource. The HTTP method instructs the API on how to handle the resource. 

Using commands like GET (receiving data in a convenient format), POST (creating new data), PUT (updating data), DELETE (deleting data), PATCH (partially update), and others, an HTTP request is used to access web services and manipulate the data. 

Here, each URL is considered a request, and the data returned to the user is referred to as a response.

Understanding REST API

A REST API is a set of protocols that specify how various apps communicate via HTTP. The information flow is quick and efficient in this technique. Because data formats aren’t pre-defined, they may be used for a wider range of purposes and is simpler to create. 

REST APIs have, therefore, become the standard protocol for web-based APIs and are a popular choice among web developers. They allow users to search for items and have the results returned by the service from which they made the request.

To make APIs RESTful, programmers must adhere to a set of guidelines while creating them. The REST set of constraints will make the APIs easier to use and find, making it easy for a developer who is just getting started with these APIs to understand how to leverage them. 

These constraints are Uniform interface, Client-server separation, Stateless, Layered system, Cacheable, and Code-on-demand.

After receiving and processing an HTTP request, a REST API will provide an HTTP response. The HTTP status code is included in this response. This code contains information about the request’s outcomes. 

The status code may be checked by an application issuing API calls, and actions can be taken based on the result. These might include resolving errors or sending a success message to a user.

It is important to note that HTTP status codes appear on all requests made by users. They come in a variety of sizes and are categorized into five types. The first digit denotes which group a code belongs to:

  • 1xx – informational
  • 2xx – success
  • 3xx – redirection
  • 4xx – client error
  • 5xx – server error

Understanding Confluence REST APIs

Confluence REST APIs can be used for a variety of tasks, including creating pages, deleting pages, adding comments, and creating spaces. However, for REST APIs, Confluence only supports two authentication methods:

  • Basic Authentication

It is a simple authentication method built into the HTTP protocol. In this, the encoded username and password are sent by the client which can be easily deciphered hence it is not ideal and thereby not recommended.  

  • Using Confluence as OAuth 2.0 Provider

By using any OAuth/OIDC one can authenticate the REST APIs,  and an access token can be fetched from the OAuth/OIDC which gets revoked after some time, thus making it a more secure and powerful method.  

The Confluence REST API Authentication plugin allows users to authenticate Confluence REST APIs using any third-party OAuth 2.0 provider/OpenID connect.

Features Of Confluence Server REST API

  • CRUD: The Confluence REST APIs in Confluence allows you to access resources (data entities) via URI paths. Your application will perform an HTTP request and interpret the result to use a Confluence REST API.

The response format is JSON by default for a Confluence REST API. The normal HTTP methods include: GET, PUT, POST, and DELETE. Because the Confluence REST API is built on open standards, you can use it with any web development language.

  • Pagination: The Confluence REST API employs pagination, which is a technique that delivers a response containing many objects but can only return a certain amount at a time. This keeps response sizes small and saves server resources.
  • Expansion: To restrict the number of requests to the Confluence REST API and the size of the responses, the Confluence REST API employs resource expansion. Some elements of a resource are not returned until they are expressly requested. This streamlines replies while reducing network traffic for the Confluence REST API.

Confluence Server REST API

The Confluence Server REST API is for administrators who wish to script Confluence Server and Data Center interactions, as well as developers who want to interface with or build on top of the Confluence platform.

Examples:

  • Browsing Content

curl -u admin:admin http://localhost:8080/confluence/rest/api/content/ | python -mjson.tool

  • Read Content and Expand the Body:

curl -u admin:admin http://localhost:8080/confluence/rest/api/content/3965072?expand=body.storage |

python -mjson.tool

Examples:

  • Create a New Page as a Child of Another Page:
Confluence REST API : Create New Page

Image Source

  • Update a Page:
Confluence REST API: Update Page

Image Source

Confluence Cloud REST API

This Confluence REST API is the primary way to retrieve and edit data in Confluence Cloud, whether you’re building an app or another integration.

Examples:

  • Browsing Content:

curl -u admin@example.com:api_token https://your-domain.atlassian.net/wiki/rest/api/content/ | python -mjson.tool

  • Read Content and Expand the Body:

curl -u admin@example.com:api_token https://your-domain.atlassian.net/wiki/rest/api/content/3965072?expand=body.storage | python -mjson.tool

Examples:

  • Browsing Content:

curl -u admin@example.com:api_token https://your-domain.atlassian.net/wiki/rest/api/content/ | python -mjson.tool

  • Read Content and Expand the Body:

curl -u admin@example.com:api_token https://your-domain.atlassian.net/wiki/rest/api/content/3965072?expand=body.storage | python -mjson.tool

Frequently Asked Questions (FAQs)

How do I enable REST API in confluence? 

To use the XML-RPC and SOAP remote APIs you need to enable the APIs from the Administration Console. You’ll need System Administrator permissions to do this. To enable the remote API:

  1. Choose the cog icon, then choose General Configuration
  2.  Click Further Configuration in the left-hand panel. 
  3. Click Edit.
  4.  Click the check box next to Remote API (XML-RPC & SOAP)
  5. Click Save.

What is the difference between Confluence and Jira? 

Jira is a project management platform used by over 65,000 companies that can help with everything from software development to managing your wine collection, and Confluence is a wiki-based content management tool that makes organizing written information easy.

How to call a Confluence REST API? 

Using the Product Fetch API from the @forge/api package, you’ll get the comments on a Confluence page in an array and print the number of comments to the console. The @forge/api package simplifies HTTP operations and contains other Forge APIs such as the Storage and Properties APIs.

What is Confluence used for in agile?

Confluence is used to help teams to collaborate and share knowledge efficiently. With Confluence, we can capture project requirements, assign tasks to specific users, and manage several calendars at once with the help of the Team Calendars add-on.

Conclusion

This article introduces you to the basics of REST API and the key constraints that govern its architecture. It also offers a brief overview of Confluence REST APIs and discusses its authentication methods. We also discussed the Confluence Cloud REST API and its examples.

The REST architectural style is one of the most popular techniques to construct APIs and Python has several useful tools that can be used for both retrieving data from REST APIs and creating your own Python REST APIs. 

Read more about Python REST APIs along with key considerations and comprehensive examples. 

Since Confluence is a collaboration wiki tool used to help teams to collaborate and share knowledge efficiently hence there are multiple sources from which data needs to be extracted. Confluence’s REST API provides an advanced search that lets you use structured queries to search for content within Confluence.

Extracting complex data from a diverse set of free data sources like REST APIs can be a challenging task and this is where Hevo saves the day!

Hevo’s native REST API connector can help connect with a variety of non-native/custom sources into your Data Warehouse to be visualized in a BI tool.

Want to take Hevo for a spin?

Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand. You can also have a look at the unbeatable pricing that will help you choose the right plan for your business needs.

Liked our blog? Please do share your thoughts in the comments below 😊

No-code Data Pipeline for REST APIs