API 101

Using the WEB API

Welcome!

Introduction

  • Getting set up
  • Authentication
  • Doing some api work

Browser addon or cURL

goo.gl/G2VjZc

goo.gl/LRnKLb

Chrome

Firefox

cURL

  • `-v` for more information
  • `-u` for adding Basic auth
curl https://apps.dhis2.org/demo/api/dataSets.json -u admin:district -v
curl -H "Content-Type: application/json" -X PATCH -d '{"code":"IN_394130"}' \
http://localhost:8080/dhis/api/indicators/tcs5YGnjiKo.json -u admin:district -v

curl -H "Content-Type: application/json" -X PATCH -d @data.json \
http://localhost:8080/dhis/api/indicators/tcs5YGnjiKo.json -u admin:district -v

Local or Demo

https://apps.dhis2.org/demo/api

Authentication

  • Basic Authentication
    • base64(admin:district)
    • Do not use without SSL
  • OAuth 2
    • More advanced (See docs)

Todo!

  • Create a dataSet, dataElement, dataValue
  • Read data value
  • Delete dataSet
  • Field filtering
  • Filtering in the api

HTTP Methods

  • GET (Read)
  • POST (Create)
  • PUT (Update)
  • DELETE
  • PATCH (Partial update)

JSON Data

goo.gl/y5qGfW

Lets go! :)

DHIS2 API 101

By markpolak

DHIS2 API 101

  • 301