0

Option 1:

Return as many links as there are resources.

{
        "teamName": "Steelers"
        "links": {
            "players": [
                { "href": "http://api.com/players/1" },
                { "href": "http://api.com/players/2" },
                { "href": "http://api.com/players/3" }
            ]
    }

It can see it being useful in the case we've already been caching some of the player resources on the client side.

Option 2:

Return a single link leading to the list of resources.

{
    "teamName": "Steelers"
    "links": {
        "players": [
            { "href": "http://api.com/teams/1/players" }
        ]
}

It looks a lot cleaner, and we can fetch the players in one request.

mb21
  • 34,845
  • 8
  • 116
  • 142
user3408654
  • 301
  • 1
  • 13

1 Answers1

1

I think there is no definitive answer to that question because it depends on your use case. In first option I would add more information about player for each link for the player.

Denis
  • 83
  • 2
  • 14