Choose content analytics filters

Populate category, author, creation-age and sorting controls for a publication's current content selection. The returned choices describe that selection; they are not reader records, activity totals or a complete taxonomy catalog.

TaskOperationResult
Get choices for the current selectionGET /api/v1/admin/content/analytics/filtersFour arrays: category, author, published and order

Before you start

A resource is the selected publication. Supply its existing public key and an existing active staff session authorized there. Eligible roles are readonly, manager, support, admin and partner; root is also permitted. Service-account credentials are not supported. See credential transport.

HeaderPurposeRequired
resourceSelect the publication by public keyYes
tokenExisting authorized staff sessionYes
Accept: application/jsonRequest JSON responsesUsed in the examples

This GET takes query parameters and no body. All examples are synthetic and unexecuted. They use fictional category2101/author2201 and WALLKIT_API_BASE (scheme and host only, without a trailing slash or /api/v1), RESOURCE_KEY and STAFF_TOKEN. Clients are cURL, Node.js18+ native fetch in an .mjs file and Python3 standard-library urllib. See sample runtimes.

Get report choices

GET /api/v1/admin/content/analytics/filters

Start here to populate category and author selectors for the current report selection. The example selects content created within the thirty_days age choice. Use returned category and author IDs in their matching selection controls. The shared headers and prerequisites apply.

Send filter as JSON text in one query value, URL-encoded by the client. Here its decoded value is {"published":"thirty_days"}. The selection inputs define every supported field. Choices use the full current selection, including the facet being requested; list pagination does not limit them.

Request

curl --fail --silent --show-error --get \
  "$WALLKIT_API_BASE/api/v1/admin/content/analytics/filters" \
  --header 'Accept: application/json' \
  --header "resource: $RESOURCE_KEY" \
  --header "token: $STAFF_TOKEN" \
  --data-urlencode 'filter={"published":"thirty_days"}'
try {
  const url = new URL("/api/v1/admin/content/analytics/filters", process.env.WALLKIT_API_BASE);
  url.searchParams.set("filter", JSON.stringify({ published: "thirty_days" }));
  const response = await fetch(url, { headers: {
    Accept: "application/json", resource: process.env.RESOURCE_KEY, token: process.env.STAFF_TOKEN
  } });
  if (response.status !== 200) throw new Error();
  const choices = await response.json();
  if (!choices || choices.error ||
      !["category", "author", "published", "order"].every(key => Array.isArray(choices[key]))) {
    throw new Error();
  }
  console.log(`Category choices: ${choices.category.length}`);
} catch {
  console.error("Report choices unavailable. Check the publication, session and selection.");
  process.exitCode = 1;
}
import json
import os
from urllib.parse import urlencode
from urllib.request import Request, urlopen

try:
    query = urlencode({"filter": json.dumps({"published": "thirty_days"})})
    url = os.environ["WALLKIT_API_BASE"] + "/api/v1/admin/content/analytics/filters?" + query
    request = Request(url, headers={"Accept": "application/json",
        "resource": os.environ["RESOURCE_KEY"], "token": os.environ["STAFF_TOKEN"]})
    with urlopen(request) as response:
        if response.status != 200:
            raise ValueError()
        choices = json.load(response)
    if (not isinstance(choices, dict) or choices.get("error") or
            not all(isinstance(choices.get(key), list)
                    for key in ("category", "author", "published", "order"))):
        raise ValueError()
    print("Category choices:", len(choices["category"]))
except Exception:
    raise SystemExit("Report choices unavailable. Check the publication, session and selection.") from None

Successful response and fields

HTTP 200; complete synthetic response:

{
  "category": [{"id": 2101, "title": "Culture"}],
  "author": [{"id": 2201, "title": "Example editor"}],
  "published": [
    {"id": "one_day", "title": "1 day"},
    {"id": "one_week", "title": "1 week"},
    {"id": "thirty_days", "title": "30 days"},
    {"id": "three_months", "title": "3 months"},
    {"id": "six_months", "title": "6 months"}
  ],
  "order": [
    {"id": "published", "title": "Date/Time"},
    {"id": "total_views", "title": "Total Views"},
    {"id": "signups_count", "title": "Signups"},
    {"id": "signups_percent", "title": "Signups (%)"},
    {"id": "conversions_count", "title": "Conversions"},
    {"id": "conversions_percent", "title": "Conversions (%)"}
  ]
}
FieldType and presenceMeaning
categoryRequired array, possibly emptyCurrent category terms associated with matching stored-content records
authorRequired array, possibly emptyCurrent author terms associated with matching stored-content records
category[].id, author[].idRequired integerTerm ID to use in its corresponding filter
category[].title, author[].titleRequired string or nullCurrent term label; null means no title is supplied
publishedRequired arrayThe five fixed creation-age choices shown above
orderRequired arrayThe six fixed row-sorting choices shown above
published[].id, order[].idRequired stringExact input enum value shown above
published[].title, order[].titleRequired stringDisplay title shown above

