docs / integrations / datacamp-workspace
๐Ÿ•๏ธ

DataCamp Workspace

Use Headless Oracle in a DataCamp workspace or any Jupyter notebook environment. Install the Python SDK with a single pip install, fetch cryptographically signed market status receipts, and gate any execution logic on verified market state.

Works in DataCamp workspaces, Jupyter Lab, Jupyter Notebook, Google Colab, and any standard Python environment.

1

Install the SDK

Run in a DataCamp workspace terminal or notebook cell:

# In a notebook cell (the ! prefix runs shell commands in Jupyter)
!pip install headless-oracle

# Or in the workspace terminal:
pip install headless-oracle

The package includes verify(), OracleClient, and optional LangChain/CrewAI tools. No extra dependencies required for basic use.

2

Get a free API key

Request a key from a notebook cell. It arrives in the response immediately:

import requests

resp = requests.post(
    "https://headlessoracle.com/v5/keys/instant",
    json={"agent_id": "my-datacamp-notebook"}
)
print(resp.json())
# {"key": "ho_free_...", "plan": "free", "requests_per_day": 500}

Free keys allow 500 requests/day across all 28 exchanges. No credit card required. Store your key as an environment variable, not in the notebook itself.

3

Check market status

Fetch a signed receipt and verify it in 3 lines:

import os
from headless_oracle import OracleClient, verify, VerificationError

# In DataCamp workspaces, use environment variables for secrets
oracle = OracleClient(api_key=os.environ["ORACLE_KEY"])

receipt = oracle.get_status("XNYS")   # NYSE
print(f"NYSE is: {receipt['status']}")  # OPEN or CLOSED

# Verify the Ed25519 signature โ€” don't skip this
verify(receipt)
print("โœ“ Receipt signature verified")
Supported MIC codes: XNYS (NYSE) ยท XNAS (NASDAQ) ยท XLON (London) ยท XJPX (Tokyo) ยท XPAR (Euronext Paris) ยท XHKG (Hong Kong) ยท XSES (Singapore)
4

Safe market analysis notebook

A complete notebook pattern โ€” check status first, run analysis only if market is confirmed OPEN:

import os
import pandas as pd
from headless_oracle import OracleClient, verify, VerificationError

ORACLE_KEY = os.environ.get("ORACLE_KEY", "")
oracle = OracleClient(api_key=ORACLE_KEY)

EXCHANGES = ["XNYS", "XNAS", "XLON", "XJPX", "XPAR", "XHKG", "XSES"]


def safe_market_check(mic: str) -> dict:
    """
    Fetch and verify a signed receipt. Returns a dict with:
      - status: OPEN | CLOSED | HALTED | UNKNOWN
      - safe:   True only if OPEN and signature verified
      - reason: human-readable explanation
    """
    try:
        receipt = oracle.get_status(mic)
        verify(receipt)                   # raises VerificationError if invalid
        is_open = receipt["status"] == "OPEN"
        return {
            "mic": mic,
            "status": receipt["status"],
            "safe": is_open,
            "reason": "Verified OPEN" if is_open else f"Market is {receipt['status']}",
            "expires_at": receipt.get("expires_at"),
        }
    except VerificationError as e:
        return {"mic": mic, "status": "UNKNOWN", "safe": False,
                "reason": f"Signature verification failed: {e}", "expires_at": None}
    except Exception as e:
        return {"mic": mic, "status": "UNKNOWN", "safe": False,
                "reason": f"Oracle error: {e}", "expires_at": None}


# โ”€โ”€ Check all exchanges โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

results = [safe_market_check(mic) for mic in EXCHANGES]
df = pd.DataFrame(results)

display(df[["mic", "status", "safe", "reason"]].style.applymap(
    lambda v: "color: #4ade80" if v is True else ("color: #f87171" if v is False else ""),
    subset=["safe"]
))


# โ”€โ”€ Gate your analysis on verified OPEN markets โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

open_markets = [r["mic"] for r in results if r["safe"]]

if not open_markets:
    print("โ›” No markets currently open. Analysis halted.")
else:
    print(f"โœ“ Running analysis for open markets: {', '.join(open_markets)}")
    # --- your analysis code goes here ---
    for mic in open_markets:
        print(f"  โ†’ Fetching data for {mic}...")
5

Get the market schedule

No auth required for schedule queries โ€” useful for planning notebook runs:

import requests
from datetime import datetime, timezone

def get_schedule(mic: str) -> dict:
    resp = requests.get(f"https://headlessoracle.com/v5/schedule?mic={mic}")
    resp.raise_for_status()
    return resp.json()

nyse = get_schedule("XNYS")
now = datetime.now(timezone.utc).isoformat()

print(f"Current UTC:     {now}")
print(f"NYSE next open:  {nyse.get('next_open', 'already open')}")
print(f"NYSE next close: {nyse.get('next_close', 'N/A')}")
print(f"Timezone:        {nyse['timezone']}")
print(f"Holiday?         {nyse.get('is_holiday', False)}")

x402 Micropayments (autonomous agents)

If you're building autonomous agent notebooks that need to make API calls without a pre-provisioned key, Headless Oracle supports x402 micropayments. Free tier keys automatically handle 402 responses โ€” or agents can pay 0.001 USDC per request on Base mainnet.

# Free tier: 500 req/day, no payment needed
# After the limit: agent pays per-request via x402 (0.001 USDC on Base)

oracle = OracleClient(api_key="ho_free_your_key_here")
receipt = oracle.get_status("XNYS")   # auto-handles 429 / 402 if configured

Important

Always call verify(receipt). The receipt is Ed25519-signed by the Oracle. Calling verify() confirms the signature and checks the 60-second TTL. A receipt that arrived over HTTP but fails verification must be treated as untrusted.
Never store receipts across notebook runs. Receipts expire after 60 seconds. Fetch a fresh receipt at the start of each execution โ€” do not pickle or cache them between sessions.
UNKNOWN = CLOSED. If status == "UNKNOWN", the Oracle's signing infrastructure detected an internal error. Always treat UNKNOWN as CLOSED. The safe_market_check() function above handles this correctly.
Store keys in environment variables. In DataCamp workspaces, use the Workspace environment variables panel to set ORACLE_KEY. Never hardcode keys in notebook cells.

Resources