For AI

Answers

What do view=compact and fields= do, and do they change the price?

Short answer

view picks a preset: standard (the default) returns the shared fields, compact also drops every null field, and full adds platform extras under ext. fields keeps only the dotted paths you list. Neither changes the price or the number of items: a Xiaohongshu search page is $0.02 on okdata whatever shape you ask for.

Every okdata endpoint accepts two optional parameters that shape the answer without changing what is fetched: view and fields. They exist so that a script or an AI agent can ask for exactly the columns it needs. The idea is the same as part and fields in Google's YouTube Data API, which call it partial resources.

view: three presets

view What each object holds Example on a Douyin search result
standard (default) The shared fields of the object kind, nulls included title: null is present
compact Standard minus every field that is null title is gone
full Standard plus ext, the platform's extras ext.duration_ms, ext.music, ext.region

On a Xiaohongshu note search result, full adds ext.ip_location and ext.xsec_token; on a Douyin video search result, the extras are the video's length, its music title and region. The objects reference lists the shared fields.

fields: keep only what you name

fields=id,title,metrics.likes,author.name returns objects with just those paths, nested where they were. Dots reach into objects. Paths are applied after view, which has one practical consequence: ext only exists in full, so fields=id,ext.duration_ms needs view=full as well. Ask for a path that matches nothing and the call still succeeds; the response lists the miss in warnings, such as fields matched nothing: ext.duration_ms.

Price and item count

Request Items Cost
query=露营装备 about 20 $0.02
the same with view=compact about 20 $0.02
the same with view=full&fields=id,metrics.likes,ext.duration_ms about 20 $0.02

You pay per call, so a slim page and a fat page cost the same. The saving is in bandwidth and, when a model reads the result, in tokens.

Example

import os, requests

URL = "https://api.okdata.online/v1/xiaohongshu/notes/search"
H = {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"}

body = requests.get(URL, headers=H, timeout=60, params={
    "query": "防晒霜 推荐", "sort": "popular",
    "view": "full",
    "fields": "id,title,metrics.likes,metrics.favorites,author.name,ext.ip_location",
}).json()
if body["code"] != "ok":
    raise SystemExit(body["message"])
print(body["warnings"])            # [] when every path matched
print(body["meta"]["unavailable"]) # why a field is null, e.g. metrics.views: platform
for note in body["data"]["items"]:
    print(note)

Things to watch

  • Compact hides nulls, it does not explain them. A missing metrics.views in compact output is not zero. meta.unavailable still says which fields are null and whether the platform never shows them (platform) or the source cannot fetch them yet (capability).
  • Paging. You may change view and fields between pages of one listing; the cursor stays valid.
  • Agents. Over MCP the same names go inside params, for example {"query": "露营装备", "fields": "id,title,metrics.likes"}.

For the token side of this, with field lists for common jobs, see reducing LLM tokens on social data.

Sources

  1. YouTube Data API: Partial resources, the part and fields parametersdevelopers.google.com · read

Where people asked this (read 2026-11-12)

Updated

Connect once, then just ask.

Every new key comes with $0.10 to try it. One sentence connects your agent.

Start free
Connect your AI

Paste this into your agent

Read https://okdata.online/agents.md and set up okdata for me; my key is in the OKDATA_API_KEY environment variable.

Claude Code, Cursor, Codex and other agents that can open a link set themselves up from it.

MCP serverhttps://api.okdata.online/mcp