mercredi 21 août 2019

How do I get REST API many to many to one to many information?

I have a question about how to design a certain part of my REST API. Imagine the following situation:

A racing driver can be part of multiple racing teams (i.e. one for Sundays, one for Saturdays, one for rally cross etc.). Every racing team has multiple cars, cars which can only belong to one team. Now, I want my REST API to return a list of all racing cars of every team the driver is part of.

At the moment, I have the following:

Drivers

All drivers: /drivers

Certain driver: /drivers/12345

Teams a driver is part of: /drivers/12345/teams

Teams

All teams: /teams

Certain team: /teams/12345

Cars of a certain team: /teams/12345/cars

Cars

All cars: /cars

Certain car /cars/12345

So now, my question is: what is a proper way to define an URL for getting all cars from all the teams a certain driver is part of?

Aucun commentaire:

Enregistrer un commentaire