Skip to main content

View a Collection of Projects

Get a high level view of key metrics for a collection of projects. New to OSO? Check out our Getting Started guide to set up your API access.

tip

All collections are defined as YAML files in OSS Directory. View our current collections here.

Getting Started

Before running any analysis, you'll need to set up your environment:

Start your Python notebook with the following:

import os
import pandas as pd
from pyoso import Client

OSO_API_KEY = os.environ['OSO_API_KEY']
client = Client(api_key=OSO_API_KEY)

For more details on setting up Python notebooks, see our guide on writing Python notebooks.

Query Collections

All Collections

Get the names of all collections on OSO:

query = """
SELECT
collection_name,
display_name
FROM collections_v1
ORDER BY collection_name
"""
df = client.to_pandas(query)

Projects in a Collection

Get the names of all projects in a collection:

query = """
SELECT
project_id,
project_name
FROM projects_by_collection_v1
WHERE collection_name = 'ethereum-github'
"""
df = client.to_pandas(query)

Collection-level Metrics

Code Metrics

Get onchain metrics for all projects in a collection:

query = """
SELECT
tm.sample_date,
tm.amount
FROM timeseries_metrics_by_collection_v0 AS tm
JOIN collections_v1 AS c ON tm.collection_id = c.collection_id
JOIN metrics_v0 AS m ON tm.metric_id = m.metric_id
WHERE
c.collection_name = 'ethereum-github'
AND m.metric_name = 'GITHUB_commits_daily'
ORDER BY 1
"""
df = client.to_pandas(query)

Onchain Metrics

Get onchain metrics for all projects in a collection:

query = """
SELECT
tm.sample_date,
tm.amount
FROM timeseries_metrics_by_collection_v0 AS tm
JOIN collections_v1 AS c ON tm.collection_id = c.collection_id
JOIN metrics_v0 AS m ON tm.metric_id = m.metric_id
WHERE
c.collection_name = 'op-retrofunding-4'
AND m.metric_name = 'BASE_gas_fees_weekly'
ORDER BY 1
"""
df = client.to_pandas(query)

Adding Collections and Projects

Projects and collections are defined as YAML files in our OSS Directory repo. You can add or update your own collections and projects by submitting a pull request.

For more information on how collections work, see our guide here.