API: Difference between revisions

From EHWiki
Jump to navigationJump to search
Maximum Joe (talk | contribs)
mNo edit summary
Maximum Joe (talk | contribs)
No edit summary
Line 1: Line 1:
The E-Hentai JSON API can be used to request metadata information for E-Hentai Galleries. This can be done for links pointing directly to said galleries or to individual pages in galleries.
The E-Hentai API can be used to request metadata information for [[galleries]]. This can be done for links to galleries or to individual images.


==Basics==
==Basics==
Line 8: Line 8:
*Load limiting: 25 entries per request, 4-5 sequential requests usually okay before having to wait for ~5 seconds
*Load limiting: 25 entries per request, 4-5 sequential requests usually okay before having to wait for ~5 seconds


==API Commands & Responses==
==Commands & Responses==
===Gallery Metadata===
===Gallery Metadata===
This is the meat of the API - requesting gallery metadata for links. Users must provide a gallery ID along with its token in order to retrieve metadata for it. Both of these can be found in a gallery's URL, which has the following format:
Users must provide a gallery ID along with its token in order to retrieve metadata. Both of these can be found in a gallery's URL which has the following format:


<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">http://g.e-hentai.org/g/{gallery_id}/{gallery_token}/</pre>
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">http://g.e-hentai.org/g/{gallery_id}/{gallery_token}/</pre>


For example, for http://g.e-hentai.org/g/618395/0439fa3666/ users would make the following request:
Example: http://g.e-hentai.org/g/618395/0439fa3666/ would require the following request:


<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
Line 23: Line 23:
}</pre>
}</pre>


To get the metadata for multiple galleries, users simply add entries to the ''gidlist''. Users can have 25 entries at most in a single request. The previous request, when successful, would give the following JSON payload in response:
Which gives the following JSON payload in response:
 
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
  "gmetadata": [
  "gmetadata": [
Line 52: Line 51:
}</pre>
}</pre>


If an invalid token is specified for a gallery in the original request, its entry in the `gmetadata` array will consist of just the following, however:
If an invalid token is specified its entry in the ''gmetadata'' array will consist of the following:
 
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
   "gid":519325,
   "gid":519325,
   "error":"Key missing, or incorrect key provided."
   "error":"Key missing, or incorrect key provided."
}</pre>
}</pre>
More details about the metadata keys can be found below.


===Gallery Tokens===
===Gallery Tokens===
Individual page links can't be used directly for requesting gallery metadata - while they contain the gallery ID, they don't have the gallery token. The ''gtoken'' method can be used to find the gallery token by providing the page data from the link. Page links use the following format:
Individual page links cannot be used directly for requesting gallery metadata; they contain the gallery ID but not the token. The ''gtoken'' method can be used to find the gallery token by providing the page data from the link. Page links use the following format:
 
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">http://g.e-hentai.org/s/{page_token}/{gallery_id}-{pagenumber}</pre>
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">http://g.e-hentai.org/s/{page_token}/{gallery_id}-{pagenumber}</pre>


Example: For http://g.e-hentai.org/s/40bc07a79a/618395-11 users would make the following request:
Example: http://g.e-hentai.org/s/40bc07a79a/618395-11 would require the following request:
 
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
   "method": "gtoken",
   "method": "gtoken",
Line 75: Line 69:
}</pre>
}</pre>


