Download Markdown

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 curl and jq.

Set the address and key as environment variables; the commands below use them:

Bash
export WHALE_BASE_URL="https://www.marsyoo.com"
export WHALE_API_KEY="your API key"

Search documents published in the last 30 days that mention “artificial intelligence”, and take the first 10:

Bash
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:

JSON
{
  "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:

Bash
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

Completion check: Obtain a document_id and read its content; for empty results, check the query and effective access without automatically requesting collection.