Skip to main content

This package allows you to interact with and fetch data from the StoryGraph website.

Project description

Storygraph API

A python package to interact with and fetch data from the StoryGraph website.

Features

  • Book Details: Fetch detailed information about a book using its unique ID.
  • Search: Perform a book search on StoryGraph and retrieve the results.
  • Fetch User lists:
    • currently reading
    • planning to read
    • books read

Installation

pip install storygraph-api

Getting Started

The API is divided into two components, Books Client and User Client.

Book Details:

# Books Client
# Fetch details of a book using its ID

from storygraph_api import Book
id = "fbdd6b7c-f512-47f2-aa94-d8bf0d5f5175"
book = Book()
result = book.book_info(id)
print(result)

Result:

{
    "title": "Hagakure: The Book of the Samurai",
    "authors": [
        "Yamamoto Tsunetomo",
        "William Scott Wilson"
    ],
    "pages": "179",
    "first_pub": "1716",
    "tags": [
        "nonfiction",
        "history",
        "philosophy",
        "informative",
        "reflective",
        "slow-paced"
    ],
    "average_rating": "3.57",
    "description": "<div><em>Hagakure<\\/em> (\\\"In the Shadow of Leaves\\\") is a manual for the samurai classes consisting of a series of short anecdotes and reflections that give both insight and instruction-in the philosophy and code of behavior that foster the true spirit of Bushido-the Way of the Warrior. It is not a book of philosophy as most would understand the word: it is a collection of thoughts and sayings recorded over a period of seven years, and as such covers a wide variety of subjects, often in no particular sequence. <br><br>The work represents an attitude far removed from our modern pragmatism and materialism, and possesses an intuitive rather than rational appeal in its assertion that Bushido is a Way of Dying, and that only a samurai retainer prepared and willing to die at any moment can be totally true to his lord. While <em>Hagakure<\\/em> was for many years a secret text known only to the warrior vassals of the Hizen fief to which the author belonged, it later came to be recognized as a classic exposition of samurai thought and came to influence many subsequent generations, including Yukio Mishima. <br><br>This translation offers 300 selections that constitute the core texts of the 1,300 present in the original. <br><em>Hagakure<\\/em> was featured prominently in the film <em>Ghost Dog<\\/em>, by Jim Jarmusch.<\\/div>"
}

User List:

# User Client
# works only for public profiles
# fetch user's currently reading list

from storygraph_api import User
from dotenv import load_dotenv
load_dotenv()
cookie = os.getenv('COOKIE') # retrieve cookie from .env file
uname = 'sampleuname' #some username 
user = User()
result = user.currently_reading(uname,cookie=cookie)
print(result)

Result:

[
  {
      "title": "The Murder After the Night Before",
      "book_id": "38cb5b56-23f1-48fd-b4b3-a80e07a19775"
  },
  {
      "title": "The Graces",
      "book_id": "653b54b3-a79d-4c2e-ae40-eae281a91315"
  }
]

Further Information

  • Refer to books_client.py and users_client.py files to know more functionalities.
  • All the user related tasks require the remember_user_token cookie. It can be found in the Application section of your browser’s developer tools for the StoryGraph website.

Contributing

Contributions are welcome! Fork the repository, make your changes, and submit a pull request.

For bugs or feature requests, please open an issue on GitHub.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

storygraph_api-0.2.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

storygraph_api-0.2.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file storygraph_api-0.2.0.tar.gz.

File metadata

  • Download URL: storygraph_api-0.2.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for storygraph_api-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f4a631094f1494bfc6ee250aa3a17fd3c56ba24c8d92b44f4ba249c6dbf88f6e
MD5 ee0fc3f3b12c4ac3ffe7756de69c5c39
BLAKE2b-256 ea4ce8ce521bf2c4accfb1249323c83ae435efc4ab152d46580ecf0fb08e5d43

See more details on using hashes here.

File details

Details for the file storygraph_api-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: storygraph_api-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for storygraph_api-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 068b4a99be868b199bb047357064c8c06a1aeffc03f0be082dc16a56fdad7814
MD5 9ed45cf294f7bf59f09fc27c0d6d76a3
BLAKE2b-256 274c991e8b7bc88d260c41dde098b7bc680a4eb8f3d31b17c1ba30221fc2f68b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page