Debates

Get Single Debate

curl "https://example.ziik.io/api/debates/124"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"

The above command returns JSON structured like this:

  {
          "id":124,
          "content_type":"debate",
          "author":{
              "id":234,
              "name":"Test User",
              "avatar":{
                  "id":"345",
                  "name":"avatar.png",
                  "mime":"image/png",
                  "size":"54314",
                  "type":"image",
                  "source":"https://example.ziik.io/api/file/default_images/avatar.png",
                  "versions":{
                      "listing":"https://example.ziik.io/api/file/styles/article_listing/private/default_images/avatar.png",
                      "detail":"https://example.ziik.io/api/file/styles/article_desktop/private/default_images/avatar.png",
                      "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/default_images/avatar.png"
                  }
              },
              "userType":{
                  "id":11,
                  "name":"Worker",
                  "url":"api/user_types/11"
              },
              "url":"api/users/234"
          },
          "date":1465910290,
          "files":[
              {
                  "id":"937",
                  "name":"begraensningens-kunst.png",
                  "mime":"image/png",
                  "size":"8731",
                  "type":"image",
                  "source":"https://example.ziik.io/api/file/groups/files/begraensningens-kunst.png",
                  "versions":{
                      "listing":"https://example.ziik.io/api/file/styles/article_listing/private/groups/files/example.png",
                      "detail":"https://example.ziik.io/api/file/styles/article_desktop/private/groups/files/example.png",
                      "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/default_images/avatar.png"
                  }
              },

          ],
          "stats":{
              "seen":3,
              "comments":0,
              "likes":3,
              "liked":true
          },
          "body":"This is also a discussion",
          "latest_comment": {
              "id": 45,
              "author": {
                  "See user service..."
              },
              "body": "Test comment for debates",
              "files": [{
                  "id":"345",
                  "name":"filename.png",
                  "mime":"image/png",
                  "size":"54314",
                  "type":"image",
                  "source":"https://example.ziik.io/api/file/groups/avatar.png",
                  "versions":{
                      "listing":"https://example.ziik.io/api/file/styles/article_listing/private/default_images/avatar.png",
                      "detail":"https://example.ziik.io/api/file/styles/article_desktop/private/default_images/avatar.png",
                      "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/default_images/avatar.png"
                  }
              }],
              "date": 1476697957,
              "url": "api/comments/45",
              "permissions": {
                  "edit": false,
                  "delete": true
              }
          },
          "url":"api/debates/124",
          "comments_url":"api/debates/124/comments"
        }

This endpoint returns a single debate

HTTP Request

GET https://example.ziik.io/api/debates/ID

URL Parameters

ParameterTypeDescription
IDIntegerThe ID of the debate

Permissions Required

  • Member of debate's group

Edit a Debate

curl -i -X PATCH "https://example.ziik.io/api/debates/124"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
  -d "{ [...] }"

The above command returns 204 No Content on successful debate update.

HTTP/1.0 204 No Content

This endpoint updates an existing debate.

HTTP Request

PATCH https://example.ziik.io/api/debates/ID

Request Parameters

ParameterTypeRequiredDescription
bodyStringYesDebate body.
filesArrayNoFile data for files to accompany the debate. If provided, existing files are cleared. Must be an array of arrays with the following values
- typeStringYesType of file - can be either 'upload', 'youtube' or 'vimeo'.
- nameStringYesFile name.
- dataStringYesIf type is 'upload' this must be the base64 encoded content of the file. Else it must be the Youtube/Vimeo embed URL.

Permissions Required

  • Either Group administrator
  • OR Debate author

TIP

Authors can only edit or delete debates within 15 minutes of creation.

Delete a Debate

curl -i -X DELETE "https://example.ziik.io/api/debates/124"
  -H "Authorization: Bearer aaaaaa.bbbbbbb.ccccccc"

The above command returns a 204 No Content header on success:

HTTP/1.0 204 No Content

This endpoint deletes a debate.

HTTP Request

DELETE https://example.ziik.io/api/debates/ID

URL Parameters

ParameterTypeDescription
IDIntegerThe ID of the debate to delete

Permissions Required

  • Either Group administrator
  • OR Debate author

TIP

Authors can only edit or delete debates within 15 minutes of creation.

Get Comments for a Debate

curl "https://example.ziik.io/api/debates/124/comments"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"

