Try 30 days of free premium.

Get several shows in a single request?

DorWeidman wrote 7 years ago: 1

Hello,

I have the following situation in my application:

-> The user searches for shows using the show search API

-> If the user wants, he saves a certain show on the app's storage. (Either by ID or name, not yet decided)

-> Once the user re opens the app, his saved list of shows should appear.

There is my problem. The user keeps unique identifiers of shows, but not the relevant data I need to present.

Therefore I need to request specific shows, e.g 4 specific shows with the IDs 1,2,3,4.

The current solution I have is using the single search API because I need to embed previous and next episode, but it requires (in this example) 4 requests to the server, which takes a respectable amount of time.

My question: Is there a way to select several shows with embedding? (even without embedding). e.g /shows/1,2,3,4?embed=previousepisode

Thanks!


gazza911 wrote 7 years ago: 1

As far as I'm aware it isn't possible to do that.

You would be better off using your own database so that you can select multiple IDs. This could be done either of 2 ways:

1. Get the entire show database once (~24MB last time I did this) so that you already have all of the information

2. Only save shows that have been previously been searched

In both cases you should use a cache expirery / last_updated value (timestamp) where if it's past that time (plus a determined interval) it will update the information using TVMaze's API.

When you're ready to list them just call: SELECT columns FROM tvmaze_shows WHERE showID IN (1, 2, 3, 4)

And then iterate through each row.

P.S It would be better for the app storage to be by ID as there can be multiple shows with the same name

Try 30 days of free premium.