Skip to content
Start here

Get list items

client.Rules.Lists.Items.List(ctx, listID, params) (*CursorPaginationAfter[ListItemListResponse], error)
GET/accounts/{account_id}/rules/lists/{list_id}/items

Fetches all the items 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
params ListItemListParams
AccountID param.Field[string]

Path param: The Account ID for this resource.

maxLength32
minLength32
Cursor param.Field[string]Optional

Query param: The pagination cursor. An opaque string token indicating the position from which to continue when requesting the next/previous set of records. Cursor values are provided under result_info.cursors in the response. You should make no assumptions about a cursor’s content or length.

PerPage param.Field[int64]Optional

Query param: Amount of results to include in each paginated response. A non-negative 32 bit integer.

maximum500
minimum1
ReturnsExpand Collapse
type ListItemListResponse interface{…}
One of the following:
type ListItemListResponseListsListItemIPFull 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 ListItemListResponseListsListItemHostnameFull 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 ListItemListResponseListsListItemRedirectFull 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 ListItemListResponseListsListItemASNFull 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 list items

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"),
  )
  page, err := client.Rules.Lists.Items.List(
    context.TODO(),
    "2c0fc9fa937b11eaa1b71c4d701ab86e",
    rules.ListItemListParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
{
  "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,
  "result_info": {
    "cursors": {
      "after": "yyy",
      "before": "xxx"
    }
  }
}
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,
  "result_info": {
    "cursors": {
      "after": "yyy",
      "before": "xxx"
    }
  }
}