Skip to content
Javascript library for DHIS 2 app development
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


build status greenkeeper badge npm version

The full api documentation is available here. To get started we suggest you read the overview. If you already know what you're looking for we suggest the reference material on what is available on the instance of d2.

For more information on how the models work the model module documentation is helpful reference material. For other questions see the FAQ.

Quickstart guide


Start with adding d2 to your project:

yarn add d2 or npm install d2

After installing you will be able to import the library into your project by using the files in the lib folder:

// Using ES2015 imports
import d2 from 'd2';

// Using CommonJS imports
var d2 = require('d2');

Initialise the library

To be able to use d2 you will first need to initialise the library. This is required to let the library know where it should load its data from (e.g. the schemas, currentUser, authorities). The schemas are the definitions of the data model as used in DHIS2.

To do this you can provide d2 with a baseUrl (if you don't provide any the default of ../api will be used):

import { init } from 'd2';

init({ baseUrl: '' })
  .then(d2 => {
    //Your d2 is initialised and ready to use.

Get first page of users and print their names

  .then(userCollection => {
    userCollection.forEach(user => console.log(;

That's it! See the documentation referenced above for further information.

You can’t perform that action at this time.