pyanimeinfo.bangumitv.client

BangumiTVClient

class pyanimeinfo.bangumitv.client.BangumiTVClient(session: Session | None = None, website: str | None = None, user_agent: str | None = 'deepghs/pyanimeinfo')[source]

A client class for accessing the Bangumi.tv API.

The BangumiTVClient class provides methods for interacting with the Bangumi.tv API, allowing you to search for subjects, retrieve information about subjects, characters, persons, and more.

Parameters:
  • session (Optional[requests.Session]) – An optional requests.Session object to be used for making HTTP requests.

  • website (Optional[str]) – The base URL of the Bangumi.tv API. Default is https://api.bgm.tv.

  • user_agent (Optional[str]) – User agent to use in client. Defaults to deepghs/pyanimeinfo. Keep the original UA when assigned to empty value.

__init__(session: Session | None = None, website: str | None = None, user_agent: str | None = 'deepghs/pyanimeinfo')[source]
get_character(character_id: int)[source]

Get information about a specific character.

This method retrieves information about a character on Bangumi.tv based on the provided character ID.

Parameters:

character_id (int) – The ID of the character.

Returns:

Information about the character as a JSON response.

Return type:

dict

Get information about persons related to a specific character.

This method retrieves information about persons related to a character on Bangumi.tv based on the provided character ID.

Parameters:

character_id (int) – The ID of the character.

Returns:

Information about persons related to the character as a JSON response.

Return type:

dict

Get information about subjects related to a specific character.

This method retrieves information about subjects related to a character on Bangumi.tv based on the provided character ID.

Parameters:

character_id (int) – The ID of the character.

Returns:

Information about subjects related to the character as a JSON response.

Return type:

dict

get_person(person_id: int)[source]

Get information about a specific person.

This method retrieves information about a person on Bangumi.tv based on the provided person ID.

Parameters:

person_id (int) – The ID of the person.

Returns:

Information about the person as a JSON response.

Return type:

dict

Get information about characters related to a specific person.

This method retrieves information about characters related to a person on Bangumi.tv based on the provided person ID.

Parameters:

person_id (int) – The ID of the person.

Returns:

Information about characters related to the person as a JSON response.

Return type:

dict

Get information about subjects related to a specific person.

This method retrieves information about subjects related to a person on Bangumi.tv based on the provided person ID.

Parameters:

person_id (int) – The ID of the person.

Returns:

Information about subjects related to the person as a JSON response.

Return type:

dict

get_subject(subject_id: int)[source]

Get information about a specific subject.

This method retrieves information about a subject on Bangumi.tv based on the provided subject ID.

Parameters:

subject_id (int) – The ID of the subject.

Returns:

Information about the subject as a JSON response.

Return type:

dict

get_subject_characters(subject_id: int)[source]

Get information about characters related to a specific subject.

This method retrieves information about characters related to a subject on Bangumi.tv based on the provided subject ID.

Parameters:

subject_id (int) – The ID of the subject.

Returns:

Information about characters related to the subject as a JSON response.

Return type:

dict

get_subject_persons(subject_id: int)[source]

Get information about persons related to a specific subject.

This method retrieves information about persons related to a subject on Bangumi.tv based on the provided subject ID.

Parameters:

subject_id (int) – The ID of the subject.

Returns:

Information about persons related to the subject as a JSON response.

Return type:

dict

get_subject_relations(subject_id: int)[source]

Get information about related subjects to a specific subject.

This method retrieves information about subjects related to a subject on Bangumi.tv based on the provided subject ID.

Parameters:

subject_id (int) – The ID of the subject.

Returns:

Information about related subjects as a JSON response.

Return type:

dict

search_subjects(keywords: str, type_: SubjectType | None = None, response_group: Literal['small', 'medium', 'large'] | None = None, offset: int | None = None, limit: int = 25)[source]

Search for subjects on Bangumi.tv.

This method allows you to search for subjects on Bangumi.tv based on provided keywords and optional search parameters.

Parameters:
  • keywords (str) – The search keywords.

  • type (Optional[SubjectType]) – The type of the subject (e.g., anime, manga).

  • response_group (Optional[Literal['small', 'medium', 'large']]) – The response group size (small, medium, large).

  • offset (Optional[int]) – The offset for the search results (pagination).

  • limit (int) – The maximum number of results to return.

Returns:

The search results as a JSON response.

Return type:

dict