Skip to main content

alchemy_sdk_py (Beta)

An SDK to use the Alchemy API


Alchemy logo


Getting Started

Requirements

  • Python 3.7 or higher
    • You'll know you've done it right if you can run python3 --version in your terminal and see something like Python 3.10.6

Installation

pip3 install alchemy_sdk_py

Quickstart

Get an API Key

After installing, you'll need to sign up for an API key and set it as an ALCHEMY_API_KEY environment variable. You can place them in a .env file if you like just please don't push the .env file to GitHub.

.env

ALCHEMY_API_KEY="asdfasfsfasf

If you're unfamiliar with environment variables, you can use the API to set the key directly using the SDK - please don't do this in production code.

from alchemy_sdk_py import Alchemy

alchemy = Alchemy(api_key="asdfasfsfasf", network="eth_mainnet")

If you have your environment variable set, and you want to use eth mainnet, you can just do this:

from alchemy_sdk_py import Alchemy
alchemy = Alchemy()

You can also set the network ID using the chainId, or hex, and even update it later.

# For Goerli ETH
alchemy = Alchemy(network=5)
# For Polygon ("0x89" is hex for 137)
alchemy.set_network("0x89")

Useage

from alchemy_sdk_py import Alchemy

alchemy = Alchemy()

current_block_number = alchemy.get_current_block_number()
print(current_block_number)
# prints the current block number

With web3.py

from alchemy_sdk_py import Alchemy
from web3 import Web3

alchemy = Alchemy()

w3 = Web3(Web3.HTTPProvider(alchemy.base_url))

Get all ERC20, value, and NFT transfers for an address

The following code will get you every transfer in and out of a single wallet address.

from alchemy_sdk_py import Alchemy
alchemy = Alchemy()

address = "YOUR_ADDRESS_HERE"

transfers, page_key = alchemy_with_key.get_asset_transfers(from_address=address)
print(transfers)
# prints every transfer in or out that's ever happened on the address

Get contract metadata for any NFT

ENS = "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85"
contract_metadata = alchemy_with_key.get_contract_metadata(ENS)

print(contract_metadata["contractMetadata"]["openSea"]["collectionName"])
# prints "ENS: Ethereum Name Service"

What's here and what's not

What this currently has

Just about everything in the Alchemy SDK section of the docs.

Currently not implemented

  • batchRequests
  • web sockets
  • Notify API & filters ie eth_newFilter
  • Async support
  • ENS Support for addresses
  • Double check the NFT, Transact, and Token docs for function
  • Trace API
  • Debug API

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alchemy_sdk_py-0.2.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alchemy_sdk_py-0.2.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file alchemy_sdk_py-0.2.0.tar.gz.

File metadata

  • Download URL: alchemy_sdk_py-0.2.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for alchemy_sdk_py-0.2.0.tar.gz
Algorithm Hash digest
SHA256 175c96f50fdf459605ae15d7148a21da0d0474dfdfdbaedfa04763955c5b5e9e
MD5 bc7abe2e5eeef3480351d40a70f9a5c0
BLAKE2b-256 d0f1073ab1f32b4477af58b6c3b5a62976efc898ec8ddf39b5c7047d91c3b31f

See more details on using hashes here.

File details

Details for the file alchemy_sdk_py-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: alchemy_sdk_py-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for alchemy_sdk_py-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89f5bdc83756af459cba48cc12e45f0a5dad9baec61fbf34e191c21a4052081a
MD5 75faa6154f20d916116ffd833d9e650f
BLAKE2b-256 382b185a3d8e9147bd8cb46756db53098c59042e99c25cede4e9b007b1623bd0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.1

2 files

0.0.4

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page