Query SDKs (Python & Go)

Query data with a Consumer API Key. Prepare an application subscription and key in Portal first. Downloads require no administrator login; API calls still enforce application permissions.

Python

Requires Python 3.10 or later:

Bash
curl -fsSL https://www.marsyoo.com/api/sdk/python-consumer \
  -o marsyoo-python-consumer-sdk-v0.2.0.tar.gz
tar -xzf marsyoo-python-consumer-sdk-v0.2.0.tar.gz
cd marsyoo-python-consumer-sdk-v0.2.0
python3 -m venv .venv
. .venv/bin/activate
python -m pip install .

Set your application’s key in the WHALE_API_KEY environment variable, then run:

Python
import os
from whale_consumer import Client
 
client = Client(api_key=os.environ["WHALE_API_KEY"], timeout=30)
result = client.search(query="AI", mode="keyword", limit=10)
for item in result.get("results", []):
    document_id = item["document_id"]
    content = client.get_document_content(document_id)
    print(document_id, content.get("content", {}).get("body", ""))

Empty results means no matches; it does not trigger collection. This Python package contains only the consumer client, not collector modules.

Go

Download the Go Consumer SDK, extract it, and run go test ./... in the package directory. Reference the local module in your Go application:

Bash
go mod edit -require=whale/sdk/go/consumer@v0.0.0
go mod edit -replace=whale/sdk/go/consumer=/absolute/path/to/marsyoo-go-consumer-sdk-v0.2.0

Replace the extraction path with your actual absolute path. The README contains search and change-feed examples. Import whale/sdk/go/consumer.

Add this example to your application’s main.go:

Go
package main
 
import (
    "context"
    "fmt"
    "log"
    "os"
    "time"
 
    consumer "whale/sdk/go/consumer"
)
 
func main() {
    key := os.Getenv("WHALE_API_KEY")
    if key == "" {
        log.Fatal("Set WHALE_API_KEY")
    }
    ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
    defer cancel()
    client := consumer.New("https://www.marsyoo.com", key)
    result, err := client.Search(ctx, consumer.SearchRequest{Query: "AI", Mode: "keyword", Limit: 10})
    if err != nil {
        log.Fatal(err)
    }
    for _, item := range result.Results {
        content, err := client.GetDocumentContent(ctx, item.DocumentID, "")
        if err != nil {
            log.Fatal(err)
        }
        fmt.Println(item.DocumentID, content.Content["body"])
    }
}

After adding the code, run go mod tidy, then go run .. Empty results do not request a document body.

Browse by topic or category

Python
page = client.browse_documents(
    topics=["AI"],
    created_from="2026-10-01T00:00:00Z",
    created_to="2026-10-02T00:00:00Z",
    limit=50,
)
for item in page.get("documents", []):
    print(item["document"]["id"])

Keep parameters unchanged and pass returned next_cursor as cursor for subsequent pages. Python also provides get_user, list_user_documents, list_classifications and search_history. Go equivalents are GetUser, ListUserDocuments, ListClassifications, SearchHistory and BrowseDocuments with CatalogRequest. Search accepts query_vector / QueryVector; search cursor / Cursor is keyword-only. User profiles are collected observations, not live platform accounts.

Method Reference

PurposePythonGoEndpoint
SearchsearchSearchPOST /v1/search
History searchsearch_historySearchHistoryPOST /v1/search/history
Browse content by filtersbrowse_documentsBrowseDocumentsGET /v1/documents/browse
Read a user profileget_userGetUserGET /v1/users/{platform}/{id}
Read a user’s contentlist_user_documentsListUserDocumentsGET /v1/users/{platform}/{id}/documents
List classification codeslist_classificationsListClassificationsGET /v1/classifications
Read document metadataget_documentGetDocumentGET /v1/documents/{id}
Read full contentget_document_contentGetDocumentContentGET /v1/documents/{id}/content
Batch readbatch_getBatchGetPOST /v1/documents/batch-get
Content version historylist_document_versionsListDocumentVersionsGET /v1/documents/{id}/versions
Metric snapshot historylist_document_snapshotsListDocumentSnapshotsGET /v1/documents/{id}/snapshots
Transcripts, OCR and other partslist_document_partsListDocumentPartsGET /v1/documents/{id}/parts
Structured factslist_document_factsListDocumentFactsGET /v1/documents/{id}/facts
Attachment list and download URLlist_attachments, get_attachment_download_urlListAttachments, GetAttachmentDownloadURLGET /v1/documents/{id}/attachments…
Change synclist_changes, iter_change_pagesListChanges, NewChangesIteratorGET /v1/changes
On-demand collectioncreate_live_query, get_live_query, list_live_query_results, cancel_live_queryCreateLiveQuery, GetLiveQuery, ListLiveQueryResults, CancelLiveQuery/v1/live-queries…
Recurring collectioncreate_collection_subscription, list_collection_subscriptions, pause_…/resume_collection_subscription, list_collection_subscription_tasksCreateCollectionSubscription, ListCollectionSubscriptions, Pause…/ResumeCollectionSubscription, ListCollectionSubscriptionTasks/v1/collection/subscriptions…
Bulk exportscreate_export, get_export, list_export_files, download_export_file, cancel_exportCreateExport, GetExport, ListExportFiles, DownloadExportFile, CancelExport/v1/exports…
Analysis (Preview)create_analysis_run, get_analysis_run, cancel_analysis_run, list_analysis_artifacts, download_analysis_artifactCreateAnalysisRun, GetAnalysisRun, CancelAnalysisRun, ListAnalysisArtifacts, DownloadAnalysisArtifact/v1/analysis…

Download methods (download_export_file, download_analysis_artifact and their Go counterparts) stream to disk or a writer instead of loading whole files into memory. Attachment download URLs are signed and valid for 300 seconds; fetch them directly without the API key.

Errors, Retries and Timeouts

  • Non-2xx responses raise or return APIError with code, message and the HTTP status (status in Python, Status in Go). See Limits, Retries & Troubleshooting for error codes.
  • Only change sync (list_changes / ListChanges and the iterators) retries network errors, 429 and 5xx automatically, up to 3 attempts in total with exponential backoff. Other methods do not retry; handle them as the troubleshooting page recommends.
  • Python defaults to a 30-second timeout, adjustable with Client(timeout=...); in Go, the context you pass controls timeouts and cancellation.

Next Steps

Use HTTP with the same Consumer Key for attachment downloads and endpoints not wrapped by the SDK.