Read as needed; not a required onboarding step. Path：[Data Access Path](/en/docs)

# Query SDKs (Python & Go)

Query data with a Consumer API Key. Prepare an application subscription and key in [Portal](/en/docs/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](/api/sdk/go-consumer), 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

| Purpose | Python | Go | Endpoint |
| --- | --- | --- | --- |
| Search | `search` | `Search` | `POST /v1/search` |
| History search | `search_history` | `SearchHistory` | `POST /v1/search/history` |
| Browse content by filters | `browse_documents` | `BrowseDocuments` | `GET /v1/documents/browse` |
| Read a user profile | `get_user` | `GetUser` | `GET /v1/users/{platform}/{id}` |
| Read a user's content | `list_user_documents` | `ListUserDocuments` | `GET /v1/users/{platform}/{id}/documents` |
| List classification codes | `list_classifications` | `ListClassifications` | `GET /v1/classifications` |
| Read document metadata | `get_document` | `GetDocument` | `GET /v1/documents/{id}` |
| Read full content | `get_document_content` | `GetDocumentContent` | `GET /v1/documents/{id}/content` |
| Batch read | `batch_get` | `BatchGet` | `POST /v1/documents/batch-get` |
| Content version history | `list_document_versions` | `ListDocumentVersions` | `GET /v1/documents/{id}/versions` |
| Metric snapshot history | `list_document_snapshots` | `ListDocumentSnapshots` | `GET /v1/documents/{id}/snapshots` |
| Transcripts, OCR and other parts | `list_document_parts` | `ListDocumentParts` | `GET /v1/documents/{id}/parts` |
| Structured facts | `list_document_facts` | `ListDocumentFacts` | `GET /v1/documents/{id}/facts` |
| Attachment list and download URL | `list_attachments`, `get_attachment_download_url` | `ListAttachments`, `GetAttachmentDownloadURL` | `GET /v1/documents/{id}/attachments…` |
| Change sync | `list_changes`, `iter_change_pages` | `ListChanges`, `NewChangesIterator` | `GET /v1/changes` |
| On-demand collection | `create_live_query`, `get_live_query`, `list_live_query_results`, `cancel_live_query` | `CreateLiveQuery`, `GetLiveQuery`, `ListLiveQueryResults`, `CancelLiveQuery` | `/v1/live-queries…` |
| Recurring collection | `create_collection_subscription`, `list_collection_subscriptions`, `pause_…`/`resume_collection_subscription`, `list_collection_subscription_tasks` | `CreateCollectionSubscription`, `ListCollectionSubscriptions`, `Pause…`/`ResumeCollectionSubscription`, `ListCollectionSubscriptionTasks` | `/v1/collection/subscriptions…` |
| Bulk exports | `create_export`, `get_export`, `list_export_files`, `download_export_file`, `cancel_export` | `CreateExport`, `GetExport`, `ListExportFiles`, `DownloadExportFile`, `CancelExport` | `/v1/exports…` |
| Analysis (Preview) | `create_analysis_run`, `get_analysis_run`, `cancel_analysis_run`, `list_analysis_artifacts`, `download_analysis_artifact` | `CreateAnalysisRun`, `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](/en/docs/production) 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

- [Users, Topics, Tags & Categories](/en/docs/browse): Exact filters, registry codes and field grants.

- [Keyword & Semantic Search](/en/docs/search): platform, time, language, and field filters.
- [Read Content & History](/en/docs/documents): bodies, versions, parts, and facts.
- [Synchronize Data Changes](/en/docs/change-feed): process a full page before persisting its cursor.
- [Limits, Retries & Troubleshooting](/en/docs/production): timeouts, rate limits, and errors.

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

## Continue Your Task

[Return to the integration path](/en/docs); return to your task after consulting this reference.