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)

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
solana-data-scraper-0.0.8.tar.gz 235.8 kB Details

Built distribution (wheel)

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

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

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

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