Selecting fields
Last updated
Was this helpful?
Last updated
Was this helpful?
API 3.0 introduces the possibility to request specific fields on entities. This possibility comes in handy when you only use particular fields in an API response. The advantage of selecting specific fields is that it reduces the response speed in mainly large responses. In addition to reducing response time, the response size can also be drastically reduced. Let's take a look together at an example.
One of our new additions to API 3.0 is a name field on the fixtures. The name field contains a textual representation of the participants playing the fixture. Without selecting a specific field, the API request and response would look like this:
As you can see, the API response is rather large if you're only interested in the fixture's name. Let's select that API field to reduce the response length and size.
We're using the . This means we can select on all the fields of the You can do this by adding &select=
{specific fields on the base }.
In our example, this would result in the below API request and response:
As you can see in the example response above, the 'name' field is only returned for the fixture.
You can also use field selection based on includes. Imagine you want to access fixture lineup information from Celtic vs Ranger (fixture id: 18535517). Additional to the lineups, you also wish to receive the display names, player images and country details.
Please note that we only copied the first player in the lineup in the below examples
Without selecting specific fields, you will receive a lot of information you don't need. The API request and partial API response would look like this:
Now, let's select specific fields on the base entities used.
The new API request and partial API response would look like this:
See how the size of the response is reduced? Next to selecting specific fields on the base entity or includes, it’s possible to filter your request. Check the next section for more info.
Since we're using the lineups.player
include, the first base entity is . We can select on all the fields of that entity. In our example, you need to select display_name
and image_path.
The second base entity is . Just like on the player entity, we can select on all the fields of the entity. In our example, you need to select name
and image_path.