Skip to content
Anand Chitipothu edited this page Jul 17, 2016 · 3 revisions

Quick summary of API provided by cleansweep.

Authorization Tokens

Cleansweep currently supports HTTP Basic Auth.

Generate an authorization token by visiting /accounts/tokens and use that token as password for HTTP Basic Auth.

API Endpoints

/api/user

Provides information about the logged in user.

$ curl -u [email protected] http://<host>/api/user
Enter host password for user '[email protected]':
{
  "created": "2015-10-09T03:19:27.470384",
  "email": "[email protected]",
  "id": 1,
  "name": "Some One",
  "phone": "9876500000",
  "place": {
    "key": "KA/AC158/PB0203",
    "name": "PB0203 - Adarsha Vidya Mandira, Room No-1",
    "place_type": "PB"
  },
  "voterid": null
}

Add Volunteer

End Point: /api/<place-key>/volunteers/add

$ curl -u [email protected]:secretauthtoken \
    -X POST -H 'Content-Type: application/json' \
    -d '{"name": "Lal Gore", "email": "[email protected]", "phone": "9876500010"}' \
    http://<host>/api/KA/AC158/PB0203/volunteers/add

The above one will add "Lal Gore" as a new volunteer to KA/AC158/PB0203.

On success, the response will look like the following:

{
    "status": "ok",
    "message": "Added new volunteer successfully",
    "volunteer": {
        "name": "Lal Gore", 
        "email": "[email protected]",
        "phone": "9876500010"
    }
}

On error:

{
    "status": "failed", 
    "errors": [...]
}
Clone this wiki locally