API: Difference between revisions

From EHWiki
Jump to navigationJump to search
No edit summary
Nasu (talk | contribs)
 
(9 intermediate revisions by 4 users not shown)
Line 2: Line 2:


==Basics==
==Basics==
*API URL: http://g.e-hentai.org/api.php
*API URL: https://api.e-hentai.org/api.php
*Request method: POST
*Request method: POST
*Request type: JSON
*Request type: JSON
Line 12: Line 12:
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:
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|}}}"><nowiki>https://e-hentai.org/g/{gallery_id}/{gallery_token}/</nowiki></pre>


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


<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}">{
   "method": "gdata",
   "method": "gdata",
   "gidlist": [
   "gidlist": [
       [618395,"0439fa3666"]
       [2231376,"a7584a5932"]
   ],
   ],
   "namespace": 1
   "namespace": 1
Line 25: Line 25:


Which gives 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|}}}"><nowiki>{
"gmetadata": [
    "gmetadata": [
  {
        {
    "gid": 618395,
            "gid": 2231376,
    "token": "0439fa3666",
            "token": "a7584a5932",
    "archiver_key": "403565--d887c6dfe8aae79ed0071551aa1bafeb4a5ee361",
            "title": "[Gentsuki] Kininaru Danshi ni 〇〇 suru Onnanoko. [Color Ban] [Ongoing]",
    "title": "(Kouroumu 8) [Handful☆Happiness! (Fuyuki Nanahara)] TOUHOU GUNMANIA A2 (Touhou Project)",
            "title_jpn": "[ゲンツキ] 気になる男子に〇〇する女の子。【カラー版】 [進行中]",
    "title_jpn": "(紅楼夢8) [Handful☆Happiness! (七原冬雪)] TOUHOU GUNMANIA A2 (東方Project)",
            "category": "Artist CG",
    "category": "Non-H",
            "thumb": "https://ehgt.org/1f/f5/1ff5e361bbf7eaa235e9560dc5d12e624959e9e7-2722367-1882-3000-jpg_250.jpg",
    "thumb": "<nowiki>http://gt1.ehgt.org/14/63/1463dfbc16847c9ebef92c46a90e21ca881b2a12-1729712-4271-6032-jpg_l.jpg</nowiki>",
            "uploader": "Pokom",
    "uploader": "avexotsukaai",
            "posted": "1653702810",
    "posted": "1376143500",
            "filecount": "329",
    "filecount": "20",
            "filesize": 419547090,
    "filesize": 51210504,
            "expunged": false,
    "expunged": false,
            "rating": "4.68",
    "rating": "4.43",
            "torrentcount": "5",
    "torrentcount": "0",
            "torrents": [
    "tags": [
                {
      "parody:touhou project",
                    "hash": "25198ccc3cd88393897aa5c630eb95d5ec4f695e",
      "group:handful happiness",
                    "added": "1634958428",
      "artist:nanahara fuyuki",
                    "name": "(同人CG集) [ゲンツキ] 気になる男子に〇〇する女の子。【カラー版】 [進行中].zip",
      "full color",
                    "tsize": "12256",
      "artbook"
                    "fsize": "310511523"
    ]
                },
  }
                {
]
                    "hash": "8e335d09dcb6600bb5bc18eb636bc84cb89703a2",
}</pre>
                    "added": "1645552636",
                    "name": "[Gentsuki] Kininaru Danshi ni 〇〇 suru Onnanoko. [Color Ban] [Ongoing][02_22_2022].zip",
                    "tsize": "75407",
                    "fsize": "376744038"
                },
                {
                    "hash": "3d80a6c39da7e48469ad4701a3237da00b28b4e8",
                    "added": "1650280574",
                    "name": "[ゲンツキ] 気になる男子に〇〇する女の子。【カラー版】 [18-04-2022].zip",
                    "tsize": "30655",
                    "fsize": "394442926"
                },
                {
                    "hash": "221771fd520fa9e44bb3714465c2728db68fae28",
                    "added": "1678643294",
                    "name": "[2023-01-31][Gentsuki] Kininaru Danshi ni 〇〇 suru Onnanoko. [Color Ban] [Ongoing].zip",
                    "tsize": "21836",
                    "fsize": "562301224"
                },
                {
                    "hash": "1f7e0a0ac7055bf36e7d8c29c9290ba47a2498ea",
                    "added": "1716203184",
                    "name": "[ゲンツキ] 気になる男子に〇〇する女の子。【カラー版】 [進行中].zip",
                    "tsize": "31021",
                    "fsize": "802265287"
                }
            ],
            "tags": [
                "parody:original",
                "artist:gentsuki",
                "female:pantyhose",
                "female:ponytail",
                "female:schoolgirl uniform",
                "female:stockings",
                "female:swimsuit",
                "female:tanlines",
                "female:tomboy",
                "female:twintails",
                "other:mosaic censorship",
                "other:no penetration",
                "other:nudity only"
            ],
            "parent_gid": "2197090",
            "parent_key": "2f440c5f01",
            "current_gid": "2924387",
            "current_key": "aa28f4a72a",
            "first_gid": "2043548",
            "first_key": "bdb0cd9ec2"
        }
    ]
}</nowiki></pre>


