Try 30 days of free premium.

Best way to get all episodes for a show id within the next 7 days

deleted wrote 7 years ago: 1

I am currently using the API to get a list of saved shows by ID using the following endpoint "shows/{id}?embed=nextepisode" this returns me the next episode and and airdate, I can then show the user a week view for each of the selected shows.

But looking at the schedule on the site I noticed that some shows have multiple episodes in a week which causes me a problem. I can't get all the episodes for the current week from that endpoint.

I am considering switching to the schedules endpoint but this would require 7 calls to get the next 7 days. Does anybody have any advice on the best way to get the data for any episodes for a particular show id within the next 7 days from the current day?

Thanks in advance for providing any advice.


gazza911 wrote 7 years ago: 1

wezley98 wrote:
I am currently using the API to get a list of saved shows by ID using the following endpoint "shows/{id}?embed=nextepisode" this returns me the next episode and and airdate, I can then show the user a week view for each of the selected shows.
But looking at the schedule on the site I noticed that some shows have multiple episodes in a week which causes me a problem. I can't get all the episodes for the current week from that endpoint.
I am considering switching to the schedules endpoint but this would require 7 calls to get the next 7 days. Does anybody have any advice on the best way to get the data for any episodes for a particular show id within the next 7 days from the current day?
Thanks in advance for providing any advice.

You've got a few options:


All episodes for show:

1. http://api.tvmaze.com/shows/1/episodes (include ?specials=1 if you want specials)

2. Skip all before today


Show info + all episodes:

1. http://api.tvmaze.com/shows/1?embed=episodes

2. Skip all before today


Logic based on scheduled days:

1. http://api.tvmaze.com/shows/1?embed=nextepisode

2. If schedule.days contains more than 1 value then continue to #3

3. http://api.tvmaze.com/shows/1/episodesbydate?date=2013-07-01 where the date is the next scheduled day


Logic based on next episode:

1. http://api.tvmaze.com/shows/1?embed=nextepisode

2. Do next episode date minus today, then you'll know how many days you need to check

I.e If next episode is 5 days later, you only need to check 2 more days

3. http://api.tvmaze.com/shows/1/episodesbydate?date=2013-07-01

Options #1 & #2 would always provide the information requested, but you wouldn't want to do it for a show that has hundreds of episodes.

Option #3 is simple, but isn't foolproof as it requires people have added it and that the network isn't airing it on a different day that week (which sometimes happens).

Option #4 is probably what you'll go with if you don't want to host anything.

By far the easiest option would be to get a dump of the database (or just the episodes as you require them - first option - if that's all you need), then host it somewhere and you can return stuff however you like.

deleted wrote 7 years ago: 1

Thanks both for the advice, much appreciated, I have gone for gazza911's num 2 suggestion for now as it wasn't a big change in my POJO objects, I will consider the other options as well as I improve my code.

Thanks again

Try 30 days of free premium.