Skip to main content

SDK functions for users to query Data Solutions databases.

Project description

Welcome to the Chainalysis Data Solutions Python SDK

A modern python wrapper for the Chainalysis Data Solutions API Suite.

Documentation

See the latest documentation on all available classes and methods here.

Installation

To install the SDK, run the following command in bash.

pip install chainalysis==1.1.0

Getting Started

Get an API Key at our website by registering an account and navigating to settings in the data solutions product section.

Begin using the SDK with the code below as a sample. The following code snippet details how to import and instantiate the Data Solutions Client to then be used to execute two kinds of queries: Analytical and Transactional.

Analytical queries are queries targeting the data you can view under the 'Explore Data' tab in Data Solutions. Transactional queries are queries targeting data you can find at docs.transpose.io.

    # Import the module
    from chainalysis import DataSolutionsClient

    # Instantiate with an API Key
    ds = DataSolutionsClient({API_KEY})

    # Create an AnalyticalSelect object
    analytical_select = ds.orm.AnalyticalSelect("cross_chain.clusters")

    # Construct a query
    query = analytical_select.with_columns(
        analytical_select.c.cluster_id, analytical_select.c.entity_name
    ).where(
        analytical_select.c.address == "0x00703a0ce5406501c44ca657497c0f785e83dde0"
    ).limit(10)

    # Execute the query
    query_results = query.execute()

    # Print the results of the query as a json blob
    print(query_results.json())

    # Return the results of the query as a Pandas Dataframe
    dataframe = query_results.df()

    # OR construct an analytical query manually
    query = """
        SELECT * FROM cross_chain.clusters
        WHERE address = '0x00703a0ce5406501c44ca657497c0f785e83dde0'
        LIMIT 10;
    """

    # Execute the query
    query_results = ds.sql.analytical_query(
        query=query,
        polling_interval_sec=5, # How often to check if data is available yet
    )

    # Print the results
    print(query_results.json())

Transaction Tracing with AutoTracing

The AutoTracing functionality enables you to trace cryptocurrency transactions through a graph-based approach, helping you understand the flow of funds across different addresses and chains.

Tracing Transactions

Set up your initial graph and execute a tracing step:

    # Initialize the graph with a starting address
    initial_graph = {
        "graph": {
            "nodes": [
                {
                    "address": "0x00703a0ce5406501c44ca657497c0f785e83dde0",
                    "chain_name": "ethereum",
                    "step": 0
                }
            ],
            "edges": []
        },
        "metadata": {
            "start_timestamp": "2024-02-22T08:16:11Z"
        }
    }

    # Execute one step of transaction tracing
    tracing_result = ds.autotracing.step(initial_graph)

    # Print the results
    print(tracing_result.json())

Future

More details on our SDK incoming!

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

chainalysis-1.1.0.tar.gz (557.3 kB view details)

Uploaded Source

Built Distribution

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

chainalysis-1.1.0-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file chainalysis-1.1.0.tar.gz.

File metadata

  • Download URL: chainalysis-1.1.0.tar.gz
  • Upload date:
  • Size: 557.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for chainalysis-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6f827f2d24b1e16f888db4ab990fb1654bbc6148eb13f92dfe16db7b3eb7073d
MD5 c79361e8efa93d88b34cd22cd088a500
BLAKE2b-256 bf3630a3314ddbfa2644861b57aee092f109c1d667f9c81bf7fd15ae49d72e32

See more details on using hashes here.

File details

Details for the file chainalysis-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: chainalysis-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for chainalysis-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cab99d123f6455c450bb87ffcd612fdacab47a46994d4de0c0a84da3216250d6
MD5 9fe5bde10109b3f08db57e52244db6d1
BLAKE2b-256 87a59a21b7129fc939b6dfd2404b29317db455b8a63bf80310ef165fde6c3040

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