HumHub - Polls API (1.0.0)

Download OpenAPI specification:Download

E-mail: info@humhub.com License: AGPLv2

Welcome to the HumHub polls module API reference.

Authentication

Bearer

Security Scheme Type JWT

BasicAuth

Security Scheme Type HTTP
HTTP Authorization Scheme basic

Polls

Find all polls

query Parameters
page
string >= 0

The number of page of the result set.

limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Find all polls by container

path Parameters
id
required
integer

ID of content container

query Parameters
page
string >= 0

The number of page of the result set.

limit
string [ 1 .. 50 ]
Default: 20

The numbers of items to return per page.

Responses

Response samples

Content type
{
  • "total": 76,
  • "page": 1,
  • "pages": 8,
  • "links": {
    },
  • "results": [
    ]
}

Delete polls by container

path Parameters
id
required
integer

The id of content container

Responses

Response samples

Content type
application/json
{
  • "code": 200,
  • "message": "Records successfully deleted!"
}

Poll

Create new poll

path Parameters
id
required
integer

The id of content container

Request Body schema: application/json

Poll information

required
object
newAnswers
required
Array of strings

New answers

object (Content)

Responses

Request samples

Content type
application/json
{
  • "Poll": {
    },
  • "newAnswers": [
    ],
  • "content": {
    }
}

Response samples

Content type
application/json
{
  • "id": 4,
  • "contentcontainer_id": 2,
  • "question": "Poll question from API?",
  • "description": "Poll description from API",
  • "allow_multiple": 1,
  • "created_at": "2021-07-20 09:43:12",
  • "created_by": {},
  • "updated_at": "2021-07-20 09:43:12",
  • "updated_by": {},
  • "is_random": 1,
  • "closed": 1,
  • "anonymous": 0,
  • "show_result_after_close": 0,
  • "answers": [
    ],
  • "content": {}
}

Get a poll by id

path Parameters
id
required
integer

The id of the poll

Responses

Response samples

Content type
application/json
{
  • "id": 4,
  • "contentcontainer_id": 2,
  • "question": "Poll question from API?",
  • "description": "Poll description from API",
  • "allow_multiple": 1,
  • "created_at": "2021-07-20 09:43:12",
  • "created_by": {},
  • "updated_at": "2021-07-20 09:43:12",
  • "updated_by": {},
  • "is_random": 1,
  • "closed": 1,
  • "anonymous": 0,
  • "show_result_after_close": 0,
  • "answers": [
    ],
  • "content": {}
}

Update a poll by id

path Parameters
id
required
integer

The id of the poll

Request Body schema: application/json

Poll information

required
object
answers
Array of strings

Updating answers

newAnswers
required
Array of strings

New answers

object (Content)

Responses

Request samples

Content type
application/json
{
  • "Poll": {
    },
  • "answers": [
    ],
  • "newAnswers": [
    ],
  • "content": {
    }
}

Response samples

Content type
application/json
{
  • "id": 4,
  • "contentcontainer_id": 2,
  • "question": "Poll question from API?",
  • "description": "Poll description from API",
  • "allow_multiple": 1,
  • "created_at": "2021-07-20 09:43:12",
  • "created_by": {},
  • "updated_at": "2021-07-20 09:43:12",
  • "updated_by": {},
  • "is_random": 1,
  • "closed": 1,
  • "anonymous": 0,
  • "show_result_after_close": 0,
  • "answers": [
    ],
  • "content": {}
}

Delete a poll by id

path Parameters
id
required
integer

The id of the poll

Responses

Response samples

Content type
application/json
{
  • "code": 200,
  • "message": "Successfully deleted!"
}

Poll management

Close a poll by id

path Parameters
id
required
integer

The id of the poll

Responses

Response samples

Content type
application/json
{
  • "code": 200,
  • "message": "Poll has been successfully closed."
}

Open a poll by id

path Parameters
id
required
integer

The id of the poll

Responses

Response samples

Content type
application/json
{
  • "code": 200,
  • "message": "Poll has been successfully reopened."
}

Poll voting

Vote on a poll by id

path Parameters
id
required
integer

The id of the poll

Request Body schema: application/json
answers
Array of integers[ items ]

Selected answers

Responses

Request samples

Content type
application/json
{
  • "answers": [
    ]
}

Response samples

Content type
application/json
{
  • "code": 200,
  • "message": "You have voted."
}

Reset vote on a poll by id

path Parameters
id
required
integer

The id of the poll

Responses

Response samples

Content type
application/json
{
  • "code": 200,
  • "message": "You have reset your vote."
}

Get votes on a poll for current user

path Parameters
id
required
integer

The id of the poll

Responses

Response samples

Content type
application/json
[
  • [
    ]
]