Skip to content

Anilist Custom Request Documentation

CustomRequest

CustomRequest(auth_token: Union[str, None])

This class represents a custom request in the AniLink API.

ATTRIBUTE DESCRIPTION
base_url

The base URL for the AniLink API.

TYPE: str

auth_token

The authentication token.

TYPE: str

PARAMETER DESCRIPTION
auth_token

The authentication token.

TYPE: str

Source code in AniLinkPy/apis/anilist/custom.py
def __init__(self, auth_token: Union[str, None]) -> None:
    """
    The constructor for the CustomRequest class.

    Args:
        auth_token (str): The authentication token.
    """
    self.base_url = "https://graphql.anilist.co"
    self.auth_token = auth_token

auth_token instance-attribute

auth_token = auth_token

base_url instance-attribute

base_url = 'https://graphql.anilist.co'

custom

custom(query: str, variables: Optional[Union[Dict[str, Union[str, int, bool]]]] = None) -> dict

This method is used to send a custom Query.

PARAMETER DESCRIPTION
query

The Query string.

TYPE: str

variables

The variables for the Query. Defaults to None.

TYPE: dict DEFAULT: None

RETURNS DESCRIPTION
dict

The response from the custom Query.

TYPE: dict

Source code in AniLinkPy/apis/anilist/custom.py
def custom(
    self,
    query: str,
    variables: Optional[Union[Dict[str, Union[str, int, bool]]]] = None,
) -> dict:
    """
    This method is used to send a custom Query.

    Args:
        query (str): The Query string.
        variables (dict, optional): The variables for the Query. Defaults to None.

    Returns:
        dict: The response from the custom Query.
    """
    if variables is None:
        variables = {}

    data = {"query": query, "variables": variables}
    return send_request(self.base_url, "POST", data, self.auth_token)