get.php - File Download API

Q

What is the file download API, get.php?

✍: FYIcenter.com

A

get.php is another simple API provided by Library Genesis to download files.

Technical information on file download API:

URL: {site_url}/get.php?md5={md5}
site_url: https://libgen.lc or other mirror sites
md5: The MD5 hash value of the file to download. 
Response format: Binary data of the file.  

Note that the MD5 hash value is provided in the response of "files" object returned by json.php?object=f API.

MD5 hash values are also provided in the response of "editions" objet returned by json.php?object=e API.

Here are some examples on how to download files with get.php.

1. Get the "files" object of a given f_id. Take the MD5 hash value in the response.

fyicenter$ curl 'https://libgen.lc/json.php?object=f&ids=32216214' | python -m json.tool

{
  "32216214": {
    "editions": {
        "30969895": {
            "e_id": "32149882",
            "time_added": "2021-07-17 14:40:07",
            "time_last_modified": "2021-07-17 14:40:07"
        }
    },
    "extension": "pdf",
    "fiction_id": "0",
    "fiction_rus_id": "0",
    "file_create_date": "2000-01-01 05:00:00",
    "filesize": "216912",
    "generic": "",
    "libgen_id": "0",
    "libgen_topic": "a",
    "locator": "",
    "magz_id": "0",
    "md5": "2da991ccc4cd63d23196a5c4a63a71ef",
    "ocr": "",
    "orientation": "",
    "pages": "0",
    "paginated": "",
    "releaser": "",
    "scan_content": "",
    "scan_quality": "",
    "scan_size": "",
    "scan_type": "",
    "scanned": "",
    "scimag_archive_path": "10.2307\\25311768.pdf",
    "scimag_id": "25757210",
    "standarts_id": "0",
    "time_added": "2014-08-09 08:56:11",
    "time_last_modified": "2021-07-20 20:31:12",
    "vector": "",
    "visible": ""
  }
}

2. Download a file by its MD5 hash value. The API address is moved.

fyicenter$ curl 'https://libgen.lc/get.php?md5=2da991ccc4cd63d23196a5c4a63a71ef'

<html>
<head><title>307 Temporary Redirect</title></head>
<body>
<center><h1>307 Temporary Redirect</h1></center>
<hr><center>nginx</center>
</body>
</html>

3. Show the new API address in the response header.

fyicenter$ curl -D header.txt 'https://libgen.lc/get.php?md5=2da991ccc4cd63d23196a5c4a63a71ef'

fyicenter$ more header.txt 

HTTP/1.1 307 Temporary Redirect
Server: nginx
Date: Sun, 19 Jun 2022 01:03:02 GMT
Content-Type: text/html
Content-Length: 164
Connection: keep-alive
Location: https://cdn1.booksdl.org/get.php?md5=2da991ccc4cd63d23196a5c4a63a71ef

4. Download the file with the new API address. It returns no data and no error.

fyicenter$ curl 'https://cdn1.booksdl.org/get.php?md5=2da991ccc4cd63d23196a5c4a63a71ef' \
  > files-32216214.pdf 

fyicenter$ ls -l *.pdf 
-rw-r--r--  1 fyicenter  staff      0 Jun 18 21:33 files-32216214.pdf

5. Try the "-L" option to follow redirects. It returns the "Library Genesis" home page.

fyicenter$ curl -L 'https://libgen.lc/get.php?md5=2da991ccc4cd63d23196a5c4a63a71ef'

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Library Genesis</title>
...

6. Add the API key=Z380HIK7II2DL1W1. Now the file is downloaded.

fyicenter$ curl -L 'https://libgen.lc/get.php?md5=2da991ccc4cd63d23196a5c4a63a71ef&key=Z380HIK7II2DL1W1' \
  > files-32216214.pdf

fyicenter$ ls -l *.pdf 
-rw-r--r--@ 1 fyicenter  staff  216912 Jun 18 22:07 files-32216214.pdf

7. Open files-32216214.pdf. You see the article "One Hour's Sleep: Three Dreams".

 

"File not found in lg repositories" Error

Wrong Output with object=f, topic=s and Date Range

Library Genesis API

⇑⇑ LibGen (Library Genesis) - Frequently Asked Questions

2022-10-07, 880🔥, 0💬