melaya 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59eba73c9f6a69a8b49efdeec7538ab5f3010ec11f0dc93be72419ad49584919
4
- data.tar.gz: 5b0525fb3d0ef0cac38a8a6616de85f34dd9260c68f5a07e2cd6195077748d5e
3
+ metadata.gz: f0422c0d8f2f64f64d6641922f92d3364a6eabfb8c91863fdd9a4d59d7b552a0
4
+ data.tar.gz: 8a1aab35e1c76376d3357790636b32a6e3975219d57cc5d6eff7008bb54f9c5c
5
5
  SHA512:
6
- metadata.gz: 4367298e73999840d5b3ac7b93e55797d6dd8dd24acc556053b70f7466b33d1eedbdfaf3c430913c4a473fb9c8242db0e36603ea8c8da12a131f5d63d9b7e254
7
- data.tar.gz: 6229e9bb7077330edbf5ad972a3905bd0bd7783fc74968a3fd3f732d6dbfa2a1ea8daa481673c1e292bb91e360fdbdfc6e3e9fd2fbf628d391d3563fe7fabfe2
6
+ metadata.gz: cbbf35e9a198eda11dba80ef9483d0bb40690f42bfb845bfcdb7ac0139a91b9c95b358e070b1f81768bb345305397319877b6837eb85e0fe9d17326ae572c06a
7
+ data.tar.gz: 07bf7a75bf51ef0bfa1c8199471ccdada0125e69ba938d0ac7adeb62c36adb0bdcdeccb2b7a43a18f6090c467f1d564a13b2d0c7db52678806f944fc59c212df
data/LICENSE ADDED
@@ -0,0 +1,158 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but not
32
+ limited to compiled object code, generated documentation, and
33
+ conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including the
48
+ original version of the Work and any modifications or additions
49
+ to that Work or Derivative Works thereof, that is intentionally
50
+ submitted to Licensor for inclusion in the Work by the copyright owner
51
+ or by an individual or Legal Entity authorized to submit on behalf of
52
+ the copyright owner. For the purposes of this definition, "submitted"
53
+ means any form of electronic, verbal, or written communication sent
54
+ to the Licensor or its representatives, including but not limited to
55
+ communication on electronic mailing lists, source code control systems,
56
+ and issue tracking systems that are managed by, or on behalf of, the
57
+ Licensor for the purpose of discussing and improving the Work, but
58
+ excluding communication that is conspicuously marked or otherwise
59
+ designated in writing by the copyright owner as "Not a Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity
62
+ on behalf of whom a Contribution has been received by Licensor and
63
+ subsequently incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of
66
+ this License, each Contributor hereby grants to You a perpetual,
67
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
68
+ copyright license to reproduce, prepare Derivative Works of,
69
+ publicly display, publicly perform, sublicense, and distribute the
70
+ Work and such Derivative Works in Source or Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ (except as stated in this section) patent license to make, have made,
76
+ use, offer to sell, sell, import, and otherwise transfer the Work,
77
+ where such license applies only to those patent claims licensable
78
+ by such Contributor that are necessarily infringed by their
79
+ Contribution(s) alone or by combination of their Contribution(s)
80
+ with the Work to which such Contribution(s) was submitted. If You
81
+ institute patent litigation against any entity (including a
82
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
83
+ or a Contribution incorporated within the Work constitutes direct
84
+ or contributory patent infringement, then any patent licenses
85
+ granted to You under this License for that Work shall terminate
86
+ as of the date such litigation is filed.
87
+
88
+ 4. Redistribution. You may reproduce and distribute copies of the
89
+ Work or Derivative Works thereof in any medium, with or without
90
+ modifications, and in Source or Object form, provided that You
91
+ meet the following conditions:
92
+
93
+ (a) You must give any other recipients of the Work or Derivative
94
+ Works a copy of this License; and
95
+
96
+ (b) You must cause any modified files to carry prominent notices
97
+ stating that You changed the files; and
98
+
99
+ (c) You must retain, in the Source form of any Derivative Works
100
+ that You distribute, all copyright, patent, trademark, and
101
+ attribution notices from the Source form of the Work; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, then any Derivative Works that You distribute must
105
+ include a readable copy of the attribution notices contained
106
+ within such NOTICE file.
107
+
108
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
109
+ any Contribution intentionally submitted for inclusion in the Work
110
+ by You to the Licensor shall be under the terms and conditions of
111
+ this License, without any additional terms or conditions.
112
+
113
+ 6. Trademarks. This License does not grant permission to use the trade
114
+ names, trademarks, service marks, or product names of the Licensor,
115
+ except as required for reasonable and customary use in describing the
116
+ origin of the Work and reproducing the content of the NOTICE file.
117
+
118
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed
119
+ to in writing, Licensor provides the Work (and each Contributor
120
+ provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
121
+ OR CONDITIONS OF ANY KIND, either express or implied, including,
122
+ without limitation, any warranties or conditions of TITLE,
123
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
124
+ PURPOSE. You are solely responsible for determining the
125
+ appropriateness of using or redistributing the Work.
126
+
127
+ 8. Limitation of Liability. In no event and under no legal theory,
128
+ whether in tort (including negligence), contract, or otherwise,
129
+ unless required by applicable law (such as deliberate and grossly
130
+ negligent acts) or agreed to in writing, shall any Contributor be
131
+ liable to You for damages, including any direct, indirect, special,
132
+ incidental, or consequential damages of any character arising as a
133
+ result of this License or out of the use or inability to use the
134
+ Work.
135
+
136
+ 9. Accepting Warranty or Additional Liability. While redistributing
137
+ the Work or Derivative Works thereof, You may choose to offer, and
138
+ charge a fee for, acceptance of support, warranty, indemnity, or
139
+ other liability obligations and/or rights consistent with this
140
+ License. However, in accepting such obligations, You may act only
141
+ on Your own behalf and on Your sole responsibility, not on behalf
142
+ of any other Contributor.
143
+
144
+ END OF TERMS AND CONDITIONS
145
+
146
+ Copyright 2026 Melaya (Antoine Roche)
147
+
148
+ Licensed under the Apache License, Version 2.0 (the "License");
149
+ you may not use this file except in compliance with the License.
150
+ You may obtain a copy of the License at
151
+
152
+ http://www.apache.org/licenses/LICENSE-2.0
153
+
154
+ Unless required by applicable law or agreed to in writing, software
155
+ distributed under the License is distributed on an "AS IS" BASIS,
156
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
157
+ See the License for the specific language governing permissions and
158
+ limitations under the License.
data/README.md CHANGED
@@ -1,163 +1,244 @@
1
- # melaya
2
-
3
- Official Ruby SDK for the **[Melaya](https://melaya.org)** trading platform normalized market data, paper + live trading, backtesting, and an AI agentic trading crew across **70+ venues**, powered by an in-house Rust engine.
4
-
5
- - Zero runtime gem dependencies (stdlib `net/http`, `openssl`, `json` only).
6
- - Pure Ruby WebSocket client (RFC 6455) — no external gem required for streaming.
7
- - Full market data, strategies, sim trading, backtesting, and streaming from one client.
8
-
9
- ## Install
10
-
11
- Add to your `Gemfile`:
12
-
13
- ```ruby
14
- gem "melaya", path: "path/to/sdk-ruby" # local checkout
15
- ```
16
-
17
- Or once published to RubyGems:
18
-
19
- ```bash
20
- gem install melaya
21
- ```
22
-
23
- ## Quick start
24
-
25
- ```ruby
26
- require "melaya"
27
-
28
- melaya = Melaya::Client.new(api_key: ENV["MELAYA_API_KEY"]) # keys are prefixed mk_
29
-
30
- # REST — normalized ticker from any of 70+ venues
31
- t = melaya.market.ticker(exchange: "binance", symbol: "BTC/USDT", market: "spot")
32
- puts t["last"], t["bid"], t["ask"]
33
-
34
- # Order book
35
- ob = melaya.market.orderbook(exchange: "bybit", symbol: "BTC/USDT", market: "spot", limit: 20)
36
-
37
- # Candles
38
- candles = melaya.market.ohlcv(exchange: "okx", symbol: "ETH/USDT", timeframe: "1h", limit: 200)
39
- ```
40
-
41
- ## Streaming
42
-
43
- ```ruby
44
- # Live ticker (block form — closes when block returns)
45
- melaya.stream.ticker(exchange: "binance", symbol: "BTC/USDT", market: "spot") do |frame|
46
- puts frame["last"]
47
- break # close after first frame
48
- end
49
-
50
- # Liquidation firehose
51
- melaya.stream.liquidations(exchange: "binance") do |ev|
52
- puts ev["side"], ev["notional"]
53
- break
54
- end
55
- ```
56
-
57
- ## Trading
58
-
59
- ```ruby
60
- # Account: connected exchange keys and usage
61
- keys = melaya.account.keys # [{ "apiKeyId" => "BINANCEUSDM_0", "exchange" => "binanceusdm", ... }]
62
- usage = melaya.account.usage
63
-
64
- # Strategies — launch immediately. Paper (dry_run: true) needs no exchange key.
65
- # SDK-launchable strategies are `custom` Rhai definitions.
66
- result = melaya.strategies.create(
67
- name: "my-bot",
68
- strategy_type: "custom",
69
- exchange: "binanceusdm",
70
- symbol: "BTC/USDT:USDT",
71
- market: "FUTURES",
72
- dry_run: true,
73
- params: {
74
- "language" => "rhai",
75
- "definition" => 'fn evaluate() { emit_long(param("qty")); }',
76
- "qty" => 0.001,
77
- }
78
- )
79
- sid = result["strategyId"]
80
- melaya.strategies.pause(sid)
81
- melaya.strategies.resume(sid)
82
- trades = melaya.strategies.trades(sid)
83
-
84
- # Paper trading (sim broker) — synthetic fills, no venue state
85
- bal = melaya.sim.balance(strategy_id: sid)
86
- fill = melaya.sim.create_order(
87
- strategy_id: sid,
88
- exchange: "binanceusdm",
89
- symbol: "BTC/USDT:USDT",
90
- side: "buy",
91
- type: "market",
92
- amount: 0.001,
93
- market: "FUTURES"
94
- )
95
-
96
- # Backtest on the Rust engine
97
- r = melaya.backtest.start(
98
- "strategyType" => "custom",
99
- "exchange" => "binance",
100
- "symbol" => "BTC/USDT",
101
- "timeframe" => "1h",
102
- "since_ms" => (Time.now.to_i - 90 * 86400) * 1000,
103
- "until_ms" => Time.now.to_i * 1000,
104
- "language" => "rhai",
105
- "definition" => 'fn evaluate() { emit_long(param("qty")); }',
106
- "params" => { "qty" => 0.001 }
107
- )
108
- job_id = r["job_id"]
109
- loop do
110
- j = melaya.backtest.job(job_id)
111
- break if %w[done error].include?(j["status"])
112
- sleep 2
113
- end
114
- result = melaya.backtest.results(job_id)
115
-
116
- # Private streaming (ticket minted automatically)
117
- melaya.stream.strategies do |ev|
118
- puts ev["type"], ev["strategyId"]
119
- break
120
- end
121
-
122
- # Always clean up
123
- melaya.strategies.stop(sid)
124
- melaya.strategies.delete(sid)
125
- ```
126
-
127
- ## Authentication
128
-
129
- Create an API key in the dashboard (**melaya.org → Settings → API Keys**). Keys are prefixed `mk_`; the SDK sends it automatically on every REST call and WebSocket connection.
130
-
131
- Public market-data and account/strategy reads work with the `mk_` key alone. **Live** order placement and live strategy launches additionally require a connected exchange key — connect one in **Settings → Connectors**, then reference it by `apiKeyId`. Paper trading and backtesting never touch a venue and need no exchange credentials.
132
-
133
- ## TLS verification
134
-
135
- The SDK verifies TLS certificates by default. To disable on a dev box with TLS interception:
136
-
137
- ```bash
138
- MELAYA_INSECURE_TLS=1 ruby your_script.rb
139
- ```
140
-
141
- Or pass `verify_ssl: false` to the constructor. **Never disable TLS in production.**
142
-
143
- ## API surface
144
-
145
- | Area | Methods |
146
- |---|---|
147
- | Reference | `market.list_exchanges`, `catalog_counts` |
148
- | Market data | `market.ticker`, `orderbook`, `ohlcv`, `ohlcv_multi`, `trades`, `markets`, `currencies`, `market_constraints`, `status`, `time` |
149
- | Batch / derivatives | `market.tickers`, `funding_rates`, `funding_rate_history`, `funding_rate_history_multi`, `open_interest`, `open_interest_history`, `open_interest_history_multi`, `instruments`, `liquidation_events` |
150
- | Prediction markets | `market.prediction_markets` (polymarket, kalshi, drift_pm, sxbet, azuro, overtime) |
151
- | Account | `account.keys`, `usage`, `api_key_status` |
152
- | Strategies | `strategies.create`, `list`, `get`, `pause`, `resume`, `stop`, `delete`, `update_params`, `status`, `performance`, `executions`, `trades`, `logs` |
153
- | AI optimizer | `strategies.ai_opt_start`, `ai_opt_status`, `ai_opt_approve`, `ai_opt_stop`, `ai_opt_runs` |
154
- | Paper trading | `sim.balance`, `positions`, `open_orders`, `my_trades`, `create_order`, `cancel_order`, `list_accounts` |
155
- | Backtesting | `backtest.start`, `job`, `results`, `trades`, `sweep`, `list`, `favorites`, `funding_range`, `cancel`, `delete`, `delete_all` |
156
- | Public streaming | `stream.ticker`, `orderbook`, `ohlcv`, `trades`, `liquidations` |
157
- | Private streaming | `stream.strategies`, `stream.private` |
158
-
159
- Full docs: **[melaya.org/docs](https://melaya.org/docs)**.
160
-
161
- ## License
162
-
163
- [Apache-2.0](../../LICENSE)
1
+ # melaya
2
+
3
+ > **Current production scope:** Agent Builder and Mobile Device Control are available now. Melaya Trading namespaces are preview-only and not generally available; do not use them with real funds.
4
+
5
+ Official SDK for the **[Melaya](https://melaya.org)** Agent Builder and flagship Mobile Device Control APIs. Trading namespaces are included only as a preview of a later product.
6
+
7
+ - Zero runtime gem dependencies (stdlib `net/http`, `openssl`, `json` only).
8
+ - Full Agent Builder lifecycle: projects, pipelines, templates, Connectors, HITL, evals, events, billing, team, and runner management.
9
+ - Catalogs of **1,500+ scoped tools**, **100+ specialized subagents**, and **20+ model providers** (runtime catalog endpoints are the source of truth).
10
+ - Pure Ruby WebSocket client (RFC 6455) — no external gem required for streaming.
11
+
12
+ ## Install
13
+
14
+ Add to your `Gemfile`:
15
+
16
+ ```ruby
17
+ gem "melaya", path: "path/to/sdk-ruby" # local checkout
18
+ ```
19
+
20
+ Or once published to RubyGems:
21
+
22
+ ```bash
23
+ gem install melaya
24
+ ```
25
+
26
+ ## Agent Builder & Device Control
27
+
28
+ ### Quick start: pair a phone
29
+
30
+ ```ruby
31
+ require "melaya"
32
+
33
+ melaya = Melaya::Client.new(api_key: ENV["MELAYA_API_KEY"]) # keys are prefixed mk_
34
+
35
+ pairing = melaya.agents.phone.pair
36
+ puts "Pairing code: #{pairing["code"]} (expires in #{pairing["expiresInSeconds"]}s)"
37
+ # Enter the code in the Melaya APK on the phone
38
+
39
+ devices = melaya.agents.phone.list_devices
40
+ apps = melaya.agents.phone.list_apps
41
+
42
+ melaya.agents.phone.set_allowed_apps(["com.android.chrome"])
43
+ ```
44
+
45
+ A Melaya platform key is required. "No app API required" means Device Control operates the target app through its user interface; it does not mean the Melaya SDK is unauthenticated.
46
+
47
+ ### Quick start: run an agent pipeline
48
+
49
+ Configure provider credentials through Melaya Connectors first. Never include a provider key in pipeline configuration or per-run overrides.
50
+
51
+ ```ruby
52
+ melaya.agents.pipelines.create(
53
+ name: "mobile-review",
54
+ project: "Operations",
55
+ model_provider: "anthropic",
56
+ model_name: "claude-sonnet-4-6",
57
+ agents: [{
58
+ "name" => "mobile-operator",
59
+ "role" => "Careful mobile operator",
60
+ "instruction" => "Read before acting. Never send, publish, or delete.",
61
+ "agent_tools" => [
62
+ "phone_get_screen_tree",
63
+ "phone_current_app",
64
+ "phone_open_app",
65
+ "phone_click_text",
66
+ "phone_back",
67
+ "phone_wait"
68
+ ]
69
+ }],
70
+ steps: [{ "kind" => "agent", "agent" => { "name" => "mobile-operator" } }],
71
+ maxCostUsd: 1.00
72
+ )
73
+
74
+ run = melaya.agents.pipelines.run("mobile-review", project: "Operations")
75
+ run_id = run["run_id"]
76
+
77
+ melaya.agents.phone.register_active_run(run_id)
78
+
79
+ status = melaya.agents.pipelines.run_status("mobile-review", run_id)
80
+
81
+ # Real-time run events over Socket.IO (connects lazily on first use)
82
+ melaya.events.on_run_update(run_id) { |e| puts e["event_type"] }
83
+ ```
84
+
85
+ ## Trading quick start (preview)
86
+
87
+ ```ruby
88
+ require "melaya"
89
+
90
+ melaya = Melaya::Client.new(api_key: ENV["MELAYA_API_KEY"]) # keys are prefixed mk_
91
+
92
+ # REST — normalized ticker from any of 70+ venues
93
+ t = melaya.market.ticker(exchange: "binance", symbol: "BTC/USDT", market: "spot")
94
+ puts t["last"], t["bid"], t["ask"]
95
+
96
+ # Order book
97
+ ob = melaya.market.orderbook(exchange: "bybit", symbol: "BTC/USDT", market: "spot", limit: 20)
98
+
99
+ # Candles
100
+ candles = melaya.market.ohlcv(exchange: "okx", symbol: "ETH/USDT", timeframe: "1h", limit: 200)
101
+ ```
102
+
103
+ ## Streaming (preview)
104
+
105
+ ```ruby
106
+ # Live ticker (block form — closes when block returns)
107
+ melaya.stream.ticker(exchange: "binance", symbol: "BTC/USDT", market: "spot") do |frame|
108
+ puts frame["last"]
109
+ break # close after first frame
110
+ end
111
+
112
+ # Liquidation firehose
113
+ melaya.stream.liquidations(exchange: "binance") do |ev|
114
+ puts ev["side"], ev["notional"]
115
+ break
116
+ end
117
+ ```
118
+
119
+ ## Trading (preview)
120
+
121
+ ```ruby
122
+ # Account: connected exchange keys and usage
123
+ keys = melaya.account.keys # [{ "apiKeyId" => "BINANCEUSDM_0", "exchange" => "binanceusdm", ... }]
124
+ usage = melaya.account.usage
125
+
126
+ # Strategies — launch immediately. Paper (dry_run: true) needs no exchange key.
127
+ # SDK-launchable strategies are `custom` Rhai definitions.
128
+ result = melaya.strategies.create(
129
+ name: "my-bot",
130
+ strategy_type: "custom",
131
+ exchange: "binanceusdm",
132
+ symbol: "BTC/USDT:USDT",
133
+ market: "FUTURES",
134
+ dry_run: true,
135
+ params: {
136
+ "language" => "rhai",
137
+ "definition" => 'fn evaluate() { emit_long(param("qty")); }',
138
+ "qty" => 0.001,
139
+ }
140
+ )
141
+ sid = result["strategyId"]
142
+ melaya.strategies.pause(sid)
143
+ melaya.strategies.resume(sid)
144
+ trades = melaya.strategies.trades(sid)
145
+
146
+ # Paper trading (sim broker) — synthetic fills, no venue state
147
+ bal = melaya.sim.balance(strategy_id: sid)
148
+ fill = melaya.sim.create_order(
149
+ strategy_id: sid,
150
+ exchange: "binanceusdm",
151
+ symbol: "BTC/USDT:USDT",
152
+ side: "buy",
153
+ type: "market",
154
+ amount: 0.001,
155
+ market: "FUTURES"
156
+ )
157
+
158
+ # Backtest on the Rust engine
159
+ r = melaya.backtest.start(
160
+ "strategyType" => "custom",
161
+ "exchange" => "binance",
162
+ "symbol" => "BTC/USDT",
163
+ "timeframe" => "1h",
164
+ "since_ms" => (Time.now.to_i - 90 * 86400) * 1000,
165
+ "until_ms" => Time.now.to_i * 1000,
166
+ "language" => "rhai",
167
+ "definition" => 'fn evaluate() { emit_long(param("qty")); }',
168
+ "params" => { "qty" => 0.001 }
169
+ )
170
+ job_id = r["job_id"]
171
+ loop do
172
+ j = melaya.backtest.job(job_id)
173
+ break if %w[done error].include?(j["status"])
174
+ sleep 2
175
+ end
176
+ result = melaya.backtest.results(job_id)
177
+
178
+ # Private streaming (ticket minted automatically)
179
+ melaya.stream.strategies do |ev|
180
+ puts ev["type"], ev["strategyId"]
181
+ break
182
+ end
183
+
184
+ # Always clean up
185
+ melaya.strategies.stop(sid)
186
+ melaya.strategies.delete(sid)
187
+ ```
188
+
189
+ ## Authentication
190
+
191
+ Create an API key in the dashboard (**melaya.org → Settings → API Keys**). Keys are prefixed `mk_`. Every REST call sends the key **only** as an `Authorization: Bearer mk_...` header — never in the URL query string. Public WebSocket market-data streams authenticate with `?apiKey=` in the `wss://` URL (server protocol); private WebSocket streams instead use a short-lived `?wsTicket=` that the SDK mints automatically.
192
+
193
+ Public market-data and account/strategy reads work with the `mk_` key alone. **Live** order placement and live strategy launches additionally require a connected exchange key — connect one in **Settings → Connectors**, then reference it by `apiKeyId`. Paper trading and backtesting never touch a venue and need no exchange credentials.
194
+
195
+ ## API surface
196
+
197
+ ### Agent Builder & platform (GA)
198
+
199
+ | Area | Methods |
200
+ |---|---|
201
+ | Auth | `auth.login`, `verify_mfa`, `register`, `verify_signup`, `resend_verification`, `me`, `check`, `change_password`, `forgot_password`, `reset_password`, `mobile_handoff`, `permissions`, `refresh` |
202
+ | MFA | `auth.mfa_status`, `mfa_setup`, `mfa_confirm` (also via `melaya.platform.mfa`) |
203
+ | Projects | `projects.list`, `create`, `rename`, `runner_projects` |
204
+ | Connectors | `connectors.connected_services`, `set`, `delete`, `env_handle`, `google_oauth_start` |
205
+ | Credentials | `credentials.list`, `connected_services`, `get`, `set`, `delete`, `test`, `list_models`, plus operator-profile, OAuth, and RAG helpers |
206
+ | Pipelines | `pipelines.create`, `get`, `update`, `delete_pipeline`, `list_pipelines`, `run`, `run_ids`, `run_status`, `cancel_run`, `outputs`, `output`, `preview_code`, `tools`, `subagents`, `instantiate_template`, `build_with_ai` |
207
+ | Runs & traces | `pipelines.list`, `recent`, `count`, `traces`, `trace`, `trace_stats`, `delete_traces` |
208
+ | Schedules | `pipelines.list_schedules`, `get_schedule`, `upsert_schedule`, `pause_schedule`, `resume_schedule` |
209
+ | Overview | `pipelines.overview`, `model_prices`, `chart_data`, `cost_breakdown`, `server_version` |
210
+ | Templates | `templates.list`, `list_global`, `list_validated`, `save`, `update`, `duplicate`, `delete`, `share`, `share_targets`, `list_assignments`, `assign(id, user_id:` \| `project_id:)`, `unassign(id, user_id:` \| `project_id:)` |
211
+ | Phone | `phone.pair`, `list_devices`, `revoke_device`, `screen_tree`, `list_apps`, `set_allowed_apps`, `register_active_run` |
212
+ | HITL | `hitl.pending`, `history`, `approve`, `reject`, `bulk_decide`, `run_tool_stats`, `run_tool_stats_by_agent`, `run_messages`, `run_tool_calls` |
213
+ | Evals | `evals.list_runs`, `summary`, `run_detail`, `compare`, `memory_graph`, `run_memory`, `crew_memory`, `benchmarks` |
214
+ | Events | `events.on_run_update`, `on_init_phase`, `on_project_event`, `on_hitl_approval`, `on_pipeline_created`, `on_pipeline_updated`, `on_pipeline_deleted`, `leave_run`, `leave_project`, `close` |
215
+ | Billing | `billing.subscription`, `create_checkout`, `create_portal`, `plans`, `credits`, `ai_credits`, `portfolio_ideas_credits`, `risk_monitoring_credits` |
216
+ | Accounts | `accounts.export_data`, `remove_key`, `update_profile` |
217
+ | Runner | `runner.create_token`, `list_tokens`, `revoke_token` |
218
+ | Team | `team.list_members`, `invite`, `create_invite_link`, `accept_invite`, `update_member_role`, `remove_member`, `get_pipeline_visibility`, `set_pipeline_visibility` |
219
+ | Assistant | `assistant.get_profile`, `set_profile` |
220
+ | Bugs | `bugs.create`, `list_mine`, `get`, `add_comment`, `list_notifications`, `mark_notifications_read` |
221
+
222
+ Every area is also reachable through the domain namespaces: `melaya.agents.*` (pipelines/runs, hitl, assistant, phone, evals, models) and `melaya.platform.*` (projects, credentials, connectors, billing, team, templates, overview, runner, auth, mfa, accounts, bugs, events).
223
+
224
+ ### Trading (preview — not generally available)
225
+
226
+ | Area | Methods |
227
+ |---|---|
228
+ | Reference | `market.list_exchanges`, `catalog_counts` |
229
+ | Market data | `market.ticker`, `orderbook`, `ohlcv`, `ohlcv_multi`, `trades`, `markets`, `currencies`, `market_constraints`, `status`, `time` |
230
+ | Batch / derivatives | `market.tickers`, `funding_rates`, `funding_rate_history`, `funding_rate_history_multi`, `open_interest`, `open_interest_history`, `open_interest_history_multi`, `instruments`, `liquidation_events` |
231
+ | Prediction markets | `market.prediction_markets` (polymarket, kalshi, drift_pm, sxbet, azuro, overtime) |
232
+ | Account | `account.keys`, `usage`, `api_key_status` |
233
+ | Strategies | `strategies.create`, `list`, `get`, `pause`, `resume`, `stop`, `delete`, `update_params`, `status`, `performance`, `executions`, `trades`, `logs` |
234
+ | AI optimizer | `strategies.ai_opt_start`, `ai_opt_status`, `ai_opt_approve`, `ai_opt_stop`, `ai_opt_runs` |
235
+ | Paper trading | `sim.balance`, `positions`, `open_orders`, `my_trades`, `create_order`, `cancel_order`, `list_accounts` |
236
+ | Backtesting | `backtest.start`, `job`, `results`, `trades`, `sweep`, `list`, `favorites`, `funding_range`, `cancel`, `delete`, `delete_all` |
237
+ | Public streaming | `stream.ticker`, `orderbook`, `ohlcv`, `trades`, `liquidations` |
238
+ | Private streaming | `stream.strategies`, `stream.private` |
239
+
240
+ Full docs: **[melaya.org/docs](https://melaya.org/docs)**.
241
+
242
+ ## License
243
+
244
+ [Apache-2.0](../../LICENSE)
@@ -1,30 +1,30 @@
1
- # frozen_string_literal: true
2
-
3
- module Melaya
4
- # Account API — authenticated reads about your Melaya account.
5
- #
6
- # Connected-exchange key references (masked), tier limits, and live usage
7
- # counters. Requires an mk_ key on the private plane.
8
- class AccountAPI
9
- def initialize(http)
10
- @http = http
11
- end
12
-
13
- # The exchange API keys connected to your account. +api_key+ is masked
14
- # (display-only); use +api_key_id+ (e.g. BINANCEUSDM_0) when launching
15
- # strategies or minting a private stream ticket.
16
- def keys
17
- @http.get("/api/v1/private/keys")["keys"]
18
- end
19
-
20
- # Tier, plan limits, and live usage counters (mirrors the dashboard's usage page).
21
- def usage
22
- @http.get("/api/v1/private/usage")
23
- end
24
-
25
- # Status of your platform API key (tier, max concurrent connections).
26
- def api_key_status
27
- @http.get("/api/v1/private/api-key")
28
- end
29
- end
30
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Melaya
4
+ # Account API — authenticated reads about your Melaya account.
5
+ #
6
+ # Connected-exchange key references (masked), tier limits, and live usage
7
+ # counters. Requires an mk_ key on the private plane.
8
+ class AccountAPI
9
+ def initialize(http)
10
+ @http = http
11
+ end
12
+
13
+ # The exchange API keys connected to your account. +api_key+ is masked
14
+ # (display-only); use +api_key_id+ (e.g. BINANCEUSDM_0) when launching
15
+ # strategies or minting a private stream ticket.
16
+ def keys
17
+ @http.get("/api/v1/private/keys")["keys"]
18
+ end
19
+
20
+ # Tier, plan limits, and live usage counters (mirrors the dashboard's usage page).
21
+ def usage
22
+ @http.get("/api/v1/private/usage")
23
+ end
24
+
25
+ # Status of your platform API key (tier, max concurrent connections).
26
+ def api_key_status
27
+ @http.get("/api/v1/private/api-key")
28
+ end
29
+ end
30
+ end