China SnapshotDocs
Get a key ↗
Open in AI ↗
Open in ChatGPTOpen in ClaudeView Markdown
Guides

Retrieve a record

Use an ID returned by the dataset rather than a fabricated example identifier.

Discover, then retrieve#

This runnable Python example first discovers a real ID and then fetches it. Empty results remain empty.

python
import json
from urllib.parse import urlencode
from urllib.request import urlopen
base = 'https://china-snapshot.com/api/datasets'
with urlopen(base + '?dataset=documents&limit=1', timeout=30) as response:
    page = json.load(response)
if page['items']:
    record_id = page['items'][0]['id']
    query = urlencode({'dataset': 'documents', 'id': record_id})
    with urlopen(base + '?' + query, timeout=30) as response:
        detail = json.load(response)
    assert detail['items'][0]['id'] == record_id
    print(json.dumps(detail, ensure_ascii=False))
else:
    print('No retained document was returned.')

Preserve the contract#

Match dataset to the returned ID. Do not combine id with filters or cursor. Document detail adds original_text, text_truncated and rights_basis_url, plus observations[] (each collection with observed_at and acquisition_route, capped at 100, with observations_total giving the full count), revisions[] (version_id, content_hash, observed_at for each retained content version, never the private body) and version_count. An unavailable extraction is null, not permission to infer the text. Follow source_url to the publisher and check text_status.

Search documentation