If an invalid token is specified its entry in the ''gmetadata'' array will consist of the following:
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":2231376,
   "error":"Key missing, or incorrect key provided."
   "error":"Key missing, or incorrect key provided."
}</pre>
}</pre>
Line 61: Line 111:
===Gallery Tokens===
===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:
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|}}}"><nowiki>http://g.e-hentai.org/s/{page_token}/{gallery_id}-{pagenumber}</nowiki></pre>
<pre<includeonly></includeonly> style="overflow: auto;{{{style|}}}"><nowiki>https://e-hentai.org/s/{page_token}/{gallery_id}-{pagenumber}</nowiki></pre>


Example: http://g.e-hentai.org/s/40bc07a79a/618395-11 would require the following request:
Example: https://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 85: Line 135:
==Gallery Metadata Specification==
==Gallery Metadata Specification==
*'''token'''
*'''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:
*''category'' - [[Category]] names differ slightly from the ones used on the actual site. The following are how they are called in the API:
** Doujinshi
** Doujinshi
** Manga
** Manga
** Artist CG Sets
** Artist CG
** Game CG Sets
** Game CG
** Western
** Western
** Image Sets
** Image Set
** Non-H
** Non-H
** Cosplay
** Cosplay
Line 106: Line 155:


==See also==
==See also==
*[http://forums.e-hentai.org/index.php?showtopic=157779 Gallery Filecount] - A userscript that uses API requests to add information to search results
*[https://forums.e-hentai.org/index.php?showtopic=157779 Gallery Filecount] - A userscript that uses API requests to add information to search results


{{EHGNav}}
{{EHGNav}}


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

Latest revision as of 12:25, 1 February 2026

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",
            "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_250.jpg",
            "uploader": "Pokom",
            "posted": "1653702810",
            "filecount": "329",
            "filesize": 419547090,
            "expunged": false,
            "rating": "4.68",
            "torrentcount": "5",
            "torrents": [
                {
                    "hash": "25198ccc3cd88393897aa5c630eb95d5ec4f695e",
                    "added": "1634958428",
                    "name": "(同人CG集) [ゲンツキ] 気になる男子に〇〇する女の子。【カラー版】 [進行中].zip",
                    "tsize": "12256",
                    "fsize": "310511523"
                },
                {
                    "hash": "8e335d09dcb6600bb5bc18eb636bc84cb89703a2",
                    "added": "1645552636",
                    "name": "[Gentsuki] Kininaru Danshi ni 〇〇 suru Onnanoko. [Color Ban] [Ongoing][02_22_2022].zip",
                    "tsize": "75407",
                    "fsize": "376744038"
                },
                {
                    "hash": "3d80a6c39da7e48469ad4701a3237da00b28b4e8",
                    "added": "1650280574",
                    "name": "[ゲンツキ] 気になる男子に〇〇する女の子。【カラー版】 [18-04-2022].zip",
                    "tsize": "30655",
                    "fsize": "394442926"
                },
                {
                    "hash": "221771fd520fa9e44bb3714465c2728db68fae28",
                    "added": "1678643294",
                    "name": "[2023-01-31][Gentsuki] Kininaru Danshi ni 〇〇 suru Onnanoko. [Color Ban] [Ongoing].zip",
                    "tsize": "21836",
                    "fsize": "562301224"
                },
                {
                    "hash": "1f7e0a0ac7055bf36e7d8c29c9290ba47a2498ea",
                    "added": "1716203184",
                    "name": "[ゲンツキ] 気になる男子に〇〇する女の子。【カラー版】 [進行中].zip",
                    "tsize": "31021",
                    "fsize": "802265287"
                }
            ],
            "tags": [
                "parody:original",
                "artist:gentsuki",
                "female:pantyhose",
                "female:ponytail",
                "female:schoolgirl uniform",
                "female:stockings",
                "female:swimsuit",
                "female:tanlines",
                "female:tomboy",
                "female:twintails",
                "other:mosaic censorship",
                "other:no penetration",
                "other:nudity only"
            ],
            "parent_gid": "2197090",
            "parent_key": "2f440c5f01",
            "current_gid": "2924387",
            "current_key": "aa28f4a72a",
            "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
  • 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@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