@orth/sdk 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Orthogonal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # @orth/sdk
2
+
3
+ TypeScript SDK to call any API on the Orthogonal platform.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @orth/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import Orthogonal from "@orth/sdk";
15
+
16
+ const orthogonal = new Orthogonal({
17
+ apiKey: process.env.ORTHOGONAL_API_KEY,
18
+ });
19
+
20
+ const response = await orthogonal.run({
21
+ api: "andi",
22
+ path: "/api/v1/search",
23
+ query: { q: "what is the weather today" },
24
+ });
25
+
26
+ console.log(response.data);
27
+ console.log(response.price); // e.g., "0.01"
28
+ ```
29
+
30
+ ## Response
31
+
32
+ ### Success
33
+
34
+ ```json
35
+ {
36
+ "success": true,
37
+ "price": "0.01",
38
+ "data": { ... }
39
+ }
40
+ ```
41
+
42
+ ### Error
43
+
44
+ ```json
45
+ {
46
+ "success": false,
47
+ "price": "0",
48
+ "error": "API my-api not found or not active"
49
+ }
50
+ ```
51
+
52
+ ## License
53
+
54
+ MIT
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Configuration options for the Orthogonal client
3
+ */
4
+ interface OrthogonalConfig {
5
+ /** Your Orthogonal API key (starts with orth_live_ or orth_test_) */
6
+ apiKey: string;
7
+ }
8
+ /**
9
+ * Options for the run() method
10
+ */
11
+ interface RunOptions {
12
+ /** The API slug (e.g., "andi", "weather-api") */
13
+ api: string;
14
+ /** The endpoint path (e.g., "/api/v1/search") */
15
+ path: string;
16
+ /** Query parameters to pass to the endpoint */
17
+ query?: Record<string, unknown>;
18
+ /** Request body for POST/PUT/PATCH requests */
19
+ body?: Record<string, unknown>;
20
+ }
21
+ /**
22
+ * Response from the run() method
23
+ */
24
+ interface RunResponse {
25
+ /** Whether the request was successful */
26
+ success: boolean;
27
+ /** The price paid in USD (e.g., "0.01") */
28
+ price: string;
29
+ /** The response data from the target API */
30
+ data: unknown;
31
+ }
32
+
33
+ /**
34
+ * Orthogonal SDK client
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * import Orthogonal from "@orth/sdk";
39
+ *
40
+ * const orthogonal = new Orthogonal({
41
+ * apiKey: process.env.ORTHOGONAL_API_KEY
42
+ * });
43
+ *
44
+ * const response = await orthogonal.run({
45
+ * api: "andi",
46
+ * path: "/api/v1/search",
47
+ * query: { q: "hello world" }
48
+ * });
49
+ *
50
+ * console.log(response.data);
51
+ * ```
52
+ */
53
+ declare class Orthogonal {
54
+ private apiKey;
55
+ constructor(config: OrthogonalConfig);
56
+ /**
57
+ * Call any API on the Orthogonal platform
58
+ */
59
+ run(options: RunOptions): Promise<RunResponse>;
60
+ }
61
+
62
+ export { Orthogonal, type OrthogonalConfig, type RunOptions, type RunResponse, Orthogonal as default };
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Configuration options for the Orthogonal client
3
+ */
4
+ interface OrthogonalConfig {
5
+ /** Your Orthogonal API key (starts with orth_live_ or orth_test_) */
6
+ apiKey: string;
7
+ }
8
+ /**
9
+ * Options for the run() method
10
+ */
11
+ interface RunOptions {
12
+ /** The API slug (e.g., "andi", "weather-api") */
13
+ api: string;
14
+ /** The endpoint path (e.g., "/api/v1/search") */
15
+ path: string;
16
+ /** Query parameters to pass to the endpoint */
17
+ query?: Record<string, unknown>;
18
+ /** Request body for POST/PUT/PATCH requests */
19
+ body?: Record<string, unknown>;
20
+ }
21
+ /**
22
+ * Response from the run() method
23
+ */
24
+ interface RunResponse {
25
+ /** Whether the request was successful */
26
+ success: boolean;
27
+ /** The price paid in USD (e.g., "0.01") */
28
+ price: string;
29
+ /** The response data from the target API */
30
+ data: unknown;
31
+ }
32
+
33
+ /**
34
+ * Orthogonal SDK client
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * import Orthogonal from "@orth/sdk";
39
+ *
40
+ * const orthogonal = new Orthogonal({
41
+ * apiKey: process.env.ORTHOGONAL_API_KEY
42
+ * });
43
+ *
44
+ * const response = await orthogonal.run({
45
+ * api: "andi",
46
+ * path: "/api/v1/search",
47
+ * query: { q: "hello world" }
48
+ * });
49
+ *
50
+ * console.log(response.data);
51
+ * ```
52
+ */
53
+ declare class Orthogonal {
54
+ private apiKey;
55
+ constructor(config: OrthogonalConfig);
56
+ /**
57
+ * Call any API on the Orthogonal platform
58
+ */
59
+ run(options: RunOptions): Promise<RunResponse>;
60
+ }
61
+
62
+ export { Orthogonal, type OrthogonalConfig, type RunOptions, type RunResponse, Orthogonal as default };
package/dist/index.js ADDED
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Orthogonal: () => Orthogonal,
24
+ default: () => index_default
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var VERSION = "0.1.0";
28
+ var BASE_URL = "https://api.orth.sh";
29
+ var Orthogonal = class {
30
+ constructor(config) {
31
+ if (!config.apiKey) {
32
+ throw new Error("Orthogonal API key is required");
33
+ }
34
+ this.apiKey = config.apiKey;
35
+ }
36
+ /**
37
+ * Call any API on the Orthogonal platform
38
+ */
39
+ async run(options) {
40
+ const { api, path, query, body } = options;
41
+ const response = await fetch(`${BASE_URL}/v1/run`, {
42
+ method: "POST",
43
+ headers: {
44
+ Authorization: `Bearer ${this.apiKey}`,
45
+ "Content-Type": "application/json",
46
+ "User-Agent": `@orth/sdk/${VERSION}`
47
+ },
48
+ body: JSON.stringify({ api, path, query, body })
49
+ });
50
+ const data = await response.json();
51
+ if (!response.ok) {
52
+ if (response.status === 401) {
53
+ throw new Error("Invalid API key. Visit https://orthogonal.sh to get one!");
54
+ }
55
+ if (response.status === 402) {
56
+ throw new Error("Insufficient funds. Add USDC at https://orthogonal.sh");
57
+ }
58
+ const errorMessage = data.data?.error || data.error || `Request failed with status ${response.status}`;
59
+ throw new Error(errorMessage);
60
+ }
61
+ return data;
62
+ }
63
+ };
64
+ var index_default = Orthogonal;
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ Orthogonal
68
+ });
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { OrthogonalConfig, RunOptions, RunResponse } from \"./types\";\n\nconst VERSION = \"0.1.0\";\nconst BASE_URL = \"https://api.orth.sh\";\n\n/**\n * Orthogonal SDK client\n *\n * @example\n * ```typescript\n * import Orthogonal from \"@orth/sdk\";\n *\n * const orthogonal = new Orthogonal({\n * apiKey: process.env.ORTHOGONAL_API_KEY\n * });\n *\n * const response = await orthogonal.run({\n * api: \"andi\",\n * path: \"/api/v1/search\",\n * query: { q: \"hello world\" }\n * });\n *\n * console.log(response.data);\n * ```\n */\nexport class Orthogonal {\n private apiKey: string;\n\n constructor(config: OrthogonalConfig) {\n if (!config.apiKey) {\n throw new Error(\"Orthogonal API key is required\");\n }\n this.apiKey = config.apiKey;\n }\n\n /**\n * Call any API on the Orthogonal platform\n */\n async run(options: RunOptions): Promise<RunResponse> {\n const { api, path, query, body } = options;\n\n const response = await fetch(`${BASE_URL}/v1/run`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": `@orth/sdk/${VERSION}`,\n },\n body: JSON.stringify({ api, path, query, body }),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n // Provide helpful error messages for common cases\n if (response.status === 401) {\n throw new Error(\"Invalid API key. Visit https://orthogonal.sh to get one!\");\n }\n if (response.status === 402) {\n throw new Error(\"Insufficient funds. Add USDC at https://orthogonal.sh\");\n }\n // Check for nested error in data.error (e.g., from target API)\n const errorMessage = data.data?.error || data.error || `Request failed with status ${response.status}`;\n throw new Error(errorMessage);\n }\n\n return data as RunResponse;\n }\n}\n\n// Export types\nexport * from \"./types\";\n\n// Default export\nexport default Orthogonal;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,UAAU;AAChB,IAAM,WAAW;AAsBV,IAAM,aAAN,MAAiB;AAAA,EAGtB,YAAY,QAA0B;AACpC,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,SAAK,SAAS,OAAO;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IAAI,SAA2C;AACnD,UAAM,EAAE,KAAK,MAAM,OAAO,KAAK,IAAI;AAEnC,UAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,WAAW;AAAA,MACjD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,eAAe,UAAU,KAAK,MAAM;AAAA,QACpC,gBAAgB;AAAA,QAChB,cAAc,aAAa,OAAO;AAAA,MACpC;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,KAAK,MAAM,OAAO,KAAK,CAAC;AAAA,IACjD,CAAC;AAED,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,QAAI,CAAC,SAAS,IAAI;AAEhB,UAAI,SAAS,WAAW,KAAK;AAC3B,cAAM,IAAI,MAAM,0DAA0D;AAAA,MAC5E;AACA,UAAI,SAAS,WAAW,KAAK;AAC3B,cAAM,IAAI,MAAM,uDAAuD;AAAA,MACzE;AAEA,YAAM,eAAe,KAAK,MAAM,SAAS,KAAK,SAAS,8BAA8B,SAAS,MAAM;AACpG,YAAM,IAAI,MAAM,YAAY;AAAA,IAC9B;AAEA,WAAO;AAAA,EACT;AACF;AAMA,IAAO,gBAAQ;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,44 @@
1
+ // src/index.ts
2
+ var VERSION = "0.1.0";
3
+ var BASE_URL = "https://api.orth.sh";
4
+ var Orthogonal = class {
5
+ constructor(config) {
6
+ if (!config.apiKey) {
7
+ throw new Error("Orthogonal API key is required");
8
+ }
9
+ this.apiKey = config.apiKey;
10
+ }
11
+ /**
12
+ * Call any API on the Orthogonal platform
13
+ */
14
+ async run(options) {
15
+ const { api, path, query, body } = options;
16
+ const response = await fetch(`${BASE_URL}/v1/run`, {
17
+ method: "POST",
18
+ headers: {
19
+ Authorization: `Bearer ${this.apiKey}`,
20
+ "Content-Type": "application/json",
21
+ "User-Agent": `@orth/sdk/${VERSION}`
22
+ },
23
+ body: JSON.stringify({ api, path, query, body })
24
+ });
25
+ const data = await response.json();
26
+ if (!response.ok) {
27
+ if (response.status === 401) {
28
+ throw new Error("Invalid API key. Visit https://orthogonal.sh to get one!");
29
+ }
30
+ if (response.status === 402) {
31
+ throw new Error("Insufficient funds. Add USDC at https://orthogonal.sh");
32
+ }
33
+ const errorMessage = data.data?.error || data.error || `Request failed with status ${response.status}`;
34
+ throw new Error(errorMessage);
35
+ }
36
+ return data;
37
+ }
38
+ };
39
+ var index_default = Orthogonal;
40
+ export {
41
+ Orthogonal,
42
+ index_default as default
43
+ };
44
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { OrthogonalConfig, RunOptions, RunResponse } from \"./types\";\n\nconst VERSION = \"0.1.0\";\nconst BASE_URL = \"https://api.orth.sh\";\n\n/**\n * Orthogonal SDK client\n *\n * @example\n * ```typescript\n * import Orthogonal from \"@orth/sdk\";\n *\n * const orthogonal = new Orthogonal({\n * apiKey: process.env.ORTHOGONAL_API_KEY\n * });\n *\n * const response = await orthogonal.run({\n * api: \"andi\",\n * path: \"/api/v1/search\",\n * query: { q: \"hello world\" }\n * });\n *\n * console.log(response.data);\n * ```\n */\nexport class Orthogonal {\n private apiKey: string;\n\n constructor(config: OrthogonalConfig) {\n if (!config.apiKey) {\n throw new Error(\"Orthogonal API key is required\");\n }\n this.apiKey = config.apiKey;\n }\n\n /**\n * Call any API on the Orthogonal platform\n */\n async run(options: RunOptions): Promise<RunResponse> {\n const { api, path, query, body } = options;\n\n const response = await fetch(`${BASE_URL}/v1/run`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${this.apiKey}`,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": `@orth/sdk/${VERSION}`,\n },\n body: JSON.stringify({ api, path, query, body }),\n });\n\n const data = await response.json();\n\n if (!response.ok) {\n // Provide helpful error messages for common cases\n if (response.status === 401) {\n throw new Error(\"Invalid API key. Visit https://orthogonal.sh to get one!\");\n }\n if (response.status === 402) {\n throw new Error(\"Insufficient funds. Add USDC at https://orthogonal.sh\");\n }\n // Check for nested error in data.error (e.g., from target API)\n const errorMessage = data.data?.error || data.error || `Request failed with status ${response.status}`;\n throw new Error(errorMessage);\n }\n\n return data as RunResponse;\n }\n}\n\n// Export types\nexport * from \"./types\";\n\n// Default export\nexport default Orthogonal;\n"],"mappings":";AAEA,IAAM,UAAU;AAChB,IAAM,WAAW;AAsBV,IAAM,aAAN,MAAiB;AAAA,EAGtB,YAAY,QAA0B;AACpC,QAAI,CAAC,OAAO,QAAQ;AAClB,YAAM,IAAI,MAAM,gCAAgC;AAAA,IAClD;AACA,SAAK,SAAS,OAAO;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IAAI,SAA2C;AACnD,UAAM,EAAE,KAAK,MAAM,OAAO,KAAK,IAAI;AAEnC,UAAM,WAAW,MAAM,MAAM,GAAG,QAAQ,WAAW;AAAA,MACjD,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,eAAe,UAAU,KAAK,MAAM;AAAA,QACpC,gBAAgB;AAAA,QAChB,cAAc,aAAa,OAAO;AAAA,MACpC;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,KAAK,MAAM,OAAO,KAAK,CAAC;AAAA,IACjD,CAAC;AAED,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,QAAI,CAAC,SAAS,IAAI;AAEhB,UAAI,SAAS,WAAW,KAAK;AAC3B,cAAM,IAAI,MAAM,0DAA0D;AAAA,MAC5E;AACA,UAAI,SAAS,WAAW,KAAK;AAC3B,cAAM,IAAI,MAAM,uDAAuD;AAAA,MACzE;AAEA,YAAM,eAAe,KAAK,MAAM,SAAS,KAAK,SAAS,8BAA8B,SAAS,MAAM;AACpG,YAAM,IAAI,MAAM,YAAY;AAAA,IAC9B;AAEA,WAAO;AAAA,EACT;AACF;AAMA,IAAO,gBAAQ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@orth/sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK to call any API on the Orthogonal platform",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "sideEffects": false,
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "test": "vitest",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "keywords": [
25
+ "orthogonal",
26
+ "api",
27
+ "sdk",
28
+ "x402",
29
+ "payments",
30
+ "ai-agents"
31
+ ],
32
+ "author": "Orthogonal <founders@orthogonal.sh> (https://orthogonal.sh)",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/orthogonal-sh/orthogonal-typescript.git"
37
+ },
38
+ "homepage": "https://orthogonal.sh",
39
+ "bugs": {
40
+ "url": "https://github.com/orthogonal-sh/orthogonal-typescript/issues"
41
+ },
42
+ "engines": {
43
+ "node": ">=18"
44
+ },
45
+ "devDependencies": {
46
+ "tsup": "^8.0.0",
47
+ "tsx": "^4.21.0",
48
+ "typescript": "^5.0.0",
49
+ "vitest": "^1.0.0"
50
+ }
51
+ }