Hupotronic / ExLinks

A userscript to make E-Hentai & ExHentai links on 4chan & Foolz archive more useful. Includes ExSauce.
http://hupotronic.github.com/ExLinks/
46 stars 6 forks source link

API documentation #21

Closed 07151129 closed 11 years ago

07151129 commented 11 years ago

I am interested in creating a small application to work with E(x)-H. For the sake of optimisation, I want to implement E-H API support rather than simply parse pages. However, I found no docs for it whatsoever. Could you be so nice to share your knowledge of the API?

Hupotronic commented 11 years ago

What exactly do you want to do? The API has pretty much two functions: Getting the gallery token from a page ID & token and getting gallery info from gallery ID & token. It's also limited to 25 entries in one request. Rate limiting also applies, so you need to make sure that you're using as little requests as possible. ExLinks works by first parsing the page for any page links, then requesting gallery keys, and then doing as many gallery info requests as necessary. Usually you don't need more than 3-5 requests for the initial load of a large thread with lots of links.

Anyway, I don't the API specification at hand right now, but you could inspect the API-related code in ExLinks here.

07151129 commented 11 years ago

I want to perform a search by certain tags on exh. What is the best way to do this? I tried sending corresponding headers and parsing the result with tools like curl, but I get the main page all the time instead.

Hupotronic commented 11 years ago

The API doesn't support searching, so parsing the page somehow is pretty much your only option there. The reverse image searching in ExLinks also relies on parsing the page, as seen here.

07151129 commented 11 years ago

I am not really familiar with JS/JSON. Could you provide a few examples of the possible queries to API? Thank you, the line 1081 explained why my query was ignored.

07151129 commented 11 years ago

Alright, got it myself. An example of gidlist API request if anyone needs it:

{
  "method":"gdata",
  "gidlist":[[532599,"5e434d31e5"]]
}

Returns:

{"gmetadata":[{"gid":532599,"token":"5e434d31e5","archiver_key":"377801--16e9c256a61ee2fcbd064b16f4b67fbedb3c4875","title":"[Mameyuzu] (Umineko) PUNISH ME PLEASE [ENG] (updated)","title_jpn":"","category":"Non-H","thumb":"http:\/\/gt2.ehgt.org\/64\/92\/6492504c7d39191c7fbdefb9a70d50ea3bc16453-782367-1398-2018-jpg_l.jpg","uploader":"phfatbeatrice","posted":"1349926630","filecount":"23","filesize":9630807,"expunged":false,"rating":"4.25","torrentcount":"0","tags":["english","translated","umineko no naku koro ni","mameyuzu","mameyuzu umineko","lambdadelta"]}]}

Too bad it doesn't support tag search, would've saved a lot of time.