What is the Query Playground?
The Data Query Playground is a DHIS2 application that was built to facilitate the development of your application especially when talking to the DHIS2 Web API through the DHIS2 App Runtime.
The Query Playground makes it easy to test different REST API requests and to help you define or experiment writing queries, whether it's for fetching data or mutating data (making POST, PUT or DELETE requests - in the App Runtime these equals to
How to access it?
Through the App Runtime Documentation. When you go to the App Runtime documentation, you will see a big blue button on the sidebar on the left:
How to use it?
When you get to the sign-in page, you will need to enter your existing DHIS2 instance URL as the server as well as username and password.
Once you're signed in, you'll see the following homepage:
On the left, you have the definition of a query that you want to execute, and on the right, you will get the response for that API request.
At the bottom of the query definition section you'll see the options Query and Mutation and the button Execute.
In the example above, we're getting the response of the default data query object which is the resource
me and it's providing the user details.
resource is a type of object that you want to request from the API - we can test other resources such as
In this example, we want to fetch the first 3 programs in the system. Feel free to run this query and check the response:
"fields": ["id", "displayName"]
This application uses JSON syntax which requires double quotes to be used around strings and property names.
To test data mutations you can easily do this by defining the type of mutation that you want to execute. You can specify a
In the example below, we're creating a new program. Notice that the
data property is required in type
create (as well as for type
update - see next section).
"name": "A new Program",
"shortName": "A new Program",
Before running this request, we select the Mutation option and click Execute. See the results on the left:
Useful keyboard shortcut: You can also execute
Mutation without a mouse by pressing
After we've created a new program, we can verify the result of this action by going back to the programs query and executing it again to see the response - as you can see, "A new Program" was successfully added:
delete types, the
id property is required. See the query definition examples below:
"name": "A program - Updated",
"shortName": "A program - Updated",