Limiting
Sometimes you just want to limit your response a little bit!
In the previous tutorial, we have explained the fundamentals of filtering API responses, which allows you to request the exact data you need. However, sometimes the response can be rather large. In such cases, you can use our limiting feature. In this part of our tutorial, you will be able to limit your API responses.

What is limiting?

Limiting, as its name suggests, will limit the response you get from our API to a specific amount. Limiting your API responses can come in handy when you want to avoid big API responses. In this tutorial, we'll show you how limiting is used and why it may be handy for you. Let's go!

Create the request

In this tutorial, we will request all the fixtures from the 20/21 season from the Scottish Premiership (season id: 17141). As for the endpoint, we’ll go with season by id. Furthermore, as discussed in our includes tutorial, we’ll enrich the response with an include. In this case, we’ll use the include called fixtures
The below request will give you all the fixtures of the 20/21 season of the Scottish Premiership (season id: 17141).
The response is enormous. Therefore, we've copied a small snippet instead of the full response.
Requests
Response
Field Description
1
https://soccer.sportmonks.com/api/v2.0/seasons/17141?api_token={API_TOKEN}&include=fixtures
Copied!
1
{
2
"data": {
3
"id": 17141,
4
"name": "2020/2021",
5
"league_id": 501,
6
"is_current_season": true,
7
"current_round_id": 194976,
8
"current_stage_id": 77447501,
9
"fixtures": {
10
"data": [
11
{
12
"id": 16475283,
13
"league_id": 501,
14
"season_id": 17141,
15
"stage_id": 77447501,
16
"round_id": 194968,
17
"group_id": null,
18
"aggregate_id": null,
19
"venue_id": 281425,
20
"referee_id": 15818,
21
"localteam_id": 496,
22
"visitorteam_id": 258,
23
"winner_team_id": 496,
24
"weather_report": {
25
"code": "clouds",
26
"type": "broken clouds",
27
"icon": "https://cdn.sportmonks.com/images/weather/04d.png",
28
"temperature": {
29
"temp": 60.62,
30
"unit": "fahrenheit"
31
},
32
"temperature_celcius": {
33
"temp": 15.9,
34
"unit": "celcius"
35
},
36
"clouds": "75%",
37
"humidity": "72%",
38
"pressure": 1013,
39
"wind": {
40
"speed": "5.82 m/s",
41
"degree": 300
42
},
43
"coordinates": {
44
"lat": 55.83,
45
"lon": -4.43
46
},
47
"updated_at": "2020-08-01T15:45:06.417645Z"
48
},
49
"commentaries": false,
50
"attendance": null,
51
"pitch": null,
52
"details": null,
53
"neutral_venue": false,
54
"winning_odds_calculated": true,
55
"formations": {
56
"localteam_formation": "4-2-3-1",
57
"visitorteam_formation": "3-4-2-1"
58
},
59
"scores": {
60
"localteam_score": 1,
61
"visitorteam_score": 0,
62
"localteam_pen_score": null,
63
"visitorteam_pen_score": null,
64
"ht_score": "1-0",
65
"ft_score": "1-0",
66
"et_score": null,
67
"ps_score": null
68
},
69
"time": {
70
"status": "FT",
71
"starting_at": {
72
"date_time": "2020-08-01 14:00:00",
73
"date": "2020-08-01",
74
"time": "14:00:00",
75
"timestamp": 1596290400,
76
"timezone": "UTC"
77
},
78
"minute": 90,
79
"second": null,
80
"added_time": null,
81
"extra_minute": null,
82
"injury_time": null
83
},
84
"coaches": {
85
"localteam_coach_id": 1621,
86
"visitorteam_coach_id": 22145896
87
},
88
"standings": {
89
"localteam_position": 3,
90
"visitorteam_position": 12
91
},
92
"assistants": {
93
"first_assistant_id": 12770,
94
"second_assistant_id": 36793,
95
"fourth_official_id": 19329
96
},
97
"leg": "1/1",
98
"colors": {
99
"localteam": {
100
"color": "#F0F0F0",
101
"kit_colors": "#F0F0F0,#F0F0F0,#0A0A0A,#0A0A0A,#0A0A0A,#FFDF1B,#F0F0F0"
102
},
103
"visitorteam": {
104
"color": "#FDBD0F",
105
"kit_colors": "#FDBD0F,#FDBD0F,#FAE403,#FAE403,#5C8FAE,#FFDF1B,#FDBD0F"
106
}
107
},
108
"deleted": false
109
},
110
111
Copied!
Season Field Description
Field
Description
data
Opens an array of data you've requested
id
The unique season id
name
The name of the season
league_id
The unique league id the season belongs to
is_current_season
Indicates if the season is the current one. Possible values are "true" or "false"
current_round_id
The unique id of the current round
current_stage_id
The unique id of the current stage
Fixtures Field Description
Field
Description
data
Opens an array of data you've requested
id
A unique fixture id
league_id
The unique id of the league the fixture belongs to
season_id
The unique id of the season the fixture belongs to
stage_id
The unique id of the stage the fixture belongs to
round_id
The unique id of the round the fixture belongs to
group_id
The unique id of the group the fixture belongs to
aggregate_id
Indicates if the fixture has an aggregated score
venue_id
The unique id of the venue the fixture is played at
referee_id
The unique id of the referee that is in charge of the fixture
localteam_id
The unique id of the local team
visitorteam_id
The unique id of the visitor team
winnerteam_id
Contains the id of the team that won the fixture
weather_report
Opens an array of weather details. Possible values of the data in this array can be found in our statuses and definitions
commentaries
Indicates if this fixture has commentaries available
attendance
Give information about the visitor attendance of the fixture
pitch
Gives information about the pitch. Possible values can be found in our statuses and definitions
details
Optional additional information.
neutral_venue
Indicates if the fixture was played at a neutral fixture. This often happens in cup finals

Evaluate the response

Your first thought is probably: ‘Wow that’s an enormous response’. This is because football seasons tend to have a large number of matches. In order, to make the response more legible we can introduce a limit.

Limit the response

By limiting the response, we mean that you can limit the number of results per page. Let’s say we want to limit the response to only five results per page. You still need to use the fixtures include, but now you can add :limit(X|X).
The first attribute (X) is the number of records per page, while the second (X) is the page currently browsed.
For example, if you want 5 fixtures per page and you want to browse the first page: &include=fixtures:limit(5|1)
1
https://soccer.sportmonks.com/api/v2.0/seasons/17141?api_token={API_TOKEN}&include=fixtures:limit(5|1)
Copied!
Now there are only five results per page! Moreover, you can simply replace the ‘1’ in (5|1) for a ‘2’, if you want to go to the second page. And just like that, you have successfully limited an API response!
Note that paginating through includes count towards your request limit
You’ve learnt how to filter and limit your response. Next up you will learn how to sort the API response.
Last modified 9mo ago