Skip to content
Start here

Get list items

client.rules.lists.items.list(stringlistId, ItemListParams { account_id, cursor, per_page, search } params, RequestOptionsoptions?): CursorPaginationAfter<ItemListResponse>
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: ItemListParams { account_id, cursor, per_page, search }
account_id: string

Path param: The Account ID for this resource.

maxLength32
minLength32
cursor?: string

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.

per_page?: number

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

maximum500
minimum1
ReturnsExpand Collapse
ItemListResponse = ListsListItemIPFull { id, created_on, ip, 2 more } | ListsListItemHostnameFull { id, created_on, hostname, 2 more } | ListsListItemRedirectFull { id, created_on, modified_on, 2 more } | ListsListItemASNFull { id, asn, created_on, 2 more }
One of the following:
ListsListItemIPFull { id, created_on, ip, 2 more }
id: string

Defines the unique ID of the item in the List.

maxLength32
minLength32
created_on: 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.

modified_on: string

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

comment?: string

Defines an informative summary of the list item.

ListsListItemHostnameFull { id, created_on, hostname, 2 more }
id: string

Defines the unique ID of the item in the List.

maxLength32
minLength32
created_on: string

The RFC 3339 timestamp of when the list was created.

hostname: Hostname { url_hostname, exclude_exact_hostname }

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

url_hostname: string
exclude_exact_hostname?: boolean

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.

modified_on: string

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

comment?: string

Defines an informative summary of the list item.

ListsListItemRedirectFull { id, created_on, modified_on, 2 more }
id: string

Defines the unique ID of the item in the List.

maxLength32
minLength32
created_on: string

The RFC 3339 timestamp of when the list was created.

modified_on: string

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

redirect: Redirect { source_url, target_url, include_subdomains, 4 more }

The definition of the redirect.

source_url: string
target_url: string
include_subdomains?: boolean
preserve_path_suffix?: boolean
preserve_query_string?: boolean
status_code?: 301 | 302 | 307 | 308
One of the following:
301
302
307
308
subpath_matching?: boolean
comment?: string

Defines an informative summary of the list item.

ListsListItemASNFull { id, asn, created_on, 2 more }
id: string

Defines the unique ID of the item in the List.

maxLength32
minLength32
asn: number

Defines a non-negative 32 bit integer.

created_on: string

The RFC 3339 timestamp of when the list was created.

modified_on: string

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

comment?: string

Defines an informative summary of the list item.

Get list items

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const itemListResponse of client.rules.lists.items.list(
  '2c0fc9fa937b11eaa1b71c4d701ab86e',
  { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
)) {
  console.log(itemListResponse);
}
{
  "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"
    }
  }
}