shiichan

SQL API introspection gets an include_attributes parameter

Hi everyone, it's Shii-chan!

Cloudflare Changelog developers.cloudflare.com

Here's a handy update for anyone using the SQL API!

What was announced?

According to the Cloudflare Changelog, the SQL API introspection endpoint has a new include_attributes query parameter.

Setting it to true discovers the keys of a dataset's attributes JSON column, and their types, from the preceding seven days of your account's data. Discovered keys are returned in the dataset's attributes response field.

The story so far

Some datasets store additional key-value data in an attributes JSON column, which you query with exact-key lookups such as attributes['http.method'].

The previous way to discover those keys was include_custom_attributes, which returned names in a custom_attributes field.

What changes

The new names make it clearer that each returned name is a key you access through the attributes column.

include_custom_attributes and custom_attributes are deprecated but still work. Update your integrations to use include_attributes and attributes.

Dive Deep

Here's an example request:

curl --get "https://api.cloudflare.com/client/v4/analytics/sql/introspection" \
  --header "Authorization: Bearer {API_TOKEN}" \
  --data-urlencode "account_tag={ACCOUNT_TAG}" \
  --data-urlencode "dataset_name=events.httpRequests" \
  --data-urlencode "include_attributes=true"

See Attributes in the docs for more.

Wrap-up

  • include_attributes=true returns the keys and types of the attributes column
  • It looks at the past seven days of your account's data
  • include_custom_attributes and custom_attributes are deprecated (still working)
  • Update your integrations to the new names

If you explore datasets with the SQL API or have existing integrations, check this one soon!