Skip to content

feat: reconcile SDK with v1 API routes (v0.1.1)#2

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782171349-reconcile-v0.1.1
Open

feat: reconcile SDK with v1 API routes (v0.1.1)#2
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782171349-reconcile-v0.1.1

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Reconciles the published SDK against the canonical v1 API surface (backend/api/routes/v1/* in ito-cloud-runtime, mirrored by the docs catalog v1-api-docs.json) so every method signature matches the real routes exactly. Fixes a real bug in data.orderbook and fills three gaps where the API exposed endpoints the SDK didn't. Bumps 0.1.0 -> 0.1.1.

data.orderbook — bugfix

The published method sent market= but the API reads market_id= (so the filter was silently ignored), and made start/end optional even though the API requires them.

- orderbook(venue, market, start=None, end=None, limit=1000)
+ orderbook(venue, start, end, market_id=None, limit=5000, offset=0)

New methods (endpoints already live, were missing from SDK)

data.spot_klines(symbol, start, end, interval=300, limit=5000)        # GET  /data/spot/klines
backtests.orderbook(start, end, source=None, venue=None, ...)         # GET  /backtests/atop/orderbook
backtests.dataset(symbol, start, end, interval=300, include_l2=False) # POST /backtests/atop/dataset

All signatures now match the client.* examples in the docs catalog 1:1. Tests cover the new methods and assert query/body params are sent correctly (24 passing, ruff clean).

Link to Devin session: https://app.devin.ai/sessions/ef08e8d7517d4afcaf2492b519ab9a1a
Requested by: @alejandorosumah-mansa

Greptile Summary

This PR reconciles the SDK with the live v1 API surface, fixing a silent bug in data.orderbook (wrong param name marketmarket_id, required start/end) and adding three previously-missing endpoints (data.spot_klines, backtests.orderbook, backtests.dataset). It also closes all three issues flagged in the prior review cycle.

  • data.orderbook bugfix: renames marketmarket_id so the filter is actually sent, promotes start/end to required positional args, and raises the default limit from 1 000 to 5 000.
  • New methods: data.spot_klines (GET /data/spot/klines), backtests.orderbook (GET /backtests/atop/orderbook), and backtests.dataset (POST /backtests/atop/dataset) fill the three SDK gaps.
  • Housekeeping: run() now raises ItoAPIError on "failed"/"error" status, User-Agent reads from importlib.metadata, and the unreachable 429 entry is removed from RETRYABLE_STATUS_CODES.

Confidence Score: 5/5

Safe to merge — all changes are additive or fix previously broken parameter names, and every new code path is covered by tests.

The diff is a straightforward API surface reconciliation: one param rename, two new GET wrappers, one new POST wrapper, and three housekeeping fixes from the prior review. All new paths have corresponding tests asserting both return values and wire-level params. No behavioral regressions were found in existing methods.

No files require special attention.

Important Files Changed

Filename Overview
src/ito/resources/data.py Fixes data.orderbook bug (renames marketmarket_id, makes start/end required, bumps default limit 1000→5000, adds offset) and adds new spot_klines method with correct params.
src/ito/resources/backtests.py Adds two new methods (orderbook, dataset) matching live API routes; fixes run() to raise ItoAPIError on "failed"/"error" status instead of silently returning.
src/ito/_http.py Moves User-Agent version to importlib.metadata; removes the unreachable 429 from RETRYABLE_STATUS_CODES with an explanatory comment.
src/ito/init.py Replaces hardcoded __version__ with a importlib.metadata lookup, falling back to "0.0.0" for uninstalled source trees.
tests/test_client.py Adds tests for all new methods and the updated orderbook signature; covers the run() failure path with a dedicated ItoAPIError assertion test.
pyproject.toml Version bump 0.1.0 → 0.1.1 only.
README.md Updates code examples and endpoint table to reflect the corrected orderbook signature and the three new methods.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Caller
    participant SDK
    participant API

    Note over SDK,API: data.orderbook (bugfix)
    Caller->>SDK: data.orderbook(venue, start, end, market_id?)
    SDK->>API: "GET /data/orderbook?venue=&start=&end=&market_id="
    API-->>SDK: "{data: {snapshots: [...]}}"
    SDK-->>Caller: dict

    Note over SDK,API: data.spot_klines (new)
    Caller->>SDK: data.spot_klines(symbol, start, end, interval?)
    SDK->>API: "GET /data/spot/klines?symbol=&start=&end=&interval="
    API-->>SDK: "{data: {klines: [...]}}"
    SDK-->>Caller: dict

    Note over SDK,API: backtests.orderbook (new)
    Caller->>SDK: backtests.orderbook(start, end, source?, venue?, market_id?)
    SDK->>API: "GET /backtests/atop/orderbook?start=&end=&..."
    API-->>SDK: "{data: {rows: [...]}}"
    SDK-->>Caller: dict

    Note over SDK,API: backtests.dataset (new)
    Caller->>SDK: backtests.dataset(symbol, start, end, interval?, include_l2?)
    SDK->>API: POST /backtests/atop/dataset
    API-->>SDK: "{data: {windows: [...], spot_klines: [...]}}"
    SDK-->>Caller: dict

    Note over SDK,API: backtests.run() (fixed error handling)
    Caller->>SDK: backtests.run(strategy_id, dataset_id, ...)
    SDK->>API: POST /backtests/atop
    API-->>SDK: "{data: {run_id, status: accepted}}"
    loop poll
        SDK->>API: "GET /backtests/atop/{run_id}"
        API-->>SDK: "{data: {status: running|succeeded|failed}}"
    end
    alt "status == succeeded"
        SDK-->>Caller: result dict
    else "status == failed / error"
        SDK-->>Caller: raises ItoAPIError
    else timeout exceeded
        SDK-->>Caller: raises TimeoutError
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Caller
    participant SDK
    participant API

    Note over SDK,API: data.orderbook (bugfix)
    Caller->>SDK: data.orderbook(venue, start, end, market_id?)
    SDK->>API: "GET /data/orderbook?venue=&start=&end=&market_id="
    API-->>SDK: "{data: {snapshots: [...]}}"
    SDK-->>Caller: dict

    Note over SDK,API: data.spot_klines (new)
    Caller->>SDK: data.spot_klines(symbol, start, end, interval?)
    SDK->>API: "GET /data/spot/klines?symbol=&start=&end=&interval="
    API-->>SDK: "{data: {klines: [...]}}"
    SDK-->>Caller: dict

    Note over SDK,API: backtests.orderbook (new)
    Caller->>SDK: backtests.orderbook(start, end, source?, venue?, market_id?)
    SDK->>API: "GET /backtests/atop/orderbook?start=&end=&..."
    API-->>SDK: "{data: {rows: [...]}}"
    SDK-->>Caller: dict

    Note over SDK,API: backtests.dataset (new)
    Caller->>SDK: backtests.dataset(symbol, start, end, interval?, include_l2?)
    SDK->>API: POST /backtests/atop/dataset
    API-->>SDK: "{data: {windows: [...], spot_klines: [...]}}"
    SDK-->>Caller: dict

    Note over SDK,API: backtests.run() (fixed error handling)
    Caller->>SDK: backtests.run(strategy_id, dataset_id, ...)
    SDK->>API: POST /backtests/atop
    API-->>SDK: "{data: {run_id, status: accepted}}"
    loop poll
        SDK->>API: "GET /backtests/atop/{run_id}"
        API-->>SDK: "{data: {status: running|succeeded|failed}}"
    end
    alt "status == succeeded"
        SDK-->>Caller: result dict
    else "status == failed / error"
        SDK-->>Caller: raises ItoAPIError
    else timeout exceeded
        SDK-->>Caller: raises TimeoutError
    end
Loading

Reviews (3): Last reviewed commit: "feat: reconcile SDK with v1 API routes +..." | Re-trigger Greptile

@alejandorosumah-mansa alejandorosumah-mansa self-assigned this Jun 22, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Comment thread src/ito/resources/backtests.py
Comment thread src/ito/_http.py Outdated
Comment thread src/ito/_http.py Outdated
@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1782171349-reconcile-v0.1.1 branch from f68ae31 to 58079db Compare June 22, 2026 23:43
Reconcile every method signature against backend/api/routes/v1/*:
- data.orderbook: market -> market_id (was silently dropped), require
  start/end, add offset, fix limit defaults (5000/50000)
- data.spot_klines: add (GET /data/spot/klines)
- backtests.orderbook: add (GET /backtests/atop/orderbook)
- backtests.dataset: add (POST /backtests/atop/dataset)

Review hardening:
- backtests.run() now raises ItoAPIError on terminal 'failed'/'error'
  status instead of returning silently (README example indexes metrics)
- version is sourced once from package metadata (importlib.metadata) for
  both __version__ and the User-Agent header — no more 3-place drift
- drop unreachable 429 from RETRYABLE_STATUS_CODES (handled in its own branch)

Bump 0.1.0 -> 0.1.1. 26 tests passing, ruff clean.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration devin-ai-integration Bot force-pushed the devin/1782171349-reconcile-v0.1.1 branch from 58079db to 67fbb43 Compare June 22, 2026 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant