zap2it TV Listingsのような TV リスト アプリの JSON データを返す API を想像してみてください。
これは基本的に、TV チャンネルのリストであり、各チャンネルについて現在およびそれ以降に放送されている番組です。現在、すべてのチャンネルを返す API がありますGET /channels
。ただし、そのデータにチャンネルごとに現在オンになっている番組を追加する必要があります。GET /channels/on_now
現在の API との差別化のために、新しい API を追加することを考えています。新しい API について明確にしたいのですが、チャンネルごとに個別の呼び出しを行いたくありません。show-on-now データはすべてのチャンネルに対して返される必要があります。これは良い REST API 設計ですか?
現在のGET /channels
JSON データ
[
"channel": {
"channelName": "KRON4",
},
"channel": {
"channelName": "KTOV5",
},
...
]
GET /channels/on_now
以下の新しい API に期待される JSON データ
[
{
"channel": {
"channelName": "KRON4",
},
"on_now": {
"startTime": "2012-06-04T11:30:00",
"endTime": "2012-06-04T12:00:00",
"shortDescription": "Latest local, statewide & national news events, along with sports & weather.",
"shortTitle": "4:30am Newscast"
}
},
{
"channel": {
"channelName": "KTOV5",
},
"on_now": {
"startTime": "2012-06-04T11:30:00",
"endTime": "2012-06-04T12:30:00",
"shortDescription": "Local morning news and weather report",
"shortTitle": "Morning Newscast"
}
},
...next channel...
]