Skip to main content
These examples implement the full Entity Search lifecycle: create a task, poll status, fetch every result, and handle terminal states. See the Entity Search reference for field definitions and error codes. If you adapt these examples for entity_type: "xiaohongshu" or entity_type: "wechat", add enable_web_search: true to the create request body. Use wechat for WeChat Official Account search. These tasks usually take 1 to 2 minutes before results are ready, so keep polling instead of creating a duplicate task.

Node.js

This example uses Node.js 18 or later and processes each available result exactly once.

Python

Install the asynchronous HTTP client with python -m pip install httpx.

Recovery guidance

  • Persist the returned Idempotency-Key, X-Request-Id, and leads_search_id before treating task creation as complete.
  • Reuse the original create key and body after a lost response. Do not generate a new key merely because the client timed out.
  • Resume fetching from the first pts that your application has not committed.
  • Back off between status calls. Active tasks continue progressing without a live client connection.
  • Treat unknown fields and new stop_reason values as forward-compatible data.