Skip to main content

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

Project description

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.

Project details


Download files

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

Source Distribution

solscanpy_api-1.0.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

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

solscanpy_api-1.0.0-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file solscanpy_api-1.0.0.tar.gz.

File metadata

  • Download URL: solscanpy_api-1.0.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for solscanpy_api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5c5ff62eef37f4909a3bb6d91e7ece7a51107fa02df8ca559be2e8044e53cf04
MD5 3d32569babd16dc741fc423b153a1190
BLAKE2b-256 40593a36bcac15dcf7e41ce89cf69ecacfe603fffb0bf66aeaca16a6b4ca0915

See more details on using hashes here.

File details

Details for the file solscanpy_api-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: solscanpy_api-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for solscanpy_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2988daa5c61c193ac739c4e5afe4ceb53480cb962aab8bdbbe2151059412105a
MD5 ac72df2565d2ad9b494cbc8fa278efc7
BLAKE2b-256 665371dddb1f7492d3687ed7232906c2cdc1b2ad0427b1a8e4f08b912195d199

See more details on using hashes here.

Supported by

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