There is no items, paginator or selected/default-value echo. Category and author choices are selection-dependent, rather than a complete publication taxonomy catalogue.

When a choice disappears

For a selection with no matching stored content, a successful response can have the following partial excerpt; the fixed five published and six order entries still remain in the full response:

{"category": [], "author": []}

A narrow filter can remove choices, including choices for its own facet. To broaden the selection, remove a constraint and fetch choices again. For example, change {"category":[2101],"author":[2201],"published":"thirty_days"} to {"category":[2101],"published":"thirty_days"}. This removes the author constraint; it does not guarantee that choices will appear. Current classification changes and missing stored statistics can also affect which choices are available.

HTTP statusAPI code/response shapeCauseNext action
200Empty category/author arraysNo matching terms in this selectionRemove a filter and request choices again; do not create taxonomy terms to repair the report
409invalid_data; error_description: Error retrieve content analytics filtersChoice retrieval or parameter processing failedCheck JSON text and supported values; ask Wallkit if a valid selection still fails
Other status, unreadable JSON or unexpected shapeNo usable choicesRequest or response could not be usedKeep the selectors unavailable and follow shared recovery

Next, populate your selection controls with these IDs and labels. If a filter changes, fetch choices for the new selection; do not keep treating an unavailable choice as a current match.

Selection inputs

This operation uses filter to select choices. It does not page or sort the returned choices using limit, page, order or sort, but supplied values must still validate. Omit those unused controls for this request.

InputType / requirementMeaning, constraints and omission default
filterOptional JSON text query valueA JSON object with the supported keys below; omitted means no category, author or creation-age restriction
filter.categoryOptional array of nonzero JSON integersIDs from category choices; match any supplied category. Omitted or [] adds no category restriction
filter.authorOptional array of nonzero JSON integersIDs from author choices; match any supplied author. Omitted or [] adds no author restriction
filter.publishedOptional stringOne of one_day, one_week, thirty_days, three_months, six_months; omitted adds no creation-age restriction
limitOptional integer, 1–100Page-size control; default 10, validated but unused for choices
pageOptional positive integerOne-based page control; default 1, validated but unused for choices
orderOptional stringOne of the six returned order[].id values; default published; validated but unused for choices
sortOptional stringLowercase asc or desc; default asc; validated but unused for choices

Use integers such as 2101, rather than strings such as "2101", for term IDs. Category and author constraints combine: a record must match both supplied groups. Use only the documented object shape; bracket-style filter parameters are not the format shown here. Omit an unused property rather than substituting null, false or an empty string.

Despite its name, published filters the calendar date of content creation, relative to the selected age interval. It is not a start/end window for access activity. No timezone conversion or UTC designation is supplied. Only content with stored statistics and current matching content participates; missing choices do not establish zero activity or an empty publication taxonomy.

Shared recovery

These checks cover the caller and selected publication. Structured errors use error (code), nullable error_description and req_guid (request reference). They are separate from successful operation payloads; not every failure has this envelope.

HTTP statusAPI code/response shapeCauseNext action
404resource_not_existsSelected publication could not be resolvedCheck its public key and integration context with the administrator
401auth_failed, token_expired or token_compromisedCaller/session is absent or unusableObtain a valid authorized session through the existing sign-in process
401auth_access_failCaller is inactive or access is locked/suspendedAsk the administrator to review caller/publication access
401 or 403accessCaller does not meet the access requirementsAsk the administrator to confirm the caller's grant; changing filters does not grant access
409initialize_failedRequest context initialization failedConfirm publication/session context; give Wallkit the request reference if supplied
Transport failure, other status or unreadable bodyNo usable choicesRetrieval did not produce a usable successful payloadShow unavailable; keep credentials and raw failure content out of logs and seek help if persistent

Full diagram

Use the arrow keys to scroll. Escape closes this view.

Search documentation

Enter at least 2 characters.

    ↑ ↓ move through results · Enter opens · Escape closes