Python API
Everything the command line does is available here. Indexer blocks; AsyncIndexer
has the same methods as coroutines.
Blocking version of AsyncIndexer, with the same methods and arguments.
account(address)
See AsyncIndexer.account.
account_transactions(address, *, limit=DEFAULT_TRANSACTION_LIMIT)
See AsyncIndexer.account_transactions.
asset(asset_id)
See AsyncIndexer.asset.
close()
Release the network session and the database.
contract(contract_id)
See AsyncIndexer.contract.
describe(record)
See AsyncIndexer.describe.
export(export_format, output=None, *, account=None, days=None)
See AsyncIndexer.export.
follow(address, *, interval=None, on_sync=None, rounds=None)
See AsyncIndexer.follow. Ctrl-C stops it.
metrics(days=30, *, account=None)
See AsyncIndexer.metrics.
stored_transactions(*, account=None, days=None)
See AsyncIndexer.stored_transactions.
sync(address, *, on_progress=None)
See AsyncIndexer.sync.
transaction(transaction_id)
See AsyncIndexer.transaction.
Reads one network of one chain and keeps what it reads in a local database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chain
|
str
|
Chain name, such as |
required |
network
|
str | None
|
Network name; when None, the chain's network in |
None
|
settings
|
Settings | None
|
Configuration; read from |
None
|
database
|
Database | None
|
SQLite file or PostgreSQL URL; overrides |
None
|
migrate
|
bool
|
Bring the database to the current schema first. |
True
|
Raises:
| Type | Description |
|---|---|
UnsupportedChain
|
The chain is unknown or not available in this version. |
InvalidInput
|
The network is not one the chain has. |
account(address)
async
Fetch an account's current state and store it.
account_transactions(address, *, limit=DEFAULT_TRANSACTION_LIMIT)
async
Fetch an account's most recent transactions from the node, newest first.
aclose()
async
Release the network session and the database.
asset(asset_id)
async
Fetch a token or asset, such as an Algorand ASA, and store it.
contract(contract_id)
async
Fetch an application or contract, such as an Algorand app, and store it.
describe(record)
Return label and value pairs for display, in the chain's own terms.
export(export_format, output=None, *, account=None, days=None)
Export stored transactions as csv, json or parquet.
Returns:
| Type | Description |
|---|---|
str | None
|
The exported text when |
follow(address, *, interval=None, on_sync=None, rounds=None)
async
Sync address again and again, storing new transactions as they arrive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address
|
str
|
The account to follow. |
required |
interval
|
float | None
|
Seconds between rounds; the chain's own default when None. |
None
|
on_sync
|
SyncCallback | None
|
Called with each round's result. |
None
|
rounds
|
int | None
|
Stop after this many rounds; follow until cancelled when None. |
None
|
metrics(days=30, *, account=None)
Summarise stored transactions over the last days days.
stored_transactions(*, account=None, days=None)
Return transactions from the local database, newest first.
sync(address, *, on_progress=None)
async
Store what is new for an account since the last sync. Safe to re-run.
transaction(transaction_id)
async
Fetch one transaction by its ID, such as a Bitcoin txid. Nothing is stored.
Raises:
| Type | Description |
|---|---|
UnsupportedChain
|
The chain's adapter cannot look up a single transaction. |
Every chain at once
Blocking version of AsyncCrossChain, with the same methods and arguments.
close()
Stop the event loop thread.
export(export_format, output=None, *, days=None)
See AsyncCrossChain.export.
metrics(days=30)
See AsyncCrossChain.metrics.
networks()
See AsyncCrossChain.networks.
sync(network=None)
See AsyncCrossChain.sync.
Works on every chain and network at once, through one database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
Settings | None
|
Configuration; read from |
None
|
database
|
Database | None
|
SQLite file or PostgreSQL URL; overrides |
None
|
migrate
|
bool
|
Bring the database to the current schema first; see |
True
|
export(export_format, output=None, *, days=None)
async
Export every stored chain's transactions as one table, shared fields as columns.
Returns:
| Type | Description |
|---|---|
str | None
|
The exported text when |
metrics(days=30)
async
Summarise every stored chain and network over the last days days.
networks()
Return every chain and network with stored transactions.
sync(network=None)
async
Sync every account listed under [accounts] in config.toml, chains in parallel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network
|
str | None
|
Sync only the accounts listed for this network. When None, every network except mainnet, which is synced only when named. |
None
|
Records
Errors
Exceptions raised by the library. Catch IndexerError to handle them all.
ConfigError
Bases: IndexerError
A setting is missing or has an invalid value.
IndexerError
Bases: Exception
Base class for every failure a caller is expected to handle.
InvalidAddress
Bases: InvalidInput
An address or account ID is not valid for the chain.
InvalidInput
Bases: IndexerError, ValueError
A value supplied by the caller failed validation.
MalformedResponse
Bases: IndexerError
The node answered with data that does not match its documented format.
NetworkError
Bases: IndexerError
The node could not be reached, or kept failing after every retry.
NotFound
Bases: IndexerError
The node has no record of the requested item.
RateLimited
Bases: NetworkError
The node kept refusing requests with HTTP 429 after every retry.
UnsupportedChain
Bases: IndexerError
The chain is unknown, or not available in this version.
WrongNetwork
Bases: IndexerError
The configured endpoint serves a different network than the one requested.