The above command returns JSON structured like this:

  [{
      "id":1241,
      "author":{
          "id":234,
          "name":"Test User",
          "avatar":{
              "id":"345",
              "name":"avatar.png",
              "mime":"image/png",
              "size":"54314",
              "type":"image",
              "source":"https://example.ziik.io/api/file/default_images/avatar.png",
              "versions":{
                  "listing":"https://example.ziik.io/api/file/styles/article_listing/private/default_images/avatar.png",
                  "detail":"https://example.ziik.io/api/file/styles/article_desktop/private/default_images/avatar.png",
                  "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/default_images/avatar.png"
              }
          },
          "userType":{
              "id":11,
              "name":"Worker",
              "url":"api/user_types/11"
          },
          "url":"api/users/234"
      },
      "body": "This is a comment",
      "files": [{
          "id":"345",
          "name":"filename.png",
          "mime":"image/png",
          "size":"54314",
          "type":"image",
          "source":"https://example.ziik.io/api/file/groups/avatar.png",
          "versions":{
              "listing":"https://example.ziik.io/api/file/styles/article_listing/private/default_images/avatar.png",
              "detail":"https://example.ziik.io/api/file/styles/article_desktop/private/default_images/avatar.png",
              "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/default_images/avatar.png"
          }
      }],
      "date":1465910290,
      "url":"api/comments/1241"
    },
    {
      "id":1242,
      "author":{
          "id":234,
          "name":"Test User",
          "avatar":{
              "id":"345",
              "name":"avatar.png",
              "mime":"image/png",
              "size":"54314",
              "type":"image",
              "source":"https://example.ziik.io/api/file/default_images/avatar.png",
              "versions":{
                  "listing":"https://example.ziik.io/api/file/styles/article_listing/private/default_images/avatar.png",
                  "detail":"https://example.ziik.io/api/file/styles/article_desktop/private/default_images/avatar.png",
                  "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/default_images/avatar.png"
              }
          },
          "userType":{
              "id":11,
              "name":"Worker",
              "url":"api/user_types/11"
          },
          "url":"api/users/234"
      },
      "body": "This is another comment",
      "files": [{
          "id":"345",
          "name":"filename.png",
          "mime":"image/png",
          "size":"54314",
          "type":"image",
          "source":"https://example.ziik.io/api/file/groups/avatar.png",
          "versions":{
              "listing":"https://example.ziik.io/api/file/styles/article_listing/private/default_images/avatar.png",
              "detail":"https://example.ziik.io/api/file/styles/article_desktop/private/default_images/avatar.png",
              "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/default_images/avatar.png"
          }
      }],
      "date":1465910290,
      "url":"api/comments/1242"
    }]

This endpoint returns all comments for a debate

HTTP Request

GET https://example.ziik.io/api/debates/ID/comments

URL Parameters

ParameterTypeDescription
IDIntegerThe ID of the debate

Permissions Required

  • Member of debate's group

Create New Comment

curl -i -X POST "https://example.ziik.io/api/debates/124/comments"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
  -d "{ [...] }"

The above command returns 201 Created with a location header for where to find the new comment

HTTP/1.0 201 Created
Location: https://example.ziik.io/api/comments/1234
{
    "message": "Comment created"
}

This endpoint creates a new comment to a debate.

HTTP Request

POST https://example.ziik.io/api/debates/ID/comments

Request Parameters

ParameterTypeRequiredDescription
commentStringYesComment body.
fileCountIntegerNoNumber of files that will be uploaded (type 'upload') in total, including subsequent POSTs to /api/comments/ID/files
filesArrayNoFile data for files to accompany the comment. If provided, existing files are cleared. Must be an array of arrays with the following values
- typeStringYesType of file - can be either 'upload', 'youtube' or 'vimeo'.
- nameStringYesFile name.
- dataStringYesIf type is 'upload' this must be the base64 encoded content of the file. Else it must be the Youtube/Vimeo embed URL.

Permissions Required

  • Member of debate's group

Get Viewers of a Debate

curl "https://example.ziik.io/api/debates/124/seen"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"

The above command returns JSON structured like this:

