Comments

Comments a core part of the forum aspect of the Mobile API, they are used by players to share their thoughts on other comments or threads. On this page, we'll dive into the different contact endpoints you can use to manage comments programmatically. We'll look at how to query, create, update, and delete comments.

The comment model

The comment model contains all the information about your comments, such as their content, and reactions.

Properties

  • Name
    id
    Type
    integer
    Description

    Unique identifier for the comment.

  • Name
    children_count
    Type
    integer
    Description

    The amount of children comments for the comment.

  • Name
    children
    Type
    array
    Description

    Array of child comment objects for the comment.

  • Name
    depth
    Type
    integer
    Description

    The depth for the comment.

  • Name
    player
    Type
    object
    Description

    The player who created the comment.

  • Name
    content
    Type
    string
    Description

    The content for the comment.

  • Name
    last_active_at
    Type
    timestamp
    Description

    Timestamp of when the comment was created.


GET/threads/:id/comments

List all comments for a thread

This endpoint allows you to retrieve a paginated list of all the comments associated with a thread. By default, these are sorted by latest.

Optional attributes

  • Name
    sort
    Type
    enum
    Description

    Method used to sort the objects. Possible values are:

    • latest
    • hottest
  • Name
    page
    Type
    integer
    Description

    The page of comments to retrieve.

Request

GET
/threads/1/comments
curl -G https://prod-app.themeparkshark.com/api/threads/1/comments \
-H "Accept: application/json" \
-d sort=latest \
-d page=1

Response

{
  "data": [
    {
      "id": 1,
      "children_count": 5,
      "children": [
        {
          "id": 1,
          "children_count": 0,
          "children": [],
          "depth": 1,
          "player": {
            "id": 1,
            "avatar_url": "https://assets.themeparkshark.com/mobile/production/users/1/avatar.png",
            "is_subscribed": true,
            "screen_name": "tomtheshark",
            "verified_at": null,
            "inventory": {
              "id": 1,
              "pin_item": null,
            }
          },
          "content": "Me too.",
          "created_at": "2023-12-04T15:38:51.000000Z"
        },
        // ...
      ],
      "depth": 1,
      "player": {
        "id": 1,
        "avatar_url": "https://assets.themeparkshark.com/mobile/production/users/1/avatar.png",
        "is_subscribed": true,
        "screen_name": "tomtheshark",
        "verified_at": null,
        "inventory": {
          "id": 1,
          "pin_item": null,
        }
      },
      "content": "I think this is a great idea.",
      "created_at": "2023-12-04T15:38:51.000000Z"
    },
    {
      "id": 2,
      // ...
    }
  ],
  "links": {
    "first": "https://prod-app.themeparkshark.com/api/threads/1/comments?page=1",
    "last": null,
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "path": "https://prod-app.themeparkshark.com/api/threads/1/comments",
    "per_page": 15,
    "to": 6
  }
}

POST/threads/:id/comments

Create a comment

This endpoint allows you to add a new comment to a thread. To add a thread, you must provide content to use.

Required attributes

  • Name
    content
    Type
    string
    Description

    The content for the comment.

Optional attributes

  • Name
    comment_id
    Type
    integer
    Description

    The ID of the parent comment.

Request

POST
/threads/1/comments
curl https://prod-app.themeparkshark.com/api/threads/1/comments \
-H "Accept: application/json" \
-H "Authorization: Bearer {token}" \
-d content="We could meet up on Friday."

Response

{
  "data": {
    "id": 1,
    "depth": 1,
    "player": {
      "id": 1,
      "avatar_url": "https://assets.themeparkshark.com/mobile/production/users/1/avatar.png",
      "is_subscribed": true,
      "screen_name": "tomtheshark",
      "verified_at": null,
      "inventory": {
        "id": 1,
        "pin_item": null,
      }
    },
    "content": "We could meet up on Friday.",
    "created_at": "2023-12-04T15:38:51.000000Z"
  }
}

PUT/comments/:id

Update a comment

This endpoint allows you to perform an update on a comment you have created. Currently, the only attribute that can be updated on contacts is the content attribute.

Required attributes

  • Name
    content
    Type
    string
    Description

    The content for the comment.

Request

PUT
/comments/1
curl -X PUT https://prod-app.themeparkshark.com/api/comments/1 \
-H "Accept: application/json" \
-H "Authorization: Bearer {token}" \
-d content="Hello there."

Response

{
  "data": {
    "id": 1,
    "depth": 1,
    "player": {
      "id": 1,
      "avatar_url": "https://assets.themeparkshark.com/mobile/production/users/1/avatar.png",
      "is_subscribed": true,
      "screen_name": "tomtheshark",
      "verified_at": null,
      "inventory": {
        "id": 1,
        "pin_item": null,
      }
    },
    "content": "Hello there.",
    "created_at": "2023-12-04T15:38:51.000000Z"
  }
}

DELETE/comments/:id

Delete a comment

This endpoint allows you to delete comments that you have created.

Request

DELETE
/comments/1
curl -X DELETE https://prod-app.themeparkshark.com/api/comments/1 \
-H "Accept: application/json" \
-H "Authorization: Bearer {token}"

Was this page helpful?