@alpaca-open-api/core 0.1.0-rc.0 → 1.0.1

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.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ <h1 align="center">🦙 @alpaca-open-api/core</h1>
2
+
3
+ <p align="center">Typed TypeScript fetch clients + model types for the <a href="https://alpaca.markets/">Alpaca Markets</a> API (Trading, Market Data, Broker, AuthX), generated from the official OpenAPI specs with <a href="https://orval.dev/">Orval</a>.</p>
4
+
5
+ <p align="center">
6
+ <a href="https://www.npmjs.com/package/@alpaca-open-api/core"><img src="https://img.shields.io/npm/v/@alpaca-open-api/core?logo=npm&color=CB3837" alt="npm"></a>
7
+ <a href="https://github.com/yagop/alpaca-open-api/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="license: MIT"></a>
8
+ </p>
9
+
10
+ - ⚡ Fully typed request/response types straight from the specs.
11
+ - 🛰️ One namespace per API: `tradingApi`, `dataApi`, `brokerApi`, `authxApi`.
12
+ - 🔒 Every call routes through one small shared mutator that resolves host + auth per API.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install @alpaca-open-api/core
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Credentials and environment come from env vars (`ALPACA_API_KEY`, `ALPACA_API_SECRET`, `ALPACA_ENV`; **live by default**), read by the shared mutator.
23
+
24
+ ```ts
25
+ import { tradingApi, dataApi, tradingModel } from '@alpaca-open-api/core';
26
+
27
+ // Each call returns { data, status, headers }; `data` is typed from the spec.
28
+ const { data: account } = await tradingApi.getAccount();
29
+ console.log(account?.cash);
30
+
31
+ const { data: quote } = await dataApi.stockLatestQuoteSingle('AAPL', { feed: 'iex' });
32
+ console.log(quote?.quote?.ap);
33
+
34
+ // Place an order (uses the live account unless ALPACA_ENV=paper):
35
+ await tradingApi.postOrder({ symbol: 'AAPL', side: 'buy', qty: '1', type: 'market', time_in_force: 'day' });
36
+
37
+ // Schema types are exported per API as `*Model` namespaces:
38
+ type Account = tradingModel.Account;
39
+ ```
40
+
41
+ Client namespaces: `tradingApi`, `dataApi`, `brokerApi`, `authxApi`; matching model (schema) types: `tradingModel`, `dataModel`, `brokerModel`, `authxModel`. `makeMutator` and `API_ROUTING` are also exported if you need to customize routing.
42
+
43
+ ## Configuration
44
+
45
+ | Variable | Required | Default | Purpose |
46
+ | --- | :---: | --- | --- |
47
+ | `ALPACA_API_KEY` | ✅ | — | API key (live and paper keys are different) |
48
+ | `ALPACA_API_SECRET` | ✅ | — | API secret |
49
+ | `ALPACA_ENV` | | `live` | `paper` or `live`. Selects paper/live (trading) and sandbox/production (broker, authx). |
50
+
51
+ > ⚠️ Defaults to **`live`** (real money/orders). Set `ALPACA_ENV=paper` (with your paper keys) to test safely.
52
+
53
+ ## Documentation
54
+
55
+ Full docs, the MCP server ([`@alpaca-open-api/mcp`](https://www.npmjs.com/package/@alpaca-open-api/mcp)), and source:
56
+ **https://github.com/yagop/alpaca-open-api**
57
+
58
+ ## Disclaimer
59
+
60
+ Unofficial and **not affiliated with, endorsed by, or sponsored by Alpaca**. Provided "as is", without warranty of any kind. Nothing here is financial, investment, or trading advice. Trading involves substantial risk of loss — always test with paper trading (`ALPACA_ENV=paper`) first.
61
+
62
+ ## License
63
+
64
+ [MIT](https://github.com/yagop/alpaca-open-api/blob/main/LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpaca-open-api/core",
3
- "version": "0.1.0-rc.0",
3
+ "version": "1.0.1",
4
4
  "description": "Typed fetch clients and types for the Alpaca Markets API, generated from the official OpenAPI specifications with Orval",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,11 +33,11 @@
33
33
  "license": "MIT",
34
34
  "repository": {
35
35
  "type": "git",
36
- "url": "git+https://github.com/yagop/alpaca-api-ts.git",
36
+ "url": "git+https://github.com/yagop/alpaca-open-api.git",
37
37
  "directory": "packages/core"
38
38
  },
39
- "homepage": "https://github.com/yagop/alpaca-api-ts#readme",
40
- "bugs": "https://github.com/yagop/alpaca-api-ts/issues",
39
+ "homepage": "https://github.com/yagop/alpaca-open-api#readme",
40
+ "bugs": "https://github.com/yagop/alpaca-open-api/issues",
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
@@ -1,20 +0,0 @@
1
- /**
2
- * Generated by orval v8.15.0 🍺
3
- * Do not edit manually.
4
- * Broker API
5
- * Open brokerage accounts, enable stock, options and crypto trading. Manage the ongoing user experience and brokerage customer lifecycle with the Alpaca Broker API
6
- * OpenAPI spec version: 1.1.1
7
- */
8
- /**
9
- * Only `immediate` is currently supported.
10
- *
11
- * values:
12
- *
13
- * - **immediate**
14
- *
15
- * - **next_day**
16
- */
17
- export type TransferTiming = typeof TransferTiming[keyof typeof TransferTiming];
18
- export declare const TransferTiming: {
19
- readonly immediate: "immediate";
20
- };