Try 30 days of free premium.

Redirect loses embedded arguments

markg85 wrote 17 days ago: 1

Hi,

I'm trying to convert an API url like this:
https://api.tvmaze.com/singlesearch/shows?q=the%20100&embed=episodes

to this:
https://api.tvmaze.com/lookup/shows?imdb=tt2661044&embed=episodes

Because i know the IMDB and it seems more sane to follow that route.

But this proves to be more annoying then just a simple rewrite. The lookup call is redirecting me to:
http://api.tvmaze.com/shows/6

not to:
http://api.tvmaze.com/shows/6?embed=episodes

Which is something i'd consider to be a bug.

However, that being said. I also don't quite like the lookup/shows to be a redirect. Sure it works, but is this now 2 API calls or still one? And because it's not returning the "?embed=episodes" part i have to run yet another API call to get just that. Which makes using the API when you only know the IMDB ID quite a bit more troublesome then using the API with the "singlesearch" method. I really would have expected it to be totally the opposite (easy when using IMDB, more work when using search).

I hope this can be fixed. At the very least to keep the embed query arguments in a redirect.

Cheers,
Mark


gazza911 wrote 17 days ago: 1

This is by design.

The preferred way for us if for you to only ever lookup the external ID once and then save the TVMaze ID.

Then in any future requests that are made, you can directly use the ID.

If it were possible to do this just via the single request then it would not deter people from doing it in our preferred way.

markg85 wrote 17 days ago: 1

@gazza911 wrote:
This is by design.

The preferred way for us if for you to only ever lookup the external ID once and then save the TVMaze ID.

Then in any future requests that are made, you can directly use the ID.

If it were possible to do this just via the single request then it would not deter people from doing it in our preferred way.

I could see why you would want that.

That does make it more complicated from an API user perspective if i want to support IMDB search and normal name search. Not awfully more difficult, but it adds another lookup table where i would have needed none if the API would support it directly as reported... ;) oh well...


david wrote 17 days ago: 2

Indeed, the reason for this architecture is to improve the API's cacheability on our end, and the accuracy on your end.

But to save one request, just instruct your HTTP client/library to not automatically follow redirects (e.g. CURLOPT_FOLLOWLOCATION).

Request "https://api.tvmaze.com/lookup/shows?imdb=tt266104", parse the Location response header ("http://api.tvmaze.com/shows/6") and manually append the "?embed=episodes" to it.

Try 30 days of free premium.