Class "Network"

Implements the StackExchange APIs client for all SE network.

Source code

Note #1: the **kwargs argument in methods is necessary for request parameters, like pagesize, order, etc.

Note #2: The Item class in the get_* methods return type hint is a standard dict class with the ability to get values not only using the d['key'] construction, but also d.key.

Methods:

get

Signature:

get(self, query: str, **kwargs: Any) -> dict

Returns raw result of calling query to API.


get_access_tokens

Signature:

get_access_tokens(self, access_tokens: Iterable[str], **kwargs: Any) -> list[Item]

Returns the properties for a set of access tokens.


invalidate_access_tokens

Signature:

invalidate_access_tokens(self, access_tokens: Iterable[str],
                         **kwargs: Any) -> list[Item]

Immediately expires the access tokens passed. This method is meant to allow an application to discard any active access tokens it no longer needs. Returns list of access tokens.


get_errors

Signature:

get_errors(self, **kwargs: Any) -> list[Item]

Returns the various error codes that can be produced by the API.


simulate_error

Signature:

simulate_error(self, code: int, **kwargs: Any) -> NoReturn

This method allows you to generate an error.


create_filter

Signature:

create_filter(self, **kwargs: Any) -> Item

Creates a new filter given a list of includes, excludes, a base filter, and whether this filter should be "unsafe".

It is not expected that many applications will call this method at runtime, filters should be pre-calculated and "baked in" in the common cases.


get_filters

Signature:

get_filters(self, filters: Iterable[str], **kwargs: Any) -> list[Item]

Returns the fields included by the given filters, and the "safeness" of those filters.

It is not expected that this method will be consumed by many applications at runtime, it is provided to aid in debugging.


get_sites

Signature:

get_sites(self, **kwargs: Any) -> list[Item]

Returns all sites in the network.


get_users_associated_accounts

Signature:

get_users_associated_accounts(self, ids: Iterable[int], **kwargs: Any) -> list[Item]

Returns all of a user's associated accounts, given their account ids in ids.


get_users_accounts_merges

Signature:

get_users_accounts_merges(self, ids: Iterable[int], **kwargs: Any) -> list[Item]

Returns a record of merges that have occurred involving the passed account ids.

Last updated