Nansen Query Documentation
  • Introduction
  • Overview
    • 📍Getting Started
    • 📍Benefits of Curation
  • Data
    • 🗃️Data Sources
    • 🗃️Data Catalog
      • 🗃️Raw Events
      • 🗃️Aggregates
        • Entity Stats
        • Address Stats
        • Token Usage Stats
        • Transaction Stats
        • Address & Their Relationships
      • 🗃️Dex Trades
        • 🗃️Dex Trader P&L
        • 🗃️Dex Trader Use Cases
        • 🗃️Advanced Topics
        • 🗃️Trader P&L FAQ
      • 🗃️Decoded Contracts
      • 🗃️NFTs
      • 🗃️Governance
      • 🗃️Solana
        • 🗃️Solana Aggregates
    • 🗃️Repeated / Nested Fields
    • 🗃️Adding New Projects
    • 🗃️Data Marketplace
  • Web App
    • 🖥️Overview
    • 🖥️Getting Started: Web App
    • 🖥️My Queries
    • 🖥️Query Editor
    • 🖥️Visualizations
    • 🖥️Dashboards
    • 🖥️Dashboard Editor
    • 🖥️Refresh Schedules
    • ⚙️Custom Query APIs
      • ⚙️API Keys
      • ⚙️Execute A Query
      • ⚙️Get Query Results
  • Database Access
    • 📂Database Overview
    • 📂Getting Started: Database
    • 📂Sample Queries
      • 📂Wallet Examples
      • 📂Token Examples
      • 📂Trader P&L
      • 📂Project Examples
      • 📂Solana Queries
      • 📂Blockchain Examples
    • 📂Sample Python Code
      • 📂Wallet Examples
      • 📂Token Examples
    • 📂Cost Optimization
    • 📂Database FAQs
  • Other
    • ⁉️General FAQs
    • 🏷️Wallet Labels
Powered by GitBook
On this page
  1. Database Access

Sample Python Code

Below are sample codes for accessing BigQuery from Google Colab. The code might be different depending on your specific environment.

Required Packages

Authentication is required before the data can be access from BigQuery.

# Authentification of google colab user 

from google.colab import auth
auth.authenticate_user()

After authentication, import the bigquery package from Google Cloud.

# Importing the bigquery package to link our colab notebook to bigquery

from google.cloud import bigquery

# Accessing user's project on bigquery, make sure the project name is correct

client = bigquery.Client(project="nansen-query")

Import other required packages. The below are required to run the rest of the examples. You may require different packages for your specific use case.

# Importing relevant python libraries

import pandas
from matplotlib import pyplot as plt
import matplotlib as mpl
PreviousBlockchain ExamplesNextWallet Examples

Last updated 2 years ago

More examples can be found here:

📂
https://www.kaggle.com/code/yazanator/analyzing-ethereum-classic-via-google-bigquery/notebook