Skip to content

Messages

Matthew Taylor edited this page Nov 1, 2017 · 13 revisions

GET /users/:username/messages/count

Returns the number of unread messages for a user. To be released.

Resource Information

  • Response format: JSON

Request URL

https://api.scratch.mit.edu/users/:username/messages/count

Request Parameters

  • :username – the username of the user for whom to get information

Example Request

curl -X GET "https://api.scratch.mit.edu/users/mres/messages/count"

Example Response

{
    "count": 0
}

GET /users/:username/messages

Returns messages for the given user. These are data used to generate notifications that would appear on a user's /messages page on the Scratch website.

Resource Information

  • This endpoint requires authentication. A user is only able to see messages for themselves.
  • Types of messages that are included in this response
    • addcomment
    • forumpost
    • loveproject
    • favoriteproject
    • followuser
    • curatorinvite
    • becomeownerstudio
    • remixproject
    • studioactivity
    • userjoin

Request URL

https://api.scratch.mit.edu/users/:username/messages

Request Parameters

  • :username – the username of the user for whom to get messages

Optional URL Parameters

  • limit – integer value representing the number of messages to limit the response to.
    • Maximum value: 40
    • Default value: 20
  • offset – integer value representing where in the list of the your messages to start retrieving from. Messages are returned in order of when they were created starting with the most recent, so if offset=5, then the response will start with the 5th most recently created message.
    • Default value: 0
  • filter – string value representing the type of messages you'd like to see. Example: if one specifies comments as the filter value, then the only messages that will be retrieved are ones relating to comments.
    • Possible values: all, comments, projects, studios, forums
    • Default value: all

Example Request

curl -X GET "https://api.scratch.mit.edu/users/mres/messages"

Example Response

[
    {
        "datetime_created": "2017-10-31T20:28:56.000Z",
        "comment_type": 1,
        "comment_fragment": "Hufflepuff is here too! We are also totally a house!",
        "type": "addcomment",
        "actor_id": 00000000,
        "actor_username": "<username>",
        "comment_id": 00000000,
        "comment_obj_id": 00000000,
        "comment_obj_title": "<username>",
        "id": 00000000,
        "recipient_id": 00000000
    },
    {
        "datetime_created": "2017-10-31T16:21:14.000Z",
        "topic_title": "Coolest things found in the Room of Requirement",
        "type": "forumpost",
        "actor_id": 00000000,
        "actor_username": "<username>",
        "id": 00000000,
        "recipient_id": 00000000,
        "topic_id": 00000000
    },
    {
        "datetime_created": "2017-10-31T01:55:36.000Z",
        "comment_type": 0,
        "comment_fragment": "My name's Dave and I was also at Hogwarts with HP. We were acquaintances.",
        "type": "addcomment",
        "actor_id": 00000000,
        "actor_username": "<username>",
        "comment_id": 00000000,
        "comment_obj_id": 00000000,
        "comment_obj_title": "<project title>",
        "id": 00000000,
        "recipient_id": 00000000
    }
]