godo.Domains.RecordsByTypeAndName()

Generated on 5 Nov 2026 from godo version v1.236.0

Usage

client.Domains.RecordsByTypeAndName(ctx context.Context, domain string, ofType string, name string, opt *godo.ListOptions) ([]godo.DomainRecord, *godo.Response, error)

Description

RecordsByTypeAndName returns a slice of DomainRecord for a domain matched by record type and name.

This method sends a GET request to /v2/domains/{}/records.

Parameters

domain string required
ofType string required
name string required
opt *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.DomainRecord
*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.DomainRecord

DomainRecord represents a DigitalOcean DomainRecord

ID int

Omitted from JSON when empty. JSON key: id

Type string

Omitted from JSON when empty. JSON key: type

Name string

Omitted from JSON when empty. JSON key: name

Data string

Omitted from JSON when empty. JSON key: data

Priority int

JSON key: priority

Port int

JSON key: port

TTL int

Omitted from JSON when empty. JSON key: ttl

Weight int

JSON key: weight

Flags int

JSON key: flags

Tag string

Omitted from JSON when empty. JSON key: tag

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.Domains.RecordsByTypeAndName(ctx, "<your-domain>", "<your-of-type>", "<your-name>", &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.Domains.RecordsByTypeAndName(ctx, "<your-domain>", "<your-of-type>", "<your-name>", 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
{
  "domain_records": [
    {
      "id": 28448429,
      "type": "NS",
      "name": "@",
      "data": "ns1.digitalocean.com",
      "priority": null,
      "port": null,
      "ttl": 1800,
      "weight": null,
      "flags": null,
      "tag": null
    },
    {
      "id": 28448430,
      "type": "NS",
      "name": "@",
      "data": "ns2.digitalocean.com",
      "priority": null,
      "port": null,
      "ttl": 1800,
      "weight": null,
      "flags": null,
      "tag": null
    },
    {
      "id": 28448431,
      "type": "NS",
      "name": "@",
      "data": "ns3.digitalocean.com",
      "priority": null,
      "port": null,
      "ttl": 1800,
      "weight": null,
      "flags": null,
      "tag": null
    },
    {
      "id": 28448432,
      "type": "A",
      "name": "@",
      "data": "1.2.3.4",
      "priority": null,
      "port": null,
      "ttl": 1800,
      "weight": null,
      "flags": null,
      "tag": null
    }
  ],
  "links": {},
  "meta": {
    "total": 4
  }
}

More Information

See GET /v2/domains/{}/records 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.