Skip to content

User Query Documentation

UserQuery

UserQuery(auth_token: Union[str, None])

This class represents a user Query 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/query/user.py
def __init__(self, auth_token: Union[str, None]) -> None:
    """
    The constructor for the UserQuery 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'

user

user(variables: Union[Dict[str, Union[str, int, bool]]]) -> dict

This method is used to send a user Query.

PARAMETER DESCRIPTION
variables

The variables for the Query.

TYPE: dict

RAISES DESCRIPTION
ValueError

If no variables are provided.

RETURNS DESCRIPTION
dict

The response from the user Query.

TYPE: dict

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

    Args:
        variables (dict): The variables for the Query.

    Raises:
        ValueError: If no variables are provided.

    Returns:
        dict: The response from the user Query.
    """
    if not variables:
        raise ValueError("At least one variable must be provided")

    query = f"""
        query ($id: Int, $name: String, $isModerator: Boolean, $search: String, $sort: [UserSort],
            $asHtml: Boolean, $animeStatLimit: Int, $mangaStatLimit: Int, $animeStatSort: [UserStatisticsSort],
            $mangaStatSort: [UserStatisticsSort]) {{ User (id: $id, name: $name, isModerator: $isModerator,
            search: $search, sort: $sort) {{ {USERSCHEMA}
            }}
        }}
    """

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