Skip to content

Votes

The vote object

{
    "id": 2489,
    "created": "2021-06-23T08:12:08.503002Z",
    "author": {
        "id": 202,
        "first_name": "Josh",
        "last_name": "Sharp",
        // shown here if team member
        "email": null,
        // denotes if this user is a team member
        "staff": false
    }
}

Get all votes for a task

Pass in the ID of the task in the URL.

GET https://changemap.co/api/1/map/tasks/:id/votes/

Request

curl "https://changemap.co/api/1/map/1/votes/" \
  -H "Authorization: Token [your_token]"
import requests

task = 1
url = f"https://changemap.co/api/1/map/tasks/{task}/votes/"
requests.get(url,
    headers={'Authorization':'Token [your_token]'})

Response

Returns a paged list of votes.

{
    "count": 5,
    "next": null,
    "previous": null,
    "results": [
        { 
            // json vote object
        }
    ]
}

Get a specific vote

Pass in the ID of the vote in the URL.

GET https://changemap.co/api/1/map/votes/:id/

Request

curl "https://changemap.co/api/1/map/votes/1/" \
  -H "Authorization: Token [your_token]"
import requests

pk = 1
url = f"https://changemap.co/api/1/map/votes/{pk}/"
requests.get(url,
    headers={'Authorization':'Token [your_token]'})

Response

Returns a JSON vote object, or a HTTP 404 if it isn't found.

{
    "id": 2489,
    // snip...
}

Delete a vote

Use the DELETE method and pass the vote ID to specify which vote.

DELETE https://changemap.co/api/1/map/votes/:id/

Request

curl "https://changemap.co/api/1/map/votes/1/" \
  -X "DELETE" -H "Authorization: Token [your_token]"
import requests

pk = 1
url = f"https://changemap.co/api/1/map/votes/{pk}/"
requests.delete(url,
    headers={'Authorization':'Token [your_token]'})

Response

Returns an empty HTTP 204 if successful, or HTTP 404 if not found.