Data Access Path · 2/7
Recommended reading order, not completion status. Optional steps can be skipped.
View all steps
Before you start: Configure your Consumer API Key and have Bash, curl, and jq available.
Make Your First Query in 5 Minutes
By the end of this page you will have searched a set of documents with your API key and read the full body of one of them.
Before you start
- An API key. If you don’t have one, see Get an API key.
- A terminal with
curlandjq.
Set the address and key as environment variables; the commands below use them:
export WHALE_BASE_URL="https://www.marsyoo.com"
export WHALE_API_KEY="your API key"Step 1: Search
Search documents published in the last 30 days that mention “artificial intelligence”, and take the first 10:
curl -sS "$WHALE_BASE_URL/v1/search/history" \
-H "Authorization: Bearer $WHALE_API_KEY" \
-H "Content-Type: application/json" \
--data '{"mode": "keyword", "query": "artificial intelligence", "limit": 10}' \
| tee result.json \
| jq '.results[] | {document_id, source_platform, title}'You’re done with this step when you see results with a document_id:
{
"document_id": "doc_01J...",
"source_platform": "reddit",
"title": "..."
}Note: An empty result is not an error. Usually the keyword has no recent data within your access. Try a more common word.
Step 2: Read the full body
The body in a search result is only the matching snippet. Use the document_id to read the whole text:
DOCUMENT_ID=$(jq -r '.results[0].document_id // empty' result.json)
: "${DOCUMENT_ID:?No results; try another keyword}"
curl -sS "$WHALE_BASE_URL/v1/documents/$DOCUMENT_ID/content" \
-H "Authorization: Bearer $WHALE_API_KEY" \
| jq -r '.content.body'When the terminal prints the document’s full text, you’re done.
Next steps
- Filter by platform and time, and page through more results: Keyword search
- Read authors, metrics and analysis results: Read content & versions
- Collect fresh data from a platform: Live queries
- A request returned an error: Error codes
Completion check: Obtain a document_id and read its content; for empty results, check the query and effective access without automatically requesting collection.