Scores

Scores are used for the example game used in SELF — they are the containers for the games between you, your contracts, and dApps. On this page, we’ll dive into the different score endpoints you can use to manage scores programmatically. We'll look at how to query, create, update, and delete scores.

The score model

The score model contains all the information about the scores between you and your contacts.

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the score.

  • Name
    game_id
    Type
    string
    Description

    Unique identifier for the other contact in the score.

  • Name
    avatar_id
    Type
    string
    Description

    Unique identifier for the group that the score belongs to.

  • Name
    created_at
    Type
    timestamp
    Description

    Timestamp of when the score was created.

  • Name
    archived_at
    Type
    timestamp
    Description

    Timestamp of when the score was archived.


GET/v1/scores

List all scores

This endpoint allows you to retrieve a paginated list of all your scores. By default, a maximum of ten scores are shown per page.

Optional attributes

  • Name
    limit
    Type
    integer
    Description

    Limit the number of scores returned.

  • Name
    muted
    Type
    boolean
    Description

    Only show scores that are muted when set to true.

  • Name
    archived
    Type
    boolean
    Description

    Only show scores that are archived when set to true.

  • Name
    pinned
    Type
    boolean
    Description

    Only show scores that are pinned when set to true.

  • Name
    group_id
    Type
    string
    Description

    Only show scores for the specified group.

Request

GET
/v1/scores
curl -G https://api.self.chat/v1/scores \
  -H "Authorization: Bearer {token}" \
  -d limit=10

Response

{
  "has_more": false,
  "data": [
    {
      "id": "xgQQXg3hrtjh7AvZ",
      "game_id": "WAz8eIbvDR60rouK",
      "group_id": null,
      "pinned_message_id": null,
      "is_pinned": false,
      "is_muted": false,
      "last_active_at": 705103200,
      "last_opened_at": 705103200,
      "created_at": 692233200,
      "archived_at": null
    },
    {
      "id": "hSIhXBhNe8X1d8Et"
      // ...
    }
  ]
}

POST/v1/scores

Create a score

This endpoint allows you to add a new score between you and a contact or group. A contact or group ID is required to create a score.

Required attributes

  • Name
    game_id
    Type
    string
    Description

    Unique identifier for the other contact in the score.

  • Name
    group_id
    Type
    string
    Description

    Unique identifier for the group that the score belongs to.

Request

POST
/v1/scores
curl https://api.self.chat/v1/scores \
  -H "Authorization: Bearer {token}" \
  -d 'game_id'="WAz8eIbvDR60rouK"

Response

{
  "id": "xgQQXg3hrtjh7AvZ",
  "game_id": "WAz8eIbvDR60rouK",
  "group_id": null,
  "pinned_message_id": null,
  "is_pinned": false,
  "is_muted": false,
  "last_active_at": null,
  "last_opened_at": null,
  "created_at": 692233200,
  "archived_at": null
}

GET/v1/scores/:id

Retrieve a score

This endpoint allows you to retrieve a score by providing the score ID. Refer to the list at the top of this page to see which properties are included with score objects.

Request

GET
/v1/scores/xgQQXg3hrtjh7AvZ
curl https://api.self.chat/v1/scores/xgQQXg3hrtjh7AvZ \
  -H "Authorization: Bearer {token}"

Response

{
  "id": "xgQQXg3hrtjh7AvZ",
  "game_id": "WAz8eIbvDR60rouK",
  "group_id": null,
  "pinned_message_id": null,
  "is_pinned": false,
  "is_muted": false,
  "last_active_at": 705103200,
  "last_opened_at": 705103200,
  "created_at": 692233200,
  "archived_at": null
}

PUT/v1/scores/:id

Update a score

This endpoint allows you to perform an update on a score. Examples of updates are pinning a message, muting or archiving the score, or pinning the score itself.

Optional attributes

  • Name
    pinned_message_id
    Type
    string
    Description

    Unique identifier for the pinned message.

  • Name
    is_pinned
    Type
    boolean
    Description

    Whether or not the score has been pinned.

  • Name
    is_muted
    Type
    boolean
    Description

    Whether or not the score has been muted.

  • Name
    archived_at
    Type
    timestamp
    Description

    Timestamp of when the score was archived.

Request

PUT
/v1/scores/xgQQXg3hrtjh7AvZ
curl -X PUT https://api.self.chat/v1/scores/xgQQXg3hrtjh7AvZ \
  -H "Authorization: Bearer {token}" \
  -d 'is_muted'=true

Response

{
  "id": "xgQQXg3hrtjh7AvZ",
  "game_id": "WAz8eIbvDR60rouK",
  "group_id": null,
  "pinned_message_id": null,
  "is_pinned": false,
  "is_muted": true,
  "last_active_at": 705103200,
  "last_opened_at": 705103200,
  "created_at": 692233200,
  "archived_at": null
}

DELETE/v1/scores/:id

Delete a score

This endpoint allows you to delete your scores in SELF. Note: This will permanently delete the score and all it's messages — archive it instead if you want to be able to restore it later.

Request

DELETE
/v1/scores/xgQQXg3hrtjh7AvZ
curl -X DELETE https://api.self.chat/v1/scores/xgQQXg3hrtjh7AvZ \
  -H "Authorization: Bearer {token}"