Skip to content
Start here

Get a list item

client.Rules.Lists.Items.Get(ctx, listID, itemID, query) (*ListItemGetResponse, error)
GET/accounts/{account_id}/rules/lists/{list_id}/items/{item_id}

Fetches a list item in the list.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Account Filter Lists EditAccount Filter Lists Read
ParametersExpand Collapse
listID string

The unique ID of the list.

maxLength32
minLength32
itemID string

Defines the unique ID of the item in the List.

maxLength32
minLength32
query ListItemGetParams
AccountID param.Field[string]

The Account ID for this resource.

maxLength32
minLength32
ReturnsExpand Collapse
type ListItemGetResponse interface{…}
One of the following:
type ListItemGetResponseListsListItemIPFull struct{…}
ID string

Defines the unique ID of the item in the List.

maxLength32
minLength32
CreatedOn string

The RFC 3339 timestamp of when the list was created.

IP string

An IPv4 address, an IPv4 CIDR, an IPv6 address, or an IPv6 CIDR.

ModifiedOn string

The RFC 3339 timestamp of when the list was last modified.

Comment stringOptional

Defines an informative summary of the list item.

type ListItemGetResponseListsListItemHostnameFull struct{…}
ID string

Defines the unique ID of the item in the List.

maxLength32
minLength32
CreatedOn string

The RFC 3339 timestamp of when the list was created.

Hostname Hostname

Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-).

URLHostname string
ExcludeExactHostname boolOptional

Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked.

ModifiedOn string

The RFC 3339 timestamp of when the list was last modified.

Comment stringOptional

Defines an informative summary of the list item.

type ListItemGetResponseListsListItemRedirectFull struct{…}
ID string

Defines the unique ID of the item in the List.

maxLength32
minLength32
CreatedOn string

The RFC 3339 timestamp of when the list was created.

ModifiedOn string

The RFC 3339 timestamp of when the list was last modified.

Redirect Redirect

The definition of the redirect.

SourceURL string
TargetURL string
IncludeSubdomains boolOptional
PreservePathSuffix boolOptional
PreserveQueryString boolOptional
StatusCode RedirectStatusCodeOptional
One of the following:
const RedirectStatusCode301 RedirectStatusCode = 301
const RedirectStatusCode302 RedirectStatusCode = 302
const RedirectStatusCode307 RedirectStatusCode = 307
const RedirectStatusCode308 RedirectStatusCode = 308
SubpathMatching boolOptional
Comment stringOptional

Defines an informative summary of the list item.

type ListItemGetResponseListsListItemASNFull struct{…}
ID string

Defines the unique ID of the item in the List.

maxLength32
minLength32
ASN int64

Defines a non-negative 32 bit integer.

CreatedOn string

The RFC 3339 timestamp of when the list was created.

ModifiedOn string

The RFC 3339 timestamp of when the list was last modified.

Comment stringOptional

Defines an informative summary of the list item.

Get a list item

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/option"
  "github.com/stainless-sdks/cloudflare-go/rules"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  item, err := client.Rules.Lists.Items.Get(
    context.TODO(),
    "2c0fc9fa937b11eaa1b71c4d701ab86e",
    "34b12448945f11eaa1b71c4d701ab86e",
    rules.ListItemGetParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", item)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "id": "34b12448945f11eaa1b71c4d701ab86e",
    "created_on": "2020-01-01T08:00:00Z",
    "ip": "10.0.0.1",
    "modified_on": "2020-01-10T14:00:00Z",
    "comment": "Private IP address"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "id": "34b12448945f11eaa1b71c4d701ab86e",
    "created_on": "2020-01-01T08:00:00Z",
    "ip": "10.0.0.1",
    "modified_on": "2020-01-10T14:00:00Z",
    "comment": "Private IP address"
  },
  "success": true
}