Python library for scraping blockchain data from Bitquery
Project description
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
pip3 install solquery
- Create an account at https://bitquery.io/
- Retrieve API Key
- 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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
solana-data-scraper-0.0.6.tar.gz
(235.4 kB
view hashes)
Built Distribution
Close
Hashes for solana-data-scraper-0.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21584bdbd67e255d8d745761fff82969c30f9303767fcbd56e2452bb0bd1155f |
|
MD5 | a6e6508ee7539dc087267e6fd38e1cc1 |
|
BLAKE2b-256 | 196fa2e6f5486efc12d6cd04a96465aa99cd637a4efadd013a3353bbf3ed9c2e |
Close
Hashes for solana_data_scraper-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0201be6be7673a01a044b8997ce43e08533b2b33b3e9a5de559e32809edd5a1 |
|
MD5 | 9cdad3815808b5d4f55f73619a9e79ae |
|
BLAKE2b-256 | 1a6f8585286df9a5cd11ec1a9fdcfc72a31add2e38f322cef561fe936e9e14fa |