Skip to main content

Scrape Solana Blockchain Data

This python library scrapes blockchain from https://bitquery.io/ from their GraphQL endpoints.

This requires you to supply your own Bitquery API token.

Copyright (c) 2022 Friktion Labs

Functionalities

  • Queries Bitquery for blockchain data
  • Batches queries to get around compute limits

Setup

  1. pip3 install solana-data-scraper
  2. Create an account at https://bitquery.io/
  3. Retrieve API Key
  4. In command line, export BITQUERY_API_KEY=XXXXXXX

Example

import os
from solquery.Query import Query

# Get API key associated with user's environment
API_KEY = os.environ.get("BITQUERY_API_KEY")
print(f"Bitquery API Key used: {API_KEY}")

# Create query object with API key
query = Query(API_KEY)

# Query to get random transfers
QUERY = """
query MyQuery {
  solana(network: solana) {
    instructions: instructions(
      success: {is: true}
      options: {limit: 10}
      time: {after: "2022-04-29T00:00:00"}
      programId: {is: "So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo"}
    ) {
      program {
        id
        name
        parsedName
      }
      action {
        name
        type
      }
      data {
        base58
      }
      external
      transaction {
        signature
        success
        transactionIndex
        feePayer
      }
      accountsCount
    }
  }
}
"""
result = query.run(QUERY, to_df=True)
print(f"Results: {result}")

# Query to get random transfers
QUERY = """
    query MyQuery {
      solana(network: solana) {
        transfers(
          time: {between: ["%s", "%s"]}
          options: {limit: 25000}
          success: {is: true}
          receiverAddress: {is: "DdZR6zRFiUt4S5mg7AV1uKB2z1f1WzcNYCaTEEWPAuby"}
        ) {
          amount
          transaction {
            signer
            signature
          }
          block {
            timestamp {
              iso8601
            }
          }
          currency {
            address
            decimals
          }
        }
      }
    }
"""

# This example takes a long time to run
result = query.run_batch(
    QUERY, "2022-04-28T00:00:00", "2022-05-01T00:00:00", batch_freq="6H"
)
print(f"Results: {result}")
print(result.shape)
result.to_csv("./example.csv", index=False)

Metadata

Release files for solana-data-scraper 0.0.8

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

Source distribution (sdist)

Source distribution for solana-data-scraper 0.0.8
File Size Uploaded Provenance Actions
solana-data-scraper-0.0.8.tar.gz 235.8 kB Without provenance Details for solana-data-scraper-0.0.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for solana-data-scraper 0.0.8
File Interpreter ABI Platform Actions
solana_data_scraper-0.0.8-py3-none-any.whl Python 3 none any Details for solana_data_scraper-0.0.8-py3-none-any.whl

Total release size: 471.5 kB

Release files / solana-data-scraper-0.0.8.tar.gz

Download URL solana-data-scraper-0.0.8.tar.gz
Size 235.8 kB
Tags Source
SHA-256 checksum
How to use checksums
22268020d7d5ed10712b9f00209d080a5f39ed64c6d69d692d48cf73a9dfc7a5
BLAKE2b-256 checksum
How to use checksums
2df70179ed390e3d4e5ec036f7f3c87426cb146fc37b47220e50a80da2d21555
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.9.10 Darwin/21.1.0

Release files / solana_data_scraper-0.0.8-py3-none-any.whl

Download URL solana_data_scraper-0.0.8-py3-none-any.whl
Size 235.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0a3a063560bf45251993bca7d609c54e21c7dfd9a310e78114ef561ba60806b
BLAKE2b-256 checksum
How to use checksums
cb2624f7855d97da0effd8cae8df4b5055c55d5d4742bd8e6806dd6294d025d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.9.10 Darwin/21.1.0

Security for solana-data-scraper 0.0.8

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.

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