Skip to main content

defi-analytics-py

DeFi analytics library for NEAR Protocol.

PyPI version Python

Installation

pip install defi-analytics-py

Requires Python 3.9+

Quick Start

from defi_analytics_py import DefiAnalyticsPyClient

client = DefiAnalyticsPyClient()

Methods

Chain

Method Description
get_latest_block() Fetch the latest block
get_gas_price() Get current gas price

Accounts

Method Description
get_account(account_id) Get account details
get_near_balance(account_id) Get NEAR token balance

Fungible Tokens

Method Description
get_ft_metadata(contract_id) Get token metadata
get_ft_balance(contract_id, account_id) Get token balance for account

Pools (Ref Finance)

Method Description
get_pools() List all liquidity pools
get_pool(pool_id) Get a specific pool
get_pool_tvl(pool_id) Get TVL for a pool
top_pools_by_tvl(n) Return top n pools by TVL

Example

from defi_analytics_py import DefiAnalyticsPyClient

client = DefiAnalyticsPyClient()

Chain info

block = client.get_latest_block() gas = client.get_gas_price()

Account

balance = client.get_near_balance("alice.near")

Pools

top = client.top_pools_by_tvl(10) tvl = client.get_pool_tvl(79)

Custom RPC

client = DefiAnalyticsPyClient(rpc_url="https://rpc.mainnet.near.org", timeout=60)

License

MIT

Metadata

Release files for defi-analytics-py 1.0.4

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

Source distribution (sdist)

Source distribution for defi-analytics-py 1.0.4
File Size Uploaded
defi_analytics_py-1.0.4.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for defi-analytics-py 1.0.4
File Interpreter ABI Platform
defi_analytics_py-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / defi_analytics_py-1.0.4.tar.gz

Download URL defi_analytics_py-1.0.4.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d0905787d93affa9ef6bea25b6b0866d0ac5938246618b93c2ef8a9fe59650a9
BLAKE2b-256 checksum
How to use checksums
08adaa4be131ce4f08cb5268b4a6a6a1e61297770007d88718a8c76371fe286a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / defi_analytics_py-1.0.4-py3-none-any.whl

Download URL defi_analytics_py-1.0.4-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd3a58c6356575edcdf840beb628701f04d01d991b1190d6f1dee0ccd735f75f
BLAKE2b-256 checksum
How to use checksums
d9444e2ae7deb9f27aaf7af315f3d698ecc988923ef9b1746bf1b8f92db2cbad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

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