@dogabot/sdk 0.0.0-stage → 0.1.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.
@@ -0,0 +1,31 @@
1
+ /** JSON-compatible values. */
2
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
3
+ [key: string]: JsonValue;
4
+ };
5
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
6
+ export interface ClientOptions {
7
+ /** API key (`dbk_live_…`). Defaults to `process.env.DOGABOT_API_KEY`. */
8
+ apiKey?: string;
9
+ /** Defaults to `https://api.dogabot.com`. */
10
+ baseUrl?: string;
11
+ /** Optional fetch implementation (tests). */
12
+ fetch?: typeof fetch;
13
+ /** Max retries for 429/5xx (default 2). */
14
+ maxRetries?: number;
15
+ /** User-Agent override. */
16
+ userAgent?: string;
17
+ }
18
+ export interface RequestOptions {
19
+ query?: Record<string, string | number | boolean | undefined | null>;
20
+ body?: JsonValue;
21
+ headers?: Record<string, string>;
22
+ /** Required for write mutations; preferred when retrying the same intent. */
23
+ idempotencyKey?: string;
24
+ /** Internal: marks allowlist write routes. */
25
+ write?: boolean;
26
+ signal?: AbortSignal;
27
+ }
28
+ export interface APIErrorBody {
29
+ error?: string;
30
+ [key: string]: JsonValue | undefined;
31
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ # @dogabot/sdk examples (Node)
2
+
3
+ ```bash
4
+ export DOGABOT_API_KEY=dbk_live_...
5
+ # from sdk/js:
6
+ pnpm install && pnpm run build
7
+ node examples/get-me.mjs
8
+ node examples/get-ticker.mjs
9
+ node examples/list-markets.mjs
10
+ CONFIRM_PLACE=1 node examples/place-paper-order.mjs
11
+ ```
12
+
13
+ Local imports resolve via `file:..` in each example’s comment — after publish, `npm i @dogabot/sdk` and run the same scripts from any project.
14
+
15
+ Docs: https://docs.dogabot.com/sdk/
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Print the authenticated account (GET /api/v1/me).
3
+ * From sdk/js after `pnpm run build`: node examples/get-me.mjs
4
+ */
5
+ import { dirname, join } from 'node:path'
6
+ import { pathToFileURL } from 'node:url'
7
+ import { fileURLToPath } from 'node:url'
8
+
9
+ const root = join(dirname(fileURLToPath(import.meta.url)), '..')
10
+ const { Client } = await import(pathToFileURL(join(root, 'dist/index.js')).href)
11
+
12
+ if (!process.env.DOGABOT_API_KEY) {
13
+ console.error('Set DOGABOT_API_KEY=dbk_live_...')
14
+ process.exit(1)
15
+ }
16
+
17
+ const client = new Client()
18
+ console.log(JSON.stringify(await client.getMe(), null, 2))
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Fetch a ticker with query params (GET /api/v1/ticker).
3
+ * From sdk/js after `pnpm run build`: node examples/get-ticker.mjs
4
+ */
5
+ import { dirname, join } from 'node:path'
6
+ import { pathToFileURL } from 'node:url'
7
+ import { fileURLToPath } from 'node:url'
8
+
9
+ const root = join(dirname(fileURLToPath(import.meta.url)), '..')
10
+ const { Client } = await import(pathToFileURL(join(root, 'dist/index.js')).href)
11
+
12
+ if (!process.env.DOGABOT_API_KEY) {
13
+ console.error('Set DOGABOT_API_KEY=dbk_live_...')
14
+ process.exit(1)
15
+ }
16
+
17
+ const exchange = process.env.DOGABOT_EXCHANGE ?? 'hyperliquid'
18
+ const symbol = process.env.DOGABOT_SYMBOL ?? 'BTC'
19
+ const client = new Client()
20
+ const ticker = await client.resources.getTicker({
21
+ query: { exchange, symbol },
22
+ })
23
+ console.log(JSON.stringify(ticker, null, 2))
@@ -0,0 +1,21 @@
1
+ /**
2
+ * List markets with optional filters (GET /api/v1/markets).
3
+ * From sdk/js after `pnpm run build`: node examples/list-markets.mjs
4
+ */
5
+ import { dirname, join } from 'node:path'
6
+ import { pathToFileURL } from 'node:url'
7
+ import { fileURLToPath } from 'node:url'
8
+
9
+ const root = join(dirname(fileURLToPath(import.meta.url)), '..')
10
+ const { Client } = await import(pathToFileURL(join(root, 'dist/index.js')).href)
11
+
12
+ if (!process.env.DOGABOT_API_KEY) {
13
+ console.error('Set DOGABOT_API_KEY=dbk_live_...')
14
+ process.exit(1)
15
+ }
16
+
17
+ const client = new Client()
18
+ const markets = await client.resources.getMarkets({
19
+ query: { limit: 5, is_tradable: true },
20
+ })
21
+ console.log(JSON.stringify(markets, null, 2))
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Place a tiny paper market order (Idempotency-Key required).
3
+ * Dry-run unless CONFIRM_PLACE=1. trading_mode stays paper.
4
+ * From sdk/js after `pnpm run build`: CONFIRM_PLACE=1 node examples/place-paper-order.mjs
5
+ */
6
+ import { randomUUID } from 'node:crypto'
7
+ import { dirname, join } from 'node:path'
8
+ import { pathToFileURL } from 'node:url'
9
+ import { fileURLToPath } from 'node:url'
10
+
11
+ const root = join(dirname(fileURLToPath(import.meta.url)), '..')
12
+ const { Client } = await import(pathToFileURL(join(root, 'dist/index.js')).href)
13
+
14
+ if (!process.env.DOGABOT_API_KEY) {
15
+ console.error('Set DOGABOT_API_KEY=dbk_live_...')
16
+ process.exit(1)
17
+ }
18
+
19
+ const body = {
20
+ exchange: process.env.DOGABOT_EXCHANGE ?? 'hyperliquid',
21
+ symbol: process.env.DOGABOT_SYMBOL ?? 'BTC',
22
+ side: 'buy',
23
+ quantity: 0.001,
24
+ order_type: 'market',
25
+ trading_mode: 'paper',
26
+ broadcast_mode: 'personal',
27
+ }
28
+ const idempotencyKey = process.env.DOGABOT_IDEMPOTENCY_KEY ?? `example-paper-${randomUUID()}`
29
+
30
+ if (process.env.CONFIRM_PLACE !== '1') {
31
+ console.log('Dry-run only. Would POST placeorder with:')
32
+ console.log(JSON.stringify({ body, idempotencyKey }, null, 2))
33
+ console.log('Re-run with CONFIRM_PLACE=1 to submit (still paper).')
34
+ process.exit(0)
35
+ }
36
+
37
+ const client = new Client()
38
+ const out = await client.resources.postTerminalPlaceorder(body, { idempotencyKey })
39
+ console.log(JSON.stringify(out, null, 2))
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "@dogabot/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Official dogabot REST API SDK for JavaScript/TypeScript (backend-first)",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "examples",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "test": "vitest run",
22
+ "prepublishOnly": "npm run build",
23
+ "prepare": "npm run build"
24
+ },
25
+ "engines": {
26
+ "node": ">=20"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^22.13.10",
33
+ "typescript": "^5.8.2",
34
+ "vitest": "^3.0.9"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/dogabot/dogabot-sdk-js.git"
39
+ },
40
+ "license": "MIT",
41
+ "keywords": [
42
+ "dogabot",
43
+ "trading",
44
+ "sdk",
45
+ "api"
46
+ ]
47
+ }