As with the metadata requests, users can ask for max 25 tokens in a single request by having multiple entries in the ''pagelist''. A successful request would net the following JSON payload in response:
Which gives the following JSON payload in response:
 
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
  "tokenlist": [
  "tokenlist": [
Line 106: Line 99:
*'''filesize''' - Gallery size in bytes.
*'''filesize''' - Gallery size in bytes.
*'''tags''' - A list of the gallery tags as strings. [[Namespaces]] will not be included unless the "namespace" argument is set to "1".
*'''tags''' - A list of the gallery tags as strings. [[Namespaces]] will not be included unless the "namespace" argument is set to "1".
==Multiple Requests==
To get the metadata for multiple galleries users simply add entries to the ''gidlist''. Users can have up to 25 entries in a single request. The same applies for tokens but with entries in the ''pagelist''.


{{EHGNav}}
{{EHGNav}}


[[Category:E-Hentai Galleries]] [[Category:Site Features]]
[[Category:E-Hentai Galleries]]

Revision as of 22:11, 28 December 2015

The E-Hentai API can be used to request metadata information for galleries. This can be done for links to galleries or to individual images.

Basics

  • API URL: http://g.e-hentai.org/api.php
  • Request method: POST
  • Request type: JSON
  • Response type: JSON
  • Load limiting: 25 entries per request, 4-5 sequential requests usually okay before having to wait for ~5 seconds

Commands & Responses

Gallery Metadata

Users must provide a gallery ID along with its token in order to retrieve metadata. Both of these can be found in a gallery's URL which has the following format:

http://g.e-hentai.org/g/{gallery_id}/{gallery_token}/

Example: http://g.e-hentai.org/g/618395/0439fa3666/ would require the following request:

{
  "method": "gdata",
  "gidlist": [
      [618395,"0439fa3666"]
  ]
}

Which gives the following JSON payload in response:

{
 "gmetadata": [
   {
     "gid": 618395,
     "token": "0439fa3666",
     "archiver_key": "382385--9764970b04b79524bcbdc984e4c7857561397907",
     "title": "(TouKou 8) [Handful☆Happiness! (Fuyuki Nanahara)] TOUHOU GUNMANIA A2 (Touhou Project)",
     "title_jpn": "(東方紅楼夢8) [Handful☆Happiness! (七原冬雪)] TOUHOU GUNMANIA A2 (東方Project)",
     "category": "Non-H",
     "thumb": "http://gt1.ehgt.org/14/63/1463dfbc16847c9ebef92c46a90e21ca881b2a12-1729712-4271-6032-jpg_l.jpg",
     "uploader": "avexotsukaai",
     "posted": "1376143500",
     "filecount": "20",
     "filesize": 51210504,
     "expunged": false,
     "rating": "4.64",
     "torrentcount": "1",
     "tags": [
       "touhou project",
       "handful happiness",
       "fuyuki nanahara",
       "full color"
     ]
   }
 ]
}

If an invalid token is specified its entry in the gmetadata array will consist of the following:

{
  "gid":519325,
  "error":"Key missing, or incorrect key provided."
}

Gallery Tokens

Individual page links cannot be used directly for requesting gallery metadata; they contain the gallery ID but not the token. The gtoken method can be used to find the gallery token by providing the page data from the link. Page links use the following format:

http://g.e-hentai.org/s/{page_token}/{gallery_id}-{pagenumber}

Example: http://g.e-hentai.org/s/40bc07a79a/618395-11 would require the following request:

{
  "method": "gtoken",
  "pagelist": [
  [618395,"40bc07a79a",11]
 ]
}

Which gives the following JSON payload in response:

{
 "tokenlist": [
   {
    "gid":618395,
    "token":"0439fa3666"
   }
  ]
}

If any entries are invalid however, users will get an "error": "File not found" instead of the "token" for that entry.

Gallery Metadata Specification

  • token
  • archiver_key - Archiver keys change every hour, but an individual key is good for up to 24 hours.
  • category - Category names differ slightly from the ones used on the actual site. The following are how they are called in the API:
    • Doujinshi
    • Manga
    • Artist CG Sets
    • Game CG Sets
    • Western
    • Image Sets
    • Non-H
    • Cosplay
    • Asian Porn
    • Misc
    • Private
  • posted - UNIX time-stamp, UTC.
  • filesize - Gallery size in bytes.
  • tags - A list of the gallery tags as strings. Namespaces will not be included unless the "namespace" argument is set to "1".

Multiple Requests

To get the metadata for multiple galleries users simply add entries to the gidlist. Users can have up to 25 entries in a single request. The same applies for tokens but with entries in the pagelist.

E-Hentai Galleries Navigation
Finding Gallery SearchingBounty SystemFavoritesMaking Requests
Directory AnthologiesArtist Recommendations
Uploading Making GalleriesGallery CategoriesGallery ManagerGallery Descriptions
Downloading ArchivesHentai@HomeEHTracker
User Actions Tagging Fetish ListingKnow The DifferenceMechanics (Namespaces, Tag Creation)My TagsNew Tags
Other CommentingExpungingMod PowerRatingRenamingReporting
Rewards CreditsGallery PointsHath PerksToplists
Viewing Lo-FiMulti-Page Viewer
System APIBansFAQMy HomeTechnical Issues