In the following sections, we shall learn how Confluence REST APIs work, and their features along with some examples.
- 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.
Introduction to Confluence
- 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.
Understanding REST Architecture
- 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.
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:
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:
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 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:
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:
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:
- Choose the cog icon, then choose General Configuration
- Click Further Configuration in the left-hand panel.
- Click Edit.
- Click the check box next to Remote API (XML-RPC & SOAP).
- 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.
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 😊
Preetipadma is a dedicated technical content writer specializing in the data industry. With a keen eye for detail and strong problem-solving skills, she expertly crafts informative and engaging content on data science. Her ability to simplify complex concepts and her passion for technology makes her an invaluable resource for readers seeking to deepen their understanding of data integration, analysis, and emerging trends in the field.