API

From EHWiki
Jump to navigationJump to search

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: https://api.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:

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

Example: https://e-hentai.org/g/2231376/a7584a5932/ would require the following request:

{
  "method": "gdata",
  "gidlist": [
      [2231376,"a7584a5932"]
  ],
  "namespace": 1
}

Which gives the following JSON payload in response:

{
    "gmetadata": [
        {
            "gid": 2231376,
            "token": "a7584a5932",
            "archiver_key": "459562--7e27d313c50099214fde6bf74f8014d9309a2bb8",
            "title": "[Gentsuki] Kininaru Danshi ni 〇〇 suru Onnanoko. [Color Ban] [Ongoing]",
            "title_jpn": "[ゲンツキ] 気になる男子に〇〇する女の子。【カラー版】 [進行中]",
            "category": "Artist CG",
            "thumb": "https://ehgt.org/1f/f5/1ff5e361bbf7eaa235e9560dc5d12e624959e9e7-2722367-1882-3000-jpg_l.jpg",
            "uploader": "Pokom",
            "posted": "1653702810",
            "filecount": "329",
            "filesize": 419547090,
            "expunged": false,
            "rating": "4.78",
            "torrentcount": "2",
            "torrents": [
                {
                    "hash": "25198ccc3cd88393897aa5c630eb95d5ec4f695e",
                    "added": "1634958428",
                    "name": "(同人CG集) [ゲンツキ] 気になる男子に〇〇する女の子。【カラー版】 [進行中].zip",
                    "tsize": "12256",
                    "fsize": "310511523"
                },
                {
                    "hash": "62c960eb1c7a0e00dc2933a0c83dd43e2e6ebd48",
                    "added": "1639495362",
                    "name": "[Artist CG] Gentsuki - Kininaru Danshi ni 〇〇 suru Onnanoko (14 December 2021).zip",
                    "tsize": "27652",
                    "fsize": "357426803"
                }
            ],
            "tags": [
                "artist:gentsuki",
                "female:ponytail",
                "female:schoolgirl uniform",
                "female:stockings",
                "female:swimsuit",
                "female:tanlines",
                "female:twintails",
                "other:no penetration",
                "other:nudity only"
            ],
            "parent_gid": "2197090",
            "parent_key": "2f440c5f01",
            "first_gid": "2043548",
            "first_key": "bdb0cd9ec2"
        }
    ]
}

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

{
  "gid":2231376,
  "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:

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

Example: https://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
    • Game CG
    • Western
    • Image Set
    • 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 optional "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.

See also

  • Gallery Filecount - A userscript that uses API requests to add information to search results
E-Hentai Galleries Navigation
Finding Gallery SearchingBounty SystemFavoritesMaking Requests
Directory AnthologiesArtist Recommendations
Uploading Making GalleriesGallery CategoriesGallery ManagerGallery Descriptions
Downloading ArchivesHentai@HomeEHTrackerGallery Readers
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