Skip to main content

solscan-api

A lightweight, typed Python client for the Solscan Pro API v2.0.

Every endpoint returns a validated pydantic model on success, or an ErrorModel on failure — so you get autocompletion and type safety throughout.

Features

  • Full coverage of the Solscan Pro API v2.0: account, block, token, transaction, nft, market, and program endpoints
  • Typed pydantic response models with snake_case API fields mapped to camelCase attributes
  • Consistent error handling: network and HTTP failures return an ErrorModel instead of raising
  • Optional query parameters expressed as small, discoverable helper classes

Requirements

Installation

pip install solscan-api

Quickstart

from solscan import Solscan

client = Solscan(apiKey="YOUR_API_KEY")

# Fetch token metadata
meta = client.token.meta(address="So11111111111111111111111111111111111111112")
print(meta.symbol, meta.price)

# Every method returns either a model or an ErrorModel
from solscan.error import ErrorModel

result = client.block.last()
if isinstance(result, ErrorModel):
    print(f"Request failed [{result.code}]: {result.message}")
else:
    for block in result:
        print(block.blockHeight, block.transactionsCount)

Usage

The client is organized into one property per API namespace. Each returns a sub-client exposing that namespace's methods.

Account

client.account.balanceChange(address)
client.account.detail(address)
client.account.defiActivities(address)
client.account.fundedBy(addresses)
client.account.leaderboards(AccountOptionals.leaderboards())
client.account.portfolio(address)
client.account.transactions(address)

# Nested sub-clients (pass the client instance)
client.account.meta(client).metadata(address)
client.account.meta(client).multi(address)
client.account.staking(client).stake(address)
client.account.staking(client).rewards(address)

Block

client.block.detail(block)
client.block.last(limit)
client.block.transactions(block)

Token

client.token.transfer(address)
client.token.defiActivities(address)
client.token.markets(token)
client.token.meta(address)
client.token.metaMulti(address)
client.token.price(address)
client.token.priceMulti(address)
client.token.holders(address)
client.token.list()
client.token.top()
client.token.trending()

Transaction

client.transaction.last()
client.transaction.detail(tx)
client.transaction.actions(tx)
client.transaction.fees()

NFT

client.nft.news()
client.nft.activities()
client.nft.collectionLists()
client.nft.collectionItems(collection)

Market

client.market.list()
client.market.info(address)
client.market.volume(address)
client.market.positions(address)

Program

client.program.list()
client.program.popularPlatforms()
client.program.analytics(address, range)

Optional parameters

Endpoints that accept query parameters take an optional helper object. Each module exposes its parameters under its own Optionals class. For example:

from solscan.types import PageSize, TxFilter
from solscan.token.optionals import Optionals as TokenOptionals
from solscan.transaction.optionals import Optionals as TxOptionals

# Token transfers, paginated
client.token.transfer(
    address="So11111111111111111111111111111111111111112",
    optional=TokenOptionals.transfer(page=1, pageSize=PageSize.size20),
)

# Latest transactions, filtered
client.transaction.last(
    optional=TxOptionals.last(filter=TxFilter.exceptVote),
)

Shared enums (page sizes, sort order, limits, time ranges, etc.) live in solscan.types.

Error handling

Requests never raise on transport or HTTP errors. Instead, every method returns an ErrorModel with a code and message:

from solscan.error import ErrorModel

result = client.token.price(address="invalid")
if isinstance(result, ErrorModel):
    print(result.code, result.message)

Running Tests

python -m pytest tests/ -v

The test suite mocks all network calls, so it runs fully offline and requires no API key.

License

Released under the MIT License.

Metadata

Release files for solscanpy-api 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for solscanpy-api 1.0.0
File Size Uploaded Provenance Actions
solscanpy_api-1.0.0.tar.gz 22.5 kB Without provenance Details for solscanpy_api-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for solscanpy-api 1.0.0
File Interpreter ABI Platform Actions
solscanpy_api-1.0.0-py3-none-any.whl Python 3 none any Details for solscanpy_api-1.0.0-py3-none-any.whl

Total release size: 49.1 kB

Release files / solscanpy_api-1.0.0.tar.gz

Download URL solscanpy_api-1.0.0.tar.gz
Size 22.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5c5ff62eef37f4909a3bb6d91e7ece7a51107fa02df8ca559be2e8044e53cf04
BLAKE2b-256 checksum
How to use checksums
40593a36bcac15dcf7e41ce89cf69ecacfe603fffb0bf66aeaca16a6b4ca0915
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / solscanpy_api-1.0.0-py3-none-any.whl

Download URL solscanpy_api-1.0.0-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2988daa5c61c193ac739c4e5afe4ceb53480cb962aab8bdbbe2151059412105a
BLAKE2b-256 checksum
How to use checksums
665371dddb1f7492d3687ed7232906c2cdc1b2ad0427b1a8e4f08b912195d199
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for solscanpy-api 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page