
In February, we released version 3.0 of our add-on PocketQuery for Confluence. One major new feature was the introduction of REST APIs as datasources. Now, we would like to demonstrate some catchy and practical example usages, that you can copy, adjust to your needs or just use as an inspiration. We will start with one example in this blog post and continue with a second one within the next few days.
You should already be familiar with PocketQuery in general and its handling of REST APIs. Otherwise, please have a look at the Getting Started Guide first.
Wikipedia: Integrating Knowledge
If you are using Confluence, chances are that you are collecting knowledge. This knowledge is contributed by everyone who creates and edits pages. With the help of PocketQuery, you can also integrate external knowledge sources to enrich and further complete the contents of your knowledge base.
How about adding a whole Wikipedia article to your Confluence, that is styled correctly and even integrates into Confluence Search?

Datasource
Datasource typeREST CustomDatasource URL"https://en.wikipedia.org/w/api.php"
The Wikipedia REST API is a charming example: it’s very basic, yet very powerful. As the data is publicly available, there is no need for authentication.
We’ll start by adding a new datasource of the type “REST Custom”, but we can neglect all of the advanced options. All we need is a meaningful name and the REST base URL “https://en.wikipedia.org/w/api.php”. This is even sufficient for a successful connection test- we do not need to append a test URL.
Query
Query URL?action=parse&page=:title&format=json
Query JSON path$.parse.text['*']
Query settings Enable "Add results to Confluence search"
Again, nothing fancy here. We need to select our Wikipedia datasource, a name, the REST URL that will be appended to the base URL defined in the datasource (in this case ?action=parse&page=:title&format=json) and the JSON Path to the data of interest within the result. Note that we use a parameter in the Query which allows us to set the name of the Wikipedia article (:title).
The JSON Path can be found easily by having a look at the result from the Wikipedia REST API. Simply call an URL like “https://en.wikipedia.org/w/api.php?action=parse&page=Atlassian&format=json” by e.g. pasting it into a browser and use a JSON formatter to get an idea of the structure of the result: