Skip to content

Alchemy

Root client constructor and API group accessors.

new

Create an Alchemy client.

Parameters:

Name Type Description Default
api_key str | None

Alchemy API key. If omitted, falls back to ALCHEMY_API_KEY.

None
validate bool

Validate responses by default.

True
data_url str | None

Fully-qualified Portfolio API base URL override.

None
prices_url str | None

Fully-qualified Prices API base URL override.

None
http HttpClient | None

Shared HTTP client override.

None
Source code in pkg/src/alchemy/__init__.py
@classmethod
def new(
  cls, *, api_key: str | None = None, validate: bool = True,
  data_url: str | None = None, prices_url: str | None = None,
  http: _HttpClient | None = None,
):
  """Create an Alchemy client.

  Args:
    api_key: Alchemy API key. If omitted, falls back to `ALCHEMY_API_KEY`.
    validate: Validate responses by default.
    data_url: Fully-qualified Portfolio API base URL override.
    prices_url: Fully-qualified Prices API base URL override.
    http: Shared HTTP client override.
  """
  return cls(
    api_key=_env_api_key(api_key),
    validate=validate,
    data_url=data_url,
    prices_url=prices_url,
    http=http or _HttpClient(),
  )

portfolio

Access the Portfolio API group.

prices

Access the Prices API group.

nft

Access the NFT API group for a network.

Parameters:

Name Type Description Default
network Network

Supported Alchemy network.

required
base_url str | None

Fully-qualified NFT API base URL override.

None
Source code in pkg/src/alchemy/__init__.py
def nft(self, network: Network, *, base_url: str | None = None) -> Nft:
  """Access the NFT API group for a network.

  Args:
    network: Supported Alchemy network.
    base_url: Fully-qualified NFT API base URL override.
  """
  url = base_url or _authed_url(NFT_URLS[network], self.api_key)
  return Nft(base_url=url, http=self.http, validate=self.validate)

token

Access the Token JSON-RPC API group for a network.

Parameters:

Name Type Description Default
network Network

Supported Alchemy network.

required
base_url str | None

Fully-qualified JSON-RPC API base URL override.

None
Source code in pkg/src/alchemy/__init__.py
def token(self, network: Network, *, base_url: str | None = None) -> Token:
  """Access the Token JSON-RPC API group for a network.

  Args:
    network: Supported Alchemy network.
    base_url: Fully-qualified JSON-RPC API base URL override.
  """
  url = base_url or _authed_url(RPC_URLS[network], self.api_key)
  return Token(base_url=url, http=self.http, validate=self.validate)

transfers

Access the Transfers JSON-RPC API group for a network.

Parameters:

Name Type Description Default
network Network

Supported Alchemy network.

required
base_url str | None

Fully-qualified JSON-RPC API base URL override.

None
Source code in pkg/src/alchemy/__init__.py
def transfers(self, network: Network, *, base_url: str | None = None) -> Transfers:
  """Access the Transfers JSON-RPC API group for a network.

  Args:
    network: Supported Alchemy network.
    base_url: Fully-qualified JSON-RPC API base URL override.
  """
  url = base_url or _authed_url(RPC_URLS[network], self.api_key)
  return Transfers(base_url=url, http=self.http, validate=self.validate)

utility

Access the Utility JSON-RPC API group for a network.

Parameters:

Name Type Description Default
network Network

Supported Alchemy network.

required
base_url str | None

Fully-qualified JSON-RPC API base URL override.

None
Source code in pkg/src/alchemy/__init__.py
def utility(self, network: Network, *, base_url: str | None = None) -> Utility:
  """Access the Utility JSON-RPC API group for a network.

  Args:
    network: Supported Alchemy network.
    base_url: Fully-qualified JSON-RPC API base URL override.
  """
  url = base_url or _authed_url(RPC_URLS[network], self.api_key)
  return Utility(base_url=url, http=self.http, validate=self.validate)

simulation

Access the Simulation JSON-RPC API group for a network.

Parameters:

Name Type Description Default
network Network

Supported Alchemy network.

required
base_url str | None

Fully-qualified JSON-RPC API base URL override.

None
Source code in pkg/src/alchemy/__init__.py
def simulation(self, network: Network, *, base_url: str | None = None) -> Simulation:
  """Access the Simulation JSON-RPC API group for a network.

  Args:
    network: Supported Alchemy network.
    base_url: Fully-qualified JSON-RPC API base URL override.
  """
  url = base_url or _authed_url(RPC_URLS[network], self.api_key)
  return Simulation(base_url=url, http=self.http, validate=self.validate)