Pintac
Pintac

Reputation: 1585

Rest Api Url design fro intersecting resource

I have a team,user and teamUser table.

I have the following url's

team - all teams
team/{id} - one team
user - all user
user/{id} - one user
team/{id}/user - all users for specific team
user/{id}/team - all teams for specific user

Now in the teamUser table i have a userid and a teamid and some extra information the teamid and userid is the primary key(composite key).

What will the url look like if i want to get a specific teamuser. I had a few ideas.

/user/{id}team/{id}
/teamUser/{teamId}/{userId}
/teamUser?userid={}&teamid={}

and many more.

Any opinions about this.

thanks

Upvotes: 1

Views: 44

Answers (1)

cassiomolin
cassiomolin

Reputation: 130887

Provided both user and team can exist without depending on each other but they are linked, you could support both /users/{userId}/teams/{teamId} and /teams/{teamId}/users/{userId}.

Upvotes: 1

Related Questions