Arrow Flight Samples
If writing your client in Python or Node.js, we highly recommend using the respective Python SDK or Node.js SDK instead of using the Arrow Flight endpoint directly.
The Arrow Python bindings (also named “PyArrow”) have first-class integration with NumPy, pandas, and built-in Python objects. They are based on the C++ implementation of Arrow.
Queries can be sent and results retrieved as Pandas DataFrames. An example follows:
from pyarrow import flight
apiKey = '[API_KEY]'
query = 'SELECT * FROM eth.recent_blocks LIMIT 10;'
# Connect to the endpoint
client = flight.connect(f'grpc+tls://flight.spiceai.io')
# Authenticate with your app's API key
token_pair = client.authenticate_basic_token('', apiKey)
options = flight.FlightCallOptions(headers=[token_pair])
# Query and fetch a reader for the results
flight_info = client.get_flight_info(flight.FlightDescriptor.for_command(query), options)
reader = client.do_get(flight_info.endpoints[0].ticket, options)
# Convert to a Pandas DataFrame and print the results
print(reader.read_pandas())
- Block Mining Time - Aggregation example to plot Average mining time of block per day of the week (last 1M blocks)
Last modified 2mo ago