Archived Boards > WinBatch Script Exchange
JSON API for querying TVDB and IMDB
JTaylor:
I think you are going to have to be a bit more specific...not sure for which thing you are wanting documentation :)
Jim
Bardmaster:
any and all commands related to JSON queries, retrievals, etc. I don't have any documentation in my WIL manual and can't find online how to develop a JSON API script. I see the syntax at THETVDB.com, like this:
SeriesSearchData {
aliases (Array[string], optional),
banner (string, optional),
firstAired (string, optional),
id (integer, optional),
network (string, optional),
overview (string, optional),
seriesName (string, optional),
status (string, optional)
}
which apparently responds with
{
"aliases": [
"string"
],
"banner": "string",
"firstAired": "string",
"id": 0,
"network": "string",
"overview": "string",
"seriesName": "string",
"status": "string"
}there,
but how do I initiate the SeriesSearchData using WIL? What is the syntax for logging in and authenticating my API key? I see an example script for this, and in the absence of add'l docs will model from it and trial/error, but would prefer to understand how to invoke these commands in a WIL script.
JTaylor:
This is like asking how to get to Rome...maybe not really "ALL" roads go there but still many, many ways and much of the answer to many of them really isn't a WinBatch question. On the WinBatch front you could take a look at the WinInet Extender, it has examples for submitting requests and retrieving the reply. Look at iHostOpen. On the MS front I am guessing things like WinHttpRequest.5.1 or XMLHTTP would probably get you part way down the road along with a few others. As far as reading/parsing the results Tony suggested using the WIL String Functions to write your own parser. Those start with "Str" in the WIL Help File. If you search the TechDatabase and/or msdn.com for some of the things I mentioned you will probably find some more examples. Sounds like you found some JSON stuff already.
As far as telling you how the API works that would make me feel like I was doing your school Homework for you ;)
Jim
Bardmaster:
OK I've used wininit to perform ftp and basic html interface functions. I'll refresh the memory on that front and see how it works for these TVDB calls. Thanks!
td:
Simple JSON based "APIs" are often little more than a PUT (sometimes GET) with the appropriate content types in the request headers and the data as a well formatted JSON string. The "winhttp.winhttprequest.5.1" COM Automation object is simple and well suited for this. The WinInet extender works well too. The key is figuring out what the many over-hyped APIs are expecting and understanding a little bit about the HTTP and JSON standards. Many or at least some "API" providers include REST versions of their "APIs" in their documentation. In these cases, the figuring is like living in the summertime - easy.
Should add that occasionally things can get more complicated but as long as it is "HTTP" or "HTTPS" and JSON based, it should be mostly doable with the tools mentioned in this topic.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version