nokey.books_and_literature package

Submodules

nokey.books_and_literature.gutendex module

class nokey.books_and_literature.gutendex.Gutendex(use_caching=False, cache_name='gutendex_cache', backend='sqlite', expire_after=3600)[source]

Bases: object

A class for interacting with the Gutendex API.

base_url

The base URL for the API.

about

A short description of the API.

get_authors_before_specified_year(author_year_end, sort='popular', language='en')[source]

Returns authors and metadata for their books existing before the specified year.

Parameters:
  • author_year_end (int) – The year before which the author was alive. Can be negative (for BC era) or positive.

  • sort (str) – Parameter by which to sort the data. Default is popular, and other supported values are ascending and descending.

  • language (str) – The language in which the books are written. Defaults to en (English). Can take multiple comma separated (non-spaced) values.

Returns:

Returns a dictionary containing metadata for books by authors who were alive before the specified year.

Return type:

dict

get_authors_within_date_range(author_year_start, author_year_end, sort='popular', language='en')[source]

Returns authors and metadata for their books within the specified year range.

Parameters:
  • author_year_start (int) – The year marking the beginning of range. Can be negative (for BC era) or positive.

  • author_year_end (int) – The year marking the end of range. Can be negative (for BC era) or positive.

  • sort (str) – Parameter by which to sort the data. Default is popular, and other supported values are ascending and descending.

  • language (str) – The language in which the books are written. Defaults to en (English). Can take multiple comma separated (non-spaced) values.

Returns:

A dictionary containing a list of books whose authors lived within the specified range.

Return type:

dict

get_book_by_id(book_id)[source]

Returns metadata for a single book matching the given id.

Parameters:

book_id (int) – A unique integer identifying the book in the API database.

Returns:

A dictionary containing metadata for a single book.

Return type:

dict

get_books(page=1, sort='popular', language='en')[source]

Returns a list of book metadata contained in the API.

Parameters:
  • page (int) – The page of the book list. Defaults to the first page.

  • sort (str) – Sort option for the book metadata. The default is popular, based on number of downloads. Other supported values are ascending and descending.

  • language (str) – The language in which the books are written. Defaults to en (English). Can take multiple comma separated (non-spaced) values.

Returns:

A dictionary containing the book metadata for the given page.

Return type:

dict

get_books_by_ids(book_ids)[source]

Returns metadata for a single book matching the given id.

Parameters:

book_ids (str) – Comma separated (no spaces) integers, written as a string, identifying the book in the API database.

Returns:

A dictionary containing metadata for a single book.

Return type:

dict

get_docs_url()[source]

Returns the URL for the Gutendex API documentation.

Parameters:

None

Returns:

The URL for the API docs.

Return type:

string

search_books_by_author_and_title(author, title, sort='popular', language='en')[source]

Returns metadata on books from the given author and/or a give title.

Parameters:
  • author (str) – Any part of the author’s name.

  • title (str) – Any part of the book’s title.

  • sort (str) – Parameter by which to sort the data. Default is popular, and other supported values are ascending and descending.

  • language (str) – The language in which the books are written. Defaults to en (English). Can take multiple comma separated (non-spaced) values.

Returns:

A dictionary containing metadata on books from the given author and/or given title.

Return type:

dict

search_books_by_topic(topic, sort='popular', language='en')[source]

Returns metadata on books matching the given topic.

Parameters:
  • topic (str) – The topic to search.

  • sort (str) – Parameter by which to sort the data. Default is popular, and other supported values are ascending and descending.

  • language (str) – The language in which the books are written. Defaults to en (English). Can take multiple comma separated (non-spaced) values.

Returns:

A dictionary containing metadata for books matching the given topic.

Return type:

dict

nokey.books_and_literature.stephen_king module

class nokey.books_and_literature.stephen_king.StephenKingAPI(use_caching=False, cache_name='stephen_king_cache', backend='sqlite', expire_after=3600)[source]

Bases: object

A class to interact with the Stephen King API.

base_url

The base URL of the API.

about

A short description of the API.

get_docs_url()[source]

Returns the URL for the Stephen King API documentation.

Parameters:

None

Returns:

The URL for the API docs.

Return type:

string

get_stephen_king_book_by_id(book_id)[source]

Returns the Stephen King book matching the id, with related metadata.

Parameters:

book_id (int) – A unique number identifying the Stephen King book.

Returns:

A dictionary containing book metadata.

Return type:

dict

get_stephen_king_books()[source]

Returns all of the Stephen King books and related metadata.

Parameters:

None

Returns:

A dictionary containing book metadata.

Return type:

dict

get_stephen_king_short_stories()[source]

Returns all of the Stephen King short stories and related metadata.

Parameters:

None

Returns:

A dictionary containing short story metadata.

Return type:

dict

get_stephen_king_short_story_by_id(story_id)[source]

Returns the Stephen King short story matching the id, with related metadata.

Parameters:

story_id (int) – A unique number identifying the Stephen King short story.

Returns:

A dictionary containing short story metadata.

Return type:

dict

get_stephen_king_villain_by_id(villain_id)[source]

Returns the Stephen King villain matching the id, with related metadata.

Parameters:

villain_id (int) – A unique number identifying the Stephen King villain.

Returns:

A dictionary containing villain metadata.

Return type:

dict

get_stephen_king_villains()[source]

Returns all of the Stephen King villains and related metadata.

Parameters:

None

Returns:

A dictionary containing villain metadata.

Return type:

dict

Module contents