Session
The following table contains a list of favorites that can be set and the arguments needed for each type of favorite:
Type | Arguments needed |
---|---|
league |
game_class , league |
league |
game_class , league , group |
club |
club_id |
team |
team_id |
player |
player_id |
The type argument is always needed and must be set to the first column above. The second league
favorite is a variant, limiting also to a single group.
Add a favorite
Definition
POST https://api-v2.swissunihockey.ch/api/sessions/add_favorite
Add a favorite to this users list of favorites. A favorite is a JSON encoded string; here's a typical favorite:
{
"type": "league",
"game_class": 11,
"league": 1
}
The body of your POST should contain the following fields:
- sid
- string
- session reference that was obtained at the last call or
null
. - favorites[]
- json_string
- json string of favorite to add
Favorites are attached to sessions. These expire after 30 days.
To obtain a new session, you don't need to do anything special, just call this method with either null
or an invalid session reference as argument.
This function returns a structure that has two fields:
{
"type": "session",
"data": "SESSION_ID"
}
You should always use the returned session id in subsequent calls - it is guaranteed to be valid and to contain the favorite you just added.
Remove a favorite
Definition
POST https://api-v2.swissunihockey.ch/api/sessions/remove_favorite
Removes a favorite from this users list of favorites, identified by session id.
The body of your POST should contain the following fields:
- sid
- string
- session reference that was obtained at the last call or
null
. - favorites[]
- json_string
- json string of favorite to add
This function returns a structure that has two fields:
{
"type": "session",
"data": "SESSION_ID"
}
You should always use the returned session id in subsequent calls - it is guaranteed to be valid and to NOT contain the favorite you just removed.
Matchcenter
Definition
GET https://api-v2.swissunihockey.ch/api/sessions/matchcenter
Returns all data necessary for the display of the matchcenter. Please pass the following arguments to the request:
- sid
- string
- session reference that was obtained at the last call or
null
.
All known favorite types in the session passed as argument will be turned into sections in the return value that looks like this:
{
"type": "matchcenter",
"data": {
"sections": [
{
"type": "league",
"title": "Section Title"
"context": {
"type": "league",
"game_class": 11,
"league": 1
}
}
]
}
}
To use this return value, you should iterate over the sections of the matchcenter and then perform further calls on the sections that you want to output. For example, given the context above, you could call /games
and retrieve a list of upcoming games for the context. This table can then be rendered in a section that has the title returned in the matchcenter return value.