Scores
Please note this scores-section of the SELF documentation is not yet configured and the documentation has also not been altered. It is only meant for demo purposes for this rudimentary stage of our API documentation. We are looking forward to hear your inputs!
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.
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
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"
// ...
}
]
}
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
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
}
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
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
}
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
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 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
curl -X DELETE https://api.self.chat/v1/scores/xgQQXg3hrtjh7AvZ \
-H "Authorization: Bearer {token}"