Try 30 days of free premium.

End point in JSON to how much shows there are in the DB

oleg.rez wrote 8 years ago: 1

Hi,

i'm making an app that uses your website and i download the data about the shows using

a for loop, the problem is that shows are constantly added (which is good) and

i need to change the end number in the "for" loop.

It would help a lot if there would be an end point that will say how much shows there are currently.

thanks in advance.


david wrote 8 years ago: 1

Hey there!

There's a proposed workflow for usecases like this in the API documentation: "You can implement a daily/weekly sync simply by starting starting at the page number where you last left off, and be sure you won't skip over any entries. For example, if the last show in your local cache has an ID of 1800, you would start the re-sync at page number floor(1800/250) = 7. After this, simply increment the page number by 1 until you receive a HTTP 404 response code, which indicates that you've reached the end of the list."

Would this perhaps work for you instead?

oleg.rez wrote 8 years ago: 1

unfortunatly no, i tried to do that by using "while" loop, but it didn't work because at the end of this loop there is no time for download request to be sent, so basicly nothing happens.

If there would be an end point with an amount of shows i could put this as end number in my "for" loop snd download all shows by id


david wrote 8 years ago: 1

What exactly do you mean with "but it didn't work because at the end of this loop there is no time for download request to be sent, so basicly nothing happens"?

You should just be able to do a pseudo-code of 'if (response.code == 404) { break; }'

oleg.rez wrote 8 years ago: 1

when doing "while" loop in objective-c in which you send a request to recieve information (as a response you recieve data from the web site), the while loop leaves no time for the request to be sent and repeats over and over, so at the end no request is sent and naturally there is no response.

Can you make somthing like:

Http://tvmaze.com/allshowscount

That will give back the number of shows that are currently on the website


david wrote 8 years ago: 1

Ah, Objective C's HTTP client is asynchronous?

I can't easily make some Objective C example code, but try something like this then: http://jsfiddle.net/89sdqbkv/

Try 30 days of free premium.