godo.Databases.List()

Generated on 5 Nov 2026 from godo version v1.236.0

Usage

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

Description

List returns a list of the Databases visible with the caller’s API token

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

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.Database
*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.Database

Database represents a DigitalOcean managed database product. These managed databases are usually comprised of a cluster of database nodes, a primary and 0 or more replicas. The EngineSlug is a string which indicates the type of database service. Some examples are “pg”, “mysql” or “redis”. A Database also includes connection information and other properties of the service like region, size and current status.

ID string

Omitted from JSON when empty. JSON key: id

Name string

Omitted from JSON when empty. JSON key: name

EngineSlug string

Omitted from JSON when empty. JSON key: engine

VersionSlug string

Omitted from JSON when empty. JSON key: version

Connection *godo.DatabaseConnection

Omitted from JSON when empty. JSON key: connection

UIConnection *godo.DatabaseConnection

Omitted from JSON when empty. JSON key: ui_connection

PrivateConnection *godo.DatabaseConnection

Omitted from JSON when empty. JSON key: private_connection

StandbyConnection *godo.DatabaseConnection

Omitted from JSON when empty. JSON key: standby_connection

StandbyPrivateConnection *godo.DatabaseConnection

Omitted from JSON when empty. JSON key: standby_private_connection

Users []godo.DatabaseUser

Omitted from JSON when empty. JSON key: users

NumNodes int

Omitted from JSON when empty. JSON key: num_nodes

SizeSlug string

Omitted from JSON when empty. JSON key: size

DBNames []string

Omitted from JSON when empty. JSON key: db_names

RegionSlug string

Omitted from JSON when empty. JSON key: region

Status string

Omitted from JSON when empty. JSON key: status

MaintenanceWindow *godo.DatabaseMaintenanceWindow

Omitted from JSON when empty. JSON key: maintenance_window

CreatedAt time.Time

Omitted from JSON when empty. JSON key: created_at

PrivateNetworkUUID string

Omitted from JSON when empty. JSON key: private_network_uuid

Tags []string

Omitted from JSON when empty. JSON key: tags

ProjectID string

Omitted from JSON when empty. JSON key: project_id

StorageSizeMib uint64

Omitted from JSON when empty. JSON key: storage_size_mib

StorageAutoscale *godo.DatabaseStorageAutoscale

Omitted from JSON when empty. JSON key: storage_autoscale

MetricsEndpoints []*godo.ServiceAddress

Omitted from JSON when empty. JSON key: metrics_endpoints

DOSettings *godo.DOSettings

Omitted from JSON when empty. JSON key: do_settings

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.Databases.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.Databases.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
{
  "databases": [
    {
      "id": "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30",
      "name": "backend",
      "engine": "pg",
      "version": "10",
      "connection": {
        "uri": "postgres://doadmin:[email protected]:25060/defaultdb?sslmode=require",
        "database": "",
        "host": "db.example.com",
        "port": 25060,
        "user": "doadmin",
        "password": "example_password",
        "ssl": true
      },
      "private_connection": {
        "uri": "postgres://doadmin:[email protected]:25060/defaultdb?sslmode=require",
        "database": "",
        "host": "private-db.example.com",
        "port": 25060,
        "user": "doadmin",
        "password": "example_password",
        "ssl": true
      },
      "users": [
        {
          "name": "doadmin",
          "role": "primary",
          "password": "example_password"
        }
      ],
      "db_names": [
        "defaultdb"
      ],
      "num_nodes": 1,
      "region": "nyc3",
      "status": "online",
      "created_at": "2019-01-11T18:37:36Z",
      "maintenance_window": {
        "day": "saturday",
        "hour": "08:45:12",
        "pending": true,
        "description": [
          "Update TimescaleDB to version 1.2.1",
          "Upgrade to PostgreSQL 11.2 and 10.7 bugfix releases"
        ]
      },
      "size": "db-s-2vcpu-4gb",
      "tags": [
        "production"
      ],
      "private_network_uuid": "d455e75d-4858-4eec-8c95-da2f0a5f93a7",
      "version_end_of_life": "2023-11-09T00:00:00Z",
      "version_end_of_availability": "2023-05-09T00:00:00Z",
      "storage_size_mib": 61440
    }
  ]
}

More Information

See GET /v2/databases 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.