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.
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:
- Python
- GraphQL
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.
The following queries should work if you copy-paste them into our GraphQL sandbox. For more information on how to use the GraphQL API, check out our GraphQL guide.
Query Collections
All Collections
Get the names of all collections on OSO:
- Python
- GraphQL
query = """
SELECT
collection_name,
display_name
FROM collections_v1
ORDER BY collection_name
"""
df = client.to_pandas(query)
query Collections {
oso_collectionsV1 {
collectionName
displayName
}
}
Projects in a Collection
Get the names of all projects in a collection:
- Python
- GraphQL
query = """
SELECT
project_id,
project_name
FROM projects_by_collection_v1
WHERE collection_name = 'ethereum-github'
"""
df = client.to_pandas(query)
query ProjectsInCollection {
oso_projectsByCollectionV1(where: { collectionName: { _eq: "ethereum-github" } }) {
projectId
projectName
}
}
Collection-level Metrics
Code Metrics
Get onchain metrics for all projects in a collection:
- Python
- GraphQL
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)
query GetCollectionAndMetricIds(
$collectionName: String!,
$metricName: String!
) {
oso_collectionsV1(where: { collectionName: { _eq: $collectionName } }) {
collectionId
}
oso_metricsV0(where: { metricName: { _eq: $metricName } }) {
metricId
}
}
Variables for the first two queries:
{
"collectionName": "ethereum-github",
"metricName": "GITHUB_commits_daily"
}
And then for the third query, using the IDs from the previous queries:
query GetCollectionTimeseriesMetrics(
$collectionId: String!,
$metricId: String!
) {
oso_timeseriesMetricsByCollectionV0(
where: {
collectionId: { _eq: $collectionId }
metricId: { _eq: $metricId }
}
order_by: { sampleDate: Asc }
) {
sampleDate
amount
}
}
Using the IDs from the previous queries:
{
"collectionId": "r0SpWoQGlLPB/ZXdas1jtd8k3DwLmhy/l8hdzpJrU1g=", # from first query
"metricId": "0xy+em6XN6wQKZMqtspcmc49ze3hD4BofTyMG+PU2OE=" # from first query
}
Onchain Metrics
Get onchain metrics for all projects in a collection:
- Python
- GraphQL
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)
query GetCollectionAndMetricIds(
$collectionName: String!,
$metricName: String!
) {
oso_collectionsV1(where: { collectionName: { _eq: $collectionName } }) {
collectionId
}
oso_metricsV0(where: { metricName: { _eq: $metricName } }) {
metricId
}
}
Variables for the first query:
{
"collectionName": "op-retrofunding-4",
"metricName": "BASE_gas_fees_weekly"
}
And then get the timeseries data:
query GetCollectionTimeseriesMetrics(
$collectionId: String!,
$metricId: String!
) {
oso_timeseriesMetricsByCollectionV0(
where: {
collectionId: { _eq: $collectionId }
metricId: { _eq: $metricId }
}
order_by: { sampleDate: asc }
) {
sampleDate
amount
}
}
Using the IDs from the previous query:
{
"collectionId": "SaxqipEQvxQwOrO6NzeYu+cWkXWkRR0SJV/jGCSb3hU", # from first query
"metricId": "JR9+hI3XJrXA2k+jq4cwcn8jN4lhOd2NCfaqRzsvCNs=" # from first 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.