> ## Documentation Index
> Fetch the complete documentation index at: https://ona.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Top Projects

> Gets the top projects by total environment runtime in the specified date range.

`Unary` · [`Usage`](https://ona.com/docs/api-reference/generated/usage/overview)

Gets the top projects by total environment runtime in the specified date range.

## Endpoint

```text theme={null}
POST /api/gitpod.v1.UsageService/GetTopProjects
```

Send a Bearer token as described in [Authentication](https://ona.com/docs/api-reference.md#authenticate-requests). If your organization uses a custom management-plane domain, replace `https://app.ona.com` with that domain.

## Request example

```bash cURL theme={null}
export ONA_HOST=https://app.ona.com
export ONA_API_KEY=<your-token>

curl --request POST \
  --url "$ONA_HOST/api/gitpod.v1.UsageService/GetTopProjects" \
  --header "Authorization: Bearer $ONA_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "dateRange": {
    "endTime": "2026-01-01T00:00:00Z",
    "startTime": "2026-01-01T00:00:00Z"
  }
}'
```

```python Python theme={null}
import gitpod.v1.usage_pb2 as usage_pb2
import google.protobuf.timestamp_pb2 as timestamp_pb2
from ona_sdk import create_client_from_env

ona = create_client_from_env()
request = usage_pb2.GetTopProjectsRequest(
    date_range=usage_pb2.DateRange(
        start_time=timestamp_pb2.Timestamp(seconds=1767225600),
        end_time=timestamp_pb2.Timestamp(seconds=1767225600),
    ),
)
response = ona.services.usage.get_top_projects(request)
print(response)
```

```typescript TypeScript theme={null}
import { create } from "@bufbuild/protobuf";
import { createClientFromEnv } from "@gitpod/sdk";
import { GetTopProjectsRequestSchema } from "@gitpod/sdk/gitpod/v1/usage_pb";
import { timestampFromDate } from "@bufbuild/protobuf/wkt";

async function main() {
  const ona = createClientFromEnv();
  const request = create(GetTopProjectsRequestSchema, {
    dateRange: {
      startTime: timestampFromDate(new Date("2026-01-01T00:00:00Z")),
      endTime: timestampFromDate(new Date("2026-01-01T00:00:00Z")),
    },
  });
  const response = await ona.services.usage.getTopProjects(request);
  console.log(response);
}

main().catch(console.error);
```

```go Go theme={null}
package main

import (
	"context"
	"fmt"
	"log"

	"connectrpc.com/connect"
	"github.com/gitpod-io/gitpod-sdk-go/sdk"
	gitpodpb "github.com/gitpod-io/gitpod-sdk-go/v1"
	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)

func main() {
	ona, err := sdk.NewFromEnv()
	if err != nil {
		log.Fatal(err)
	}

	request := connect.NewRequest(&gitpodpb.GetTopProjectsRequest{
		DateRange: &gitpodpb.DateRange{
			StartTime: &timestamppb.Timestamp{Seconds: 1767225600},
			EndTime: &timestamppb.Timestamp{Seconds: 1767225600},
		},
	})
	response, err := ona.Services.Usage.GetTopProjects(context.Background(), request)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(response.Msg)
}
```

```json Request body theme={null}
{
  "dateRange": {
    "endTime": "2026-01-01T00:00:00Z",
    "startTime": "2026-01-01T00:00:00Z"
  }
}
```

## Request

`gitpod.v1.GetTopProjectsRequest`

| Field | Type | Required | Description |
| - | - | - | - |
| `pagination` | [PaginationRequest](#type-gitpod-v1-pagination-request) | No | Pagination options. |
| `dateRange` | [DateRange](#type-gitpod-v1-date-range) | Yes | Date range to query metrics within. Constraints: `required=true`. |
| `teamId` | string | No | Optional team ID to scope results to members of a specific team. |

## Response

`gitpod.v1.GetTopProjectsResponse`

| Field | Type | Required | Description |
| - | - | - | - |
| `projects` | array of [ProjectRuntimeInfo](#type-gitpod-v1-get-top-projects-response-project-runtime-info) | No | List of projects sorted by total runtime (descending). |
| `pagination` | [PaginationResponse](#type-gitpod-v1-pagination-response) | No | Pagination response. |

## Related types

> [accordion] DateRange
>
> DateRange specifies a time period for queries.
>
> `gitpod.v1.DateRange`
>
> | Field | Type | Required | Description |
> | - | - | - | - |
> | `startTime` | RFC 3339 timestamp | Yes | Start time of the date range (inclusive). Constraints: `required=true`. |
> | `endTime` | RFC 3339 timestamp | Yes | End time of the date range (exclusive). Constraints: `required=true`. |

> [accordion] ProjectRuntimeInfo
>
> `gitpod.v1.GetTopProjectsResponse.ProjectRuntimeInfo`
>
> | Field | Type | Required | Description |
> | - | - | - | - |
> | `projectId` | string | No | Project ID. |
> | `projectName` | string | No | Project name if available. |
> | `totalRuntimeSeconds` | 64-bit integer string | No | Total runtime in seconds. |

> [accordion] PaginationRequest
>
> `gitpod.v1.PaginationRequest`
>
> | Field | Type | Required | Description |
> | - | - | - | - |
> | `pageSize` | integer | No | Page size is the maximum number of results to retrieve per page. Defaults to 25. Maximum 100. Constraints: `int32.gte=0, int32.lte=100`. |
> | `token` | string | No | Token for the next set of results that was returned as next\_token of a PaginationResponse |

> [accordion] PaginationResponse
>
> `gitpod.v1.PaginationResponse`
>
> | Field | Type | Required | Description |
> | - | - | - | - |
> | `nextToken` | string | No | Token passed for retrieving the next set of results. Empty if there are no more results |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.