helium_py.api.client.Client¶
- class helium_py.api.client.Client(host: Optional[str] = None, port: Optional[int] = None, user_agent: Optional[str] = None, base_path: Optional[str] = None)[source]¶
Bases:
object
Base client class for Helium Blockchain API.
Sub-classes define specific paths or parameters for different aspects of the API.
- __init__(host: Optional[str] = None, port: Optional[int] = None, user_agent: Optional[str] = None, base_path: Optional[str] = None) None [source]¶
Initialize the API client.
- Args:
host (str): Hostname for Helium blockchain API. port (int): Port for Helium blockchain API. user_agent (str): Custom user agent.
Methods
__init__
([host, port, user_agent, base_path])Initialize the API client.
Return the User-Agent.
fetch_all
([path, params, page_limit])Yield objects returned by API.
get
([path, params])Get the response for a request.
get_next_page
(current_page, path, params)Return the next page from cache or from the API.
post
(path, json)Get the response for a POST request.
Attributes
base_path
host
port
user_agent
- fetch_all(path: str = '', params: Optional[dict] = None, page_limit: Union[float, int] = inf) Generator[dict, None, None] [source]¶
Yield objects returned by API.
- Args:
path: Path for initial query. params: Query params page_limit: The max number of pages to return. float is permitted since math.inf
is the provided representation of inifinity in the language, and the default is that there is no limit.
- get(path: Optional[str] = None, params: Optional[dict] = None)[source]¶
Get the response for a request.
- Args:
path: URL path for query. params: Query parameters.
- Returns:
The payload from the request, unpacked if possible
- Raises:
requests.exceptions.HTTPError: If the response code is not a successful one.