BigQuery Integration for Lens Network Datasets

Query and analyze Lens Network data using Google's powerful BigQuery service.


Overview

This documentation provides a comprehensive guide for integrating and accessing Lens Network datasets via Google BigQuery. It is designed to help users query and analyze data related to the Lens Network's testnet environment.

This is a starting point for accessing and utilizing Lens Network datasets via BigQuery. Users are encouraged to explore and experiment with the data to gain deeper insights into the Lens Network's operation. The mainnet data will be available soon, expanding the scope of accessible data.

Datasets Overview

  • lens_network_testnet_block_explorer: This dataset includes information from the Lens Network's block explorer. It provides detailed data on all the transactions, blocks, and associated metadata within the testnet environment.

  • lens_network_testnet_external_node: This dataset consists of data from the external nodes of the Lens Network. It includes logs, events, and interactions that happen on nodes participating in the Lens Network's testnet.

Accessing the Datasets

To access the datasets via BigQuery:

1

Set Up a Google Cloud Project

  • Ensure you have a Google Cloud account with billing enabled.

  • Create a new project or use an existing one.

2

Enable BigQuery API

  • Go to the Google Cloud Console.

  • Navigate to "APIs & Services" > "Library."

  • Search for "BigQuery API" and enable it.

3

Query the Datasets

  • Open the BigQuery console in Google Cloud.

  • Go to the SQL workspace in the BigQuery panel.

  • Run the following query to access the dataset:

SELECT *FROM `lens-public-data.lens_network_testnet_block_explorer.public_blocks`WHERE number = 1000;

Please note you MUST query this from the US region. If you try to use the EU region, it will not be able to find the dataset.

This query retrieves all the details of block number 1000 from the lens_network_testnet_block_explorer dataset.

Use Cases

Some common use cases for analyzing Lens Network datasets via BigQuery include:

Analyzing Transactions

Query the lens_network_testnet_block_explorer dataset to analyze transaction patterns, gas fees, and success rates.

Performance Monitoring

Use the lens_network_testnet_external_node dataset to monitor node performance, track uptime, and analyze event logs.


External Tools

You can integrate these datasets with external data analysis and visualization tools like Google Data Studio, Tableau, or custom Python scripts using the BigQuery API.

from google.cloud import bigquery
# Initialize a BigQuery clientclient = bigquery.Client()
# Query the datasetquery = '''  SELECT *  FROM `lens-public-data.lens_network_testnet_block_explorer.public_blocks`  WHERE number = 1000;'''query_job = client.query(query)
# Process the resultsresults = query_job.result()for row in results:  print(row)