DHIS2 Application Runtime Fetching

Getting data from the dataStore

Accessing data through from the dataStore is pretty straightforward. You can request and store any form of data from the dataStore by using the API.

  • Full documentation of dataStore can be found here.

Creating a namespace

Before beginning this guide, make sure you've created a namespace for your group. You can do this by:

  1. https://data.research.dhis2.org/in5320/dhis-web-datastore/#/
  2. Click "new" on the top left corner, which will create a new namespace.
  3. Insert the required fields:
    • Namespace field be called IN5320-<Group number> (replace IN5320-<Group number> with your actual group number).
    • Key name field should be "myfirstkey".
  4. Click create. You should now see your namespace on the left of the page.

Retrieve namespaces

To begin with, let's use the API to retrieve all namespaces:

Loading API module...

Test query 1

Task

Click send button to retrieve all namespaces

You should find the namespace which you created for your group in the response results. Otherwise, try creating the namespace again.

Retrieving keys and values

Inside each namespace there is a list of keys. Each of these key is associated with a value as illustrated below:

Key-values
Key-values
Notice that in the example, each key is called "id-xxx". It's not necessary to use this naming pattern, you may choose any name for a key. Similarly, each value is a person's name is the example. You may choose to have different values such as a health-commodity etc. Values can also be any type (i.e objects, strings etc)

Let's find all keys currently stored in our namespace

Loading API module...

Test query 2

Task

Insert the namespace parameter (it should be the namespace you created, ie IN5320-99), then click send.
You should retrieve a response with all keys in your namespace.

Storing a key

Let's store a new key & value. Use the following parameters to store a key:

  • The "namespace" should be the one which you've created previously
  • The "key" can be any name (try naming it something which is understandable for others)

In addition, we'll also provide a body. This body is the "value" we want to store. So open the body tab of the tool write a json object. I.e:

{
"name":"John",
"age":30,
"car":null
}

Loading API module...

Test query 3

Task

Insert the parameters & body as specified above, then click send

Check the response, if it's successful you've created a new key-value in your namespace.

Retrieving the stored key

Let's try finding the key that we stored just stored. Add the parameters:

  • The "namespace" should be the one which you've created previously
  • The "key" should be the key which you used when storing the key (in previous test query)

    Loading API module...

Updating the stored key

Let's try updating the value of a key which we're already created. Add the parameters:

  • The "namespace" should be the one which you've created previously
  • The "key" should be the key which you used when storing the key (in previous test query)
  • Finally, set the body to be different from what you used when storing the key

    Loading API module...

    Test query 4

    Task

    Insert the parameters & body as specified above, then click send
    In the response, you will see if the key was successfully updated

Deleting the stored key

Finally, we will try to delete a stored key. You can simply do this by specifying the parameters as we've done previously for what namespace & key should be deleted.

Loading API module...