godo.Projects.List()

Generated on 5 Nov 2026 from godo version v1.236.0

Usage

client.Projects.List(ctx context.Context, opts *godo.ListOptions) ([]godo.Project, *godo.Response, error)

Description

List Projects.

This method sends a GET request to /v2/projects.

Parameters

opts *godo.ListOptions

Fields of godo.ListOptions

ListOptions specifies the optional parameters to various List methods that support pagination.

Page int

For paginated result sets, page of results to retrieve.

PerPage int

For paginated result sets, the number of results to include per page.

WithProjects bool

Whether App responses should include project_id fields. The field will be empty if false or if omitted. (ListApps)

Deployed bool

This parameter is used to only list agents that are deployed in the response.

PublicOnly bool

This parameter is used to include models that are publicly available.

Usecases []string

This parameter is used to include models according to the use cases.

Returns

[]godo.Project
*godo.Response

The HTTP response, with pagination Links, Meta, and Rate limit information.

error

Non-nil when the request fails. API errors are returned as *godo.ErrorResponse.

Fields of godo.Project

Project represents a DigitalOcean Project configuration.

ID string

JSON key: id

OwnerUUID string

JSON key: owner_uuid

OwnerID uint64

JSON key: owner_id

Name string

JSON key: name

Description string

JSON key: description

Purpose string

JSON key: purpose

Environment string

JSON key: environment

IsDefault bool

JSON key: is_default

CreatedAt string

JSON key: created_at

UpdatedAt string

JSON key: updated_at

Request Sample

Show Request Sample
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/digitalocean/godo"
)

func main() {
	client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
	ctx := context.TODO()

	result, _, err := client.Projects.List(ctx, &godo.ListOptions{Page: 1, PerPage: 50})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", result)
}

Pagination

This method returns one page of results. Response.Links carries the pagination state; loop until IsLastPage reports true.

Show Pagination Sample
opt := &godo.ListOptions{Page: 1, PerPage: 50}
for {
	items, resp, err := client.Projects.List(ctx, opt)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", items)

	if resp.Links == nil || resp.Links.IsLastPage() {
		break
	}
	page, err := resp.Links.CurrentPage()
	if err != nil {
		log.Fatal(err)
	}
	opt.Page = page + 1
}

Response Example

Show Response Example
{
  "projects": [
    {
      "id": "4e1bfbc3-dc3e-41f2-a18f-1b4d7ba71679",
      "owner_uuid": "99525febec065ca37b2ffe4f852fd2b2581895e7",
      "owner_id": 258992,
      "name": "my-web-api",
      "description": "My website API",
      "purpose": "Service or API",
      "environment": "Production",
      "is_default": false,
      "created_at": "2018-09-27T20:10:35Z",
      "updated_at": "2018-09-27T20:10:35Z"
    },
    {
      "id": "addb4547-6bab-419a-8542-76263a033cf6",
      "owner_uuid": "99525febec065ca37b2ffe4f852fd2b2581895e7",
      "owner_id": 258992,
      "name": "Default",
      "description": "Default project",
      "purpose": "Just trying out DigitalOcean",
      "environment": "Development",
      "is_default": true,
      "created_at": "2017-10-19T21:44:20Z",
      "updated_at": "2019-11-05T18:50:03Z"
    }
  ],
  "links": {
    "pages": {
      "first": "https://api.digitalocean.com/v2/projects?page=1",
      "last": "https://api.digitalocean.com/v2/projects?page=1"
    }
  },
  "meta": {
    "total": 2
  }
}

More Information

See GET /v2/projects in the API reference for additional detail on responses, headers, parameters, and more.

See the Go package documentation for the source of this method.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.