Api Platform conference
Register now
API Platform Conference
September 19-20, 2024 | Lille & online

The international conference on the API Platform Framework

API Platform Conference 2024: meet the best PHP, JavaScript and API experts

Learn more about the event, register for the conference, and get ready for two days of inspiration, ideas, and knowledge-sharing with our incredible lineup of renowned specialists and advocates.

Register now


To make the admin faster and greener, you can make some changes to your API.

Retrieve All Relations in One Request

By default, if your relations are not embedded and if you decide to display some fields belonging to relations in your resource list, the admin will fetch the relations one by one.

In this case, it can be improved by doing only one request for all the related resources instead.

To do so, you need to make sure the search filter is enabled for the identifier of the related resource.

For instance, if you have a book resource having a relation to author resources and you display the author names on your book list, you can make sure the authors are retrieved in one go by writing:

// api/src/Entity/Author.php
namespace App\Entity;

use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiResource;
use Doctrine\ORM\Mapping as ORM;

class Author
    #[ORM\Id, ORM\Column, ORM\GeneratedValue]
    #[ApiFilter(SearchFilter::class, strategy: "exact")]
    public ?int $id = null;

    public string $name;

You can also help us improve the documentation of this page.

Made with love by

Les-Tilleuls.coop can help you design and develop your APIs and web projects, and train your teams in API Platform, Symfony, Next.js, Kubernetes and a wide range of other technologies.

Learn more

Copyright © 2023 Kévin Dunglas

Sponsored by Les-Tilleuls.coop