{
  "hits": [
    {
      "id":1241,
      "author":{
          "id":234,
          "name":"Test User",
          "avatar":{
              "id":"345",
              "name":"avatar.png",
              "mime":"image/png",
              "size":"54314",
              "type":"image",
              "source":"https://example.ziik.io/api/file/default_images/avatar.png",
              "versions":{
                  "listing":"https://example.ziik.io/api/file/styles/article_listing/private/default_images/avatar.png",
                  "detail":"https://example.ziik.io/api/file/styles/article_desktop/private/default_images/avatar.png",
                  "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/default_images/avatar.png"
              }
          },
          "userType":{
              "id":11,
              "name":"Worker",
              "url":"api/user_types/11"
          },
          "url":"api/users/234"
      },
      "body": "This is a comment",
      "date":1465910290,
      "url":"api/comments/1241"
    },
    {
      "id":1242,
      "author":{
          "id":234,
          "name":"Test User",
          "avatar":{
              "id":"345",
              "name":"avatar.png",
              "mime":"image/png",
              "size":"54314",
              "type":"image",
              "source":"https://example.ziik.io/api/file/default_images/avatar.png",
              "versions":{
                  "listing":"https://example.ziik.io/api/file/styles/article_listing/private/default_images/avatar.png",
                  "detail":"https://example.ziik.io/api/file/styles/article_desktop/private/default_images/avatar.png",
                  "thumbnail":"https://example.ziik.io/api/file/styles/media_thumbnail/private/default_images/avatar.png"
              }
          },
          "userType":{
              "id":11,
              "name":"Worker",
              "url":"api/user_types/11"
          },
          "url":"api/users/234"
      },
      "body": "This is another comment",
      "date":1465910290,
      "url":"api/comments/1242"
    }
  ],
  "meta": {
      "pagination": {
          "total": 315,
          "count": 50,
          "per_page": 50,
          "current_page": 2,
          "total_pages": 7,
          "links": []
      }
  }
}

This endpoint returns users, who have seen a debate

HTTP Request

GET https://example.ziik.io/api/debates/ID/seen

URL Parameters

ParameterTypeDescription
IDIntegerThe ID of the debate

Permissions Required

  • Member of debate's group

Mark Debate Seen

curl -i -X POST "https://example.ziik.io/api/debates/124/seen"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
  -d "{ [...] }"

The above command returns 204 No Content on success.

HTTP/1.0 204 No Content

This endpoint marks a debate as seen by the current user.

HTTP Request

POST https://example.ziik.io/api/debates/ID/seen

Request Parameters

None.

Permissions Required

  • Member of debate's group

Get Debate Likers

curl "https://example.ziik.io/api/debates/123/likes"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"

The above command returns JSON structured like this:

  [{
    "timestamp": 1465823551,
    "user": { "See User Service..." }
  },
  {
    "timestamp": 1465823556,
    "user": { "See User Service..." }
  }]

This endpoint returns a list of users, who have liked a debate along with the timestamp of the like.

HTTP Request

GET https://example.ziik.io/api/debates/ID/like

URL Parameters

ParameterTypeDescription
IDIntegerThe ID of the debate

Permissions Required

  • Read access to the debate

Like debate

curl -i -X POST "https://example.ziik.io/api/debates/123/like"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
  -d "{ [...] }"

The above command returns 204 No Content on success

HTTP/1.0 204 No Content

This endpoint marks a debate as liked by the user.

HTTP Request

POST https://example.ziik.io/api/debates/123/like

Request Parameters

None

Permissions Required

  • Read access to the debate

Unlike a Debate

curl -i -X DELETE "https://example.ziik.io/api/debates/124/like"
  -H "Authorization: Bearer aaaaaa.bbbbbbb.ccccccc"

The above command returns a 204 No Content header on success:

HTTP/1.0 204 No Content

This endpoint removes a like for a debate for the current user.

HTTP Request

DELETE https://example.ziik.io/api/debates/IDlike

URL Parameters

ParameterTypeDescription
IDIntegerThe ID of the debate to unlike

Add Files To Debate

curl -i -X POST "https://example.ziik.io/api/debates/files"
  -H "Authorization: Bearer aaaaaaaaa.bbbbbbbbb.cccccccccc"
  -d "{ [...] }"

The above command returns 204 No Content on success

HTTP/1.0 204 No Content

This endpoint adds files to an existing debate.

HTTP Request

POST https://example.ziik.io/api/debates/files

Request Parameters

ParameterTypeDescription
idIntegerThe ID of the debate to add files to
filesArrayNo
- typeStringYes
- nameStringYes
- dataStringYes

Permissions Required

  • Either Group administrator
  • OR Debate author

TIP

Authors can only add files to debates within 15 minutes of creation.

Delete File From Debate

curl -i -X DELETE "https://example.ziik.io/api/debates/124/files/12345"
  -H "Authorization: Bearer aaaaaa.bbbbbbb.ccccccc"

The above command returns a 204 No Content header on success:

HTTP/1.0 204 No Content

This endpoint deletes a file from a debate.

HTTP Request

DELETE https://example.ziik.io/api/debates/<DebateID>/files/<FileID>

URL Parameters

ParameterTypeDescription
DebateIDIntegerThe ID of the debate
FileIDIntegerThe ID of the file to delete

Permissions Required

  • Either Group administrator
  • OR Debate author

TIP

Authors can only remove files from debates within 15 minutes of creation.