klickanalytics-cli 0.1.0__tar.gz

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KlickAnalytics
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.
@@ -0,0 +1,304 @@
1
+ Metadata-Version: 2.4
2
+ Name: klickanalytics-cli
3
+ Version: 0.1.0
4
+ Summary: Official CLI for KlickAnalytics APIs
5
+ Author-email: KlickAnalytics <support@klickanalytics.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.klickanalytics.com
8
+ Project-URL: Documentation, https://www.klickanalytics.com/cli_documentation.php
9
+ Keywords: finance,stocks,cli,market-data,klickanalytics,agents,api
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Office/Business :: Financial
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: requests>=2.31.0
21
+ Dynamic: license-file
22
+
23
+ # KlickAnalytics CLI
24
+
25
+ **Financial market intelligence from your terminal, scripts, and AI agents.**
26
+
27
+ KlickAnalytics CLI provides a simple way for developers, traders, researchers, and AI systems to access financial market data directly from the command line.
28
+
29
+ Instead of writing API requests manually, you can retrieve structured financial data instantly.
30
+
31
+ Example:
32
+
33
+ ```bash
34
+ ka profile -s TSLA
35
+ ka quote -s NVDA
36
+ ka prices -s AAPL -sd 2025-01-01 -ed 2025-12-31
37
+ ka quantstats -s MSFT
38
+ ```
39
+
40
+ ---
41
+
42
+ # Why KlickAnalytics CLI?
43
+
44
+ Most financial API workflows involve unnecessary friction:
45
+
46
+ - writing HTTP request code
47
+ - building authentication headers
48
+ - managing JSON parsing
49
+ - creating repetitive scripts
50
+ - integrating APIs with agents or automation pipelines
51
+
52
+ KlickAnalytics CLI removes that friction by acting as a thin client that connects directly to the KlickAnalytics API platform.
53
+
54
+ Benefits:
55
+
56
+ - extremely simple command interface
57
+ - direct integration with your terminal
58
+ - easy automation via scripts
59
+ - agent-friendly JSON output
60
+ - server-driven command routing
61
+ - future commands added without updating the CLI
62
+
63
+ ---
64
+
65
+ # Built for Developers and AI Agents
66
+
67
+ KlickAnalytics CLI is designed to integrate easily with modern development and automation workflows.
68
+
69
+ It works well with:
70
+
71
+ - local shell scripts
72
+ - Python pipelines
73
+ - research tools
74
+ - cron jobs
75
+ - AI agents
76
+ - OpenClaw-style systems
77
+ - MCP servers
78
+ - local developer tools
79
+ - automation pipelines
80
+
81
+ Because the CLI supports structured JSON output, agents can consume financial data without writing API wrappers.
82
+
83
+ Example:
84
+
85
+ ```bash
86
+ ka --json quote -s MSFT
87
+ ```
88
+
89
+ This allows AI tools or scripts to receive structured responses instantly.
90
+
91
+ ---
92
+
93
+ # Installation
94
+
95
+ Install from PyPI:
96
+
97
+ ```bash
98
+ pip install klickanalytics-cli
99
+ ```
100
+
101
+ After installation, the `ka` command becomes available globally.
102
+
103
+ ---
104
+
105
+ # Setting Your API Key
106
+
107
+ Create your account and generate your CLI API key in seconds.
108
+
109
+ ## Steps
110
+
111
+ 1. **Register a free account**
112
+
113
+ 👉 https://klickanalytics.com/signup
114
+
115
+ 2. **Generate your API key**
116
+
117
+ 👉 https://klickanalytics.com/user_apis
118
+
119
+ 3. **Export your API key**
120
+
121
+ ```bash
122
+ export KLICKANALYTICS_CLI_API_KEY="your_api_key_here"
123
+ ```
124
+
125
+ A fallback environment variable is also supported:
126
+
127
+ ```bash
128
+ export KA_API_KEY="your_api_key_here"
129
+ ```
130
+
131
+ ---
132
+
133
+ # Basic Usage
134
+
135
+ Display help:
136
+
137
+ ```bash
138
+ ka help
139
+ ```
140
+
141
+ List commands:
142
+
143
+ ```bash
144
+ ka commands
145
+ ```
146
+
147
+ Retrieve symbol profile:
148
+
149
+ ```bash
150
+ ka profile -s TSLA
151
+ ```
152
+
153
+ Get latest quote:
154
+
155
+ ```bash
156
+ ka quote -s TSLA
157
+ ```
158
+
159
+ Retrieve historical prices:
160
+
161
+ ```bash
162
+ ka prices -s TSLA -sd 2025-01-01 -ed 2025-12-31
163
+ ```
164
+
165
+ ---
166
+
167
+ # JSON Output
168
+
169
+ For scripts, automation, and AI workflows, you can request JSON output:
170
+
171
+ ```bash
172
+ ka --json profile -s NVDA
173
+ ```
174
+
175
+ Example output:
176
+
177
+ ```json
178
+ {
179
+ "symbol": "NVDA",
180
+ "name": "NVIDIA Corporation",
181
+ "sector": "Technology"
182
+ }
183
+ ```
184
+
185
+ ---
186
+
187
+ # Local Development
188
+
189
+ To connect the CLI to a local or staging API server:
190
+
191
+ ```bash
192
+ export KA_DEV_ENDPOINT="http://127.0.0.1:8000/cli"
193
+ ```
194
+
195
+ This allows you to test new commands or endpoints locally.
196
+
197
+ ---
198
+
199
+ # Protocol Version
200
+
201
+ Optional protocol version override:
202
+
203
+ ```bash
204
+ export KA_PROTO=v1
205
+ ```
206
+
207
+ Or specify at runtime:
208
+
209
+ ```bash
210
+ ka --version v2 profile -s TSLA
211
+ ```
212
+
213
+ ---
214
+
215
+ # Example Workflows
216
+
217
+ ## Shell Automation
218
+
219
+ ```bash
220
+ for s in AAPL MSFT NVDA TSLA
221
+ do
222
+ ka quote -s $s
223
+ done
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Data Pipeline
229
+
230
+ ```bash
231
+ ka --json prices -s NVDA > prices.json
232
+ ```
233
+
234
+ ---
235
+
236
+ ## AI Agent Workflow
237
+
238
+ ```bash
239
+ ka --json volatility -s NVDA -sd 2025-01-01 -ed 2025-12-31
240
+ ```
241
+
242
+ The structured output can be consumed directly by:
243
+
244
+ - AI agents
245
+ - Python scripts
246
+ - automation workers
247
+ - research pipelines
248
+
249
+ ---
250
+
251
+ # Environment Variables
252
+
253
+ | Variable | Description |
254
+ |---------|-------------|
255
+ | KLICKANALYTICS_CLI_API_KEY | API key for CLI authentication |
256
+ | KA_API_KEY | fallback API key |
257
+ | KA_DEV_ENDPOINT | optional local/staging API endpoint |
258
+ | KA_PROTO | protocol version override |
259
+
260
+ ---
261
+
262
+ # Design Philosophy
263
+
264
+ The CLI intentionally stays lightweight.
265
+
266
+ The client does **not hardcode commands locally**. Instead:
267
+
268
+ - commands are forwarded to the server
269
+ - the server validates and routes them
270
+ - authentication is handled server-side
271
+ - new commands can be added without updating the CLI
272
+
273
+ This architecture keeps the CLI simple and future-proof.
274
+
275
+ ---
276
+
277
+ # Development Install
278
+
279
+ Clone the repository:
280
+
281
+ ```bash
282
+ git clone https://github.com/klickanalytics/klickanalytics-cli.git
283
+ cd klickanalytics-cli
284
+ ```
285
+
286
+ Install locally:
287
+
288
+ ```bash
289
+ pip install -e .
290
+ ```
291
+
292
+ ---
293
+
294
+ # Documentation
295
+
296
+ Full CLI documentation:
297
+
298
+ https://www.klickanalytics.com/cli_documentation
299
+
300
+ ---
301
+
302
+ # License
303
+
304
+ MIT License
@@ -0,0 +1,282 @@
1
+ # KlickAnalytics CLI
2
+
3
+ **Financial market intelligence from your terminal, scripts, and AI agents.**
4
+
5
+ KlickAnalytics CLI provides a simple way for developers, traders, researchers, and AI systems to access financial market data directly from the command line.
6
+
7
+ Instead of writing API requests manually, you can retrieve structured financial data instantly.
8
+
9
+ Example:
10
+
11
+ ```bash
12
+ ka profile -s TSLA
13
+ ka quote -s NVDA
14
+ ka prices -s AAPL -sd 2025-01-01 -ed 2025-12-31
15
+ ka quantstats -s MSFT
16
+ ```
17
+
18
+ ---
19
+
20
+ # Why KlickAnalytics CLI?
21
+
22
+ Most financial API workflows involve unnecessary friction:
23
+
24
+ - writing HTTP request code
25
+ - building authentication headers
26
+ - managing JSON parsing
27
+ - creating repetitive scripts
28
+ - integrating APIs with agents or automation pipelines
29
+
30
+ KlickAnalytics CLI removes that friction by acting as a thin client that connects directly to the KlickAnalytics API platform.
31
+
32
+ Benefits:
33
+
34
+ - extremely simple command interface
35
+ - direct integration with your terminal
36
+ - easy automation via scripts
37
+ - agent-friendly JSON output
38
+ - server-driven command routing
39
+ - future commands added without updating the CLI
40
+
41
+ ---
42
+
43
+ # Built for Developers and AI Agents
44
+
45
+ KlickAnalytics CLI is designed to integrate easily with modern development and automation workflows.
46
+
47
+ It works well with:
48
+
49
+ - local shell scripts
50
+ - Python pipelines
51
+ - research tools
52
+ - cron jobs
53
+ - AI agents
54
+ - OpenClaw-style systems
55
+ - MCP servers
56
+ - local developer tools
57
+ - automation pipelines
58
+
59
+ Because the CLI supports structured JSON output, agents can consume financial data without writing API wrappers.
60
+
61
+ Example:
62
+
63
+ ```bash
64
+ ka --json quote -s MSFT
65
+ ```
66
+
67
+ This allows AI tools or scripts to receive structured responses instantly.
68
+
69
+ ---
70
+
71
+ # Installation
72
+
73
+ Install from PyPI:
74
+
75
+ ```bash
76
+ pip install klickanalytics-cli
77
+ ```
78
+
79
+ After installation, the `ka` command becomes available globally.
80
+
81
+ ---
82
+
83
+ # Setting Your API Key
84
+
85
+ Create your account and generate your CLI API key in seconds.
86
+
87
+ ## Steps
88
+
89
+ 1. **Register a free account**
90
+
91
+ 👉 https://klickanalytics.com/signup
92
+
93
+ 2. **Generate your API key**
94
+
95
+ 👉 https://klickanalytics.com/user_apis
96
+
97
+ 3. **Export your API key**
98
+
99
+ ```bash
100
+ export KLICKANALYTICS_CLI_API_KEY="your_api_key_here"
101
+ ```
102
+
103
+ A fallback environment variable is also supported:
104
+
105
+ ```bash
106
+ export KA_API_KEY="your_api_key_here"
107
+ ```
108
+
109
+ ---
110
+
111
+ # Basic Usage
112
+
113
+ Display help:
114
+
115
+ ```bash
116
+ ka help
117
+ ```
118
+
119
+ List commands:
120
+
121
+ ```bash
122
+ ka commands
123
+ ```
124
+
125
+ Retrieve symbol profile:
126
+
127
+ ```bash
128
+ ka profile -s TSLA
129
+ ```
130
+
131
+ Get latest quote:
132
+
133
+ ```bash
134
+ ka quote -s TSLA
135
+ ```
136
+
137
+ Retrieve historical prices:
138
+
139
+ ```bash
140
+ ka prices -s TSLA -sd 2025-01-01 -ed 2025-12-31
141
+ ```
142
+
143
+ ---
144
+
145
+ # JSON Output
146
+
147
+ For scripts, automation, and AI workflows, you can request JSON output:
148
+
149
+ ```bash
150
+ ka --json profile -s NVDA
151
+ ```
152
+
153
+ Example output:
154
+
155
+ ```json
156
+ {
157
+ "symbol": "NVDA",
158
+ "name": "NVIDIA Corporation",
159
+ "sector": "Technology"
160
+ }
161
+ ```
162
+
163
+ ---
164
+
165
+ # Local Development
166
+
167
+ To connect the CLI to a local or staging API server:
168
+
169
+ ```bash
170
+ export KA_DEV_ENDPOINT="http://127.0.0.1:8000/cli"
171
+ ```
172
+
173
+ This allows you to test new commands or endpoints locally.
174
+
175
+ ---
176
+
177
+ # Protocol Version
178
+
179
+ Optional protocol version override:
180
+
181
+ ```bash
182
+ export KA_PROTO=v1
183
+ ```
184
+
185
+ Or specify at runtime:
186
+
187
+ ```bash
188
+ ka --version v2 profile -s TSLA
189
+ ```
190
+
191
+ ---
192
+
193
+ # Example Workflows
194
+
195
+ ## Shell Automation
196
+
197
+ ```bash
198
+ for s in AAPL MSFT NVDA TSLA
199
+ do
200
+ ka quote -s $s
201
+ done
202
+ ```
203
+
204
+ ---
205
+
206
+ ## Data Pipeline
207
+
208
+ ```bash
209
+ ka --json prices -s NVDA > prices.json
210
+ ```
211
+
212
+ ---
213
+
214
+ ## AI Agent Workflow
215
+
216
+ ```bash
217
+ ka --json volatility -s NVDA -sd 2025-01-01 -ed 2025-12-31
218
+ ```
219
+
220
+ The structured output can be consumed directly by:
221
+
222
+ - AI agents
223
+ - Python scripts
224
+ - automation workers
225
+ - research pipelines
226
+
227
+ ---
228
+
229
+ # Environment Variables
230
+
231
+ | Variable | Description |
232
+ |---------|-------------|
233
+ | KLICKANALYTICS_CLI_API_KEY | API key for CLI authentication |
234
+ | KA_API_KEY | fallback API key |
235
+ | KA_DEV_ENDPOINT | optional local/staging API endpoint |
236
+ | KA_PROTO | protocol version override |
237
+
238
+ ---
239
+
240
+ # Design Philosophy
241
+
242
+ The CLI intentionally stays lightweight.
243
+
244
+ The client does **not hardcode commands locally**. Instead:
245
+
246
+ - commands are forwarded to the server
247
+ - the server validates and routes them
248
+ - authentication is handled server-side
249
+ - new commands can be added without updating the CLI
250
+
251
+ This architecture keeps the CLI simple and future-proof.
252
+
253
+ ---
254
+
255
+ # Development Install
256
+
257
+ Clone the repository:
258
+
259
+ ```bash
260
+ git clone https://github.com/klickanalytics/klickanalytics-cli.git
261
+ cd klickanalytics-cli
262
+ ```
263
+
264
+ Install locally:
265
+
266
+ ```bash
267
+ pip install -e .
268
+ ```
269
+
270
+ ---
271
+
272
+ # Documentation
273
+
274
+ Full CLI documentation:
275
+
276
+ https://www.klickanalytics.com/cli_documentation
277
+
278
+ ---
279
+
280
+ # License
281
+
282
+ MIT License
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "klickanalytics-cli"
7
+ version = "0.1.0"
8
+ description = "Official CLI for KlickAnalytics APIs"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "KlickAnalytics", email = "support@klickanalytics.com" }
14
+ ]
15
+ keywords = ["finance", "stocks", "cli", "market-data", "klickanalytics", "agents", "api"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Topic :: Office/Business :: Financial",
23
+ "Topic :: Software Development :: Libraries :: Python Modules"
24
+ ]
25
+ dependencies = [
26
+ "requests>=2.31.0"
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://www.klickanalytics.com"
31
+ Documentation = "https://www.klickanalytics.com/cli_documentation.php"
32
+
33
+ [project.scripts]
34
+ ka = "klickanalytics_cli.ka_cli:main"
35
+
36
+ [tool.setuptools]
37
+ package-dir = {"" = "src"}
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -0,0 +1,208 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ KlickAnalytics CLI
4
+
5
+ Examples:
6
+ ka help
7
+ ka commands
8
+ ka profile -s TSLA
9
+ ka quote -s TSLA
10
+ ka prices -s TSLA -sd 2025-01-01 -ed 2025-12-31
11
+
12
+ Environment:
13
+ KLICKANALYTICS_CLI_API_KEY API key for CLI access
14
+ KA_DEV_ENDPOINT Optional override endpoint for local/dev
15
+ KA_PROTO Optional protocol version override (v1 or v2)
16
+ """
17
+
18
+ from __future__ import annotations
19
+
20
+ import json
21
+ import os
22
+ import sys
23
+ from typing import Optional, Dict, Any, List, Tuple
24
+
25
+ import requests
26
+
27
+ DEFAULT_ENDPOINT = "https://api.klickanalytics.com/cli"
28
+ CLI_VERSION = "0.1.0"
29
+
30
+
31
+ def endpoint() -> str:
32
+ val = (os.environ.get("KA_DEV_ENDPOINT") or DEFAULT_ENDPOINT).strip()
33
+ return val.rstrip("/")
34
+
35
+
36
+ def detect_proto_default() -> str:
37
+ proto = (os.environ.get("KA_PROTO") or "v1").strip().lower()
38
+ if proto in ("v1", "1"):
39
+ return "v1"
40
+ if proto in ("v2", "2"):
41
+ return "v2"
42
+ return "v1"
43
+
44
+
45
+ def get_api_key() -> str:
46
+ return (
47
+ os.environ.get("KLICKANALYTICS_CLI_API_KEY")
48
+ or os.environ.get("KA_API_KEY")
49
+ or ""
50
+ ).strip()
51
+
52
+
53
+ def read_stdin_if_piped() -> Optional[str]:
54
+ if sys.stdin is None or sys.stdin.isatty():
55
+ return None
56
+ try:
57
+ return sys.stdin.read()
58
+ except Exception:
59
+ return None
60
+
61
+
62
+ def strip_local_flags(argv: List[str]) -> Tuple[List[str], bool, Optional[str]]:
63
+ """
64
+ Client-side flags handled locally:
65
+ --json
66
+ --version <v1|v2>
67
+
68
+ Everything else is forwarded to server unchanged.
69
+ """
70
+ want_json = False
71
+ proto = None
72
+ out: List[str] = []
73
+
74
+ i = 0
75
+ while i < len(argv):
76
+ a = argv[i]
77
+
78
+ if a == "--json":
79
+ want_json = True
80
+ i += 1
81
+ continue
82
+
83
+ if a == "--version":
84
+ if i + 1 >= len(argv):
85
+ sys.stderr.write("Error: --version requires a value (v1 or v2)\n")
86
+ sys.exit(2)
87
+
88
+ proto = argv[i + 1].strip().lower()
89
+ if proto == "1":
90
+ proto = "v1"
91
+ elif proto == "2":
92
+ proto = "v2"
93
+ elif proto not in ("v1", "v2"):
94
+ sys.stderr.write("Error: --version must be v1 or v2\n")
95
+ sys.exit(2)
96
+
97
+ i += 2
98
+ continue
99
+
100
+ out.append(a)
101
+ i += 1
102
+
103
+ return out, want_json, proto
104
+
105
+
106
+ def call_server(
107
+ argv_forward: List[str],
108
+ stdin: Optional[str],
109
+ want_json: bool,
110
+ proto: Optional[str],
111
+ ) -> Dict[str, Any]:
112
+ api_key = get_api_key()
113
+
114
+ headers = {
115
+ "Accept": "application/json",
116
+ "Content-Type": "application/json",
117
+ "User-Agent": f"klickanalytics-cli/{CLI_VERSION}",
118
+ }
119
+
120
+ if api_key:
121
+ headers["KLICKANALYTICS-CLI-API-KEY"] = api_key
122
+
123
+ if not argv_forward:
124
+ argv_forward = ["help"]
125
+
126
+ payload = {
127
+ "argv": argv_forward,
128
+ "raw": " ".join(argv_forward),
129
+ "stdin": stdin,
130
+ "proto": proto or detect_proto_default(),
131
+ "want": "json" if want_json else "text",
132
+ "client": {
133
+ "cli": "klickanalytics-cli",
134
+ "cli_version": CLI_VERSION,
135
+ "platform": sys.platform,
136
+ "python": sys.version.split()[0],
137
+ },
138
+ }
139
+
140
+ r = requests.post(endpoint(), json=payload, headers=headers, timeout=60)
141
+ r.raise_for_status()
142
+ return r.json()
143
+
144
+
145
+ def print_response(resp: Dict[str, Any], want_json: bool) -> None:
146
+ if resp.get("stderr"):
147
+ sys.stderr.write(str(resp["stderr"]))
148
+
149
+ exit_code = int(resp.get("exit_code", 0))
150
+
151
+ if want_json:
152
+ if resp.get("data") is not None:
153
+ sys.stdout.write(json.dumps(resp["data"], indent=2) + "\n")
154
+ else:
155
+ sys.stdout.write(json.dumps(resp, indent=2) + "\n")
156
+ sys.exit(exit_code)
157
+
158
+ if resp.get("stdout"):
159
+ sys.stdout.write(str(resp["stdout"]))
160
+ elif resp.get("data") is not None:
161
+ sys.stdout.write(json.dumps(resp["data"], indent=2) + "\n")
162
+ else:
163
+ sys.stdout.write(json.dumps(resp, indent=2) + "\n")
164
+
165
+ sys.exit(exit_code)
166
+
167
+
168
+ def main() -> None:
169
+ argv_forward, want_json, proto = strip_local_flags(sys.argv[1:])
170
+ stdin_data = read_stdin_if_piped()
171
+
172
+ try:
173
+ resp = call_server(
174
+ argv_forward=argv_forward,
175
+ stdin=stdin_data,
176
+ want_json=want_json,
177
+ proto=proto,
178
+ )
179
+ except requests.exceptions.ConnectionError:
180
+ sys.stderr.write(
181
+ "ConnectionError: cannot reach KlickAnalytics endpoint.\n"
182
+ f"Endpoint: {endpoint()}\n\n"
183
+ )
184
+ sys.exit(1)
185
+ except requests.exceptions.Timeout:
186
+ sys.stderr.write("Timeout: server took too long to respond.\n")
187
+ sys.exit(1)
188
+ except requests.HTTPError as e:
189
+ body = ""
190
+ try:
191
+ body = e.response.text if e.response is not None else ""
192
+ except Exception:
193
+ pass
194
+
195
+ sys.stderr.write(f"HTTPError: {e}\n")
196
+ if body:
197
+ sys.stderr.write(body + "\n")
198
+ sys.stderr.write(f"Endpoint: {endpoint()}\n")
199
+ sys.exit(1)
200
+ except Exception as e:
201
+ sys.stderr.write(f"Unexpected error: {e}\n")
202
+ sys.exit(1)
203
+
204
+ print_response(resp, want_json)
205
+
206
+
207
+ if __name__ == "__main__":
208
+ main()
@@ -0,0 +1,304 @@
1
+ Metadata-Version: 2.4
2
+ Name: klickanalytics-cli
3
+ Version: 0.1.0
4
+ Summary: Official CLI for KlickAnalytics APIs
5
+ Author-email: KlickAnalytics <support@klickanalytics.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.klickanalytics.com
8
+ Project-URL: Documentation, https://www.klickanalytics.com/cli_documentation.php
9
+ Keywords: finance,stocks,cli,market-data,klickanalytics,agents,api
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Office/Business :: Financial
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: requests>=2.31.0
21
+ Dynamic: license-file
22
+
23
+ # KlickAnalytics CLI
24
+
25
+ **Financial market intelligence from your terminal, scripts, and AI agents.**
26
+
27
+ KlickAnalytics CLI provides a simple way for developers, traders, researchers, and AI systems to access financial market data directly from the command line.
28
+
29
+ Instead of writing API requests manually, you can retrieve structured financial data instantly.
30
+
31
+ Example:
32
+
33
+ ```bash
34
+ ka profile -s TSLA
35
+ ka quote -s NVDA
36
+ ka prices -s AAPL -sd 2025-01-01 -ed 2025-12-31
37
+ ka quantstats -s MSFT
38
+ ```
39
+
40
+ ---
41
+
42
+ # Why KlickAnalytics CLI?
43
+
44
+ Most financial API workflows involve unnecessary friction:
45
+
46
+ - writing HTTP request code
47
+ - building authentication headers
48
+ - managing JSON parsing
49
+ - creating repetitive scripts
50
+ - integrating APIs with agents or automation pipelines
51
+
52
+ KlickAnalytics CLI removes that friction by acting as a thin client that connects directly to the KlickAnalytics API platform.
53
+
54
+ Benefits:
55
+
56
+ - extremely simple command interface
57
+ - direct integration with your terminal
58
+ - easy automation via scripts
59
+ - agent-friendly JSON output
60
+ - server-driven command routing
61
+ - future commands added without updating the CLI
62
+
63
+ ---
64
+
65
+ # Built for Developers and AI Agents
66
+
67
+ KlickAnalytics CLI is designed to integrate easily with modern development and automation workflows.
68
+
69
+ It works well with:
70
+
71
+ - local shell scripts
72
+ - Python pipelines
73
+ - research tools
74
+ - cron jobs
75
+ - AI agents
76
+ - OpenClaw-style systems
77
+ - MCP servers
78
+ - local developer tools
79
+ - automation pipelines
80
+
81
+ Because the CLI supports structured JSON output, agents can consume financial data without writing API wrappers.
82
+
83
+ Example:
84
+
85
+ ```bash
86
+ ka --json quote -s MSFT
87
+ ```
88
+
89
+ This allows AI tools or scripts to receive structured responses instantly.
90
+
91
+ ---
92
+
93
+ # Installation
94
+
95
+ Install from PyPI:
96
+
97
+ ```bash
98
+ pip install klickanalytics-cli
99
+ ```
100
+
101
+ After installation, the `ka` command becomes available globally.
102
+
103
+ ---
104
+
105
+ # Setting Your API Key
106
+
107
+ Create your account and generate your CLI API key in seconds.
108
+
109
+ ## Steps
110
+
111
+ 1. **Register a free account**
112
+
113
+ 👉 https://klickanalytics.com/signup
114
+
115
+ 2. **Generate your API key**
116
+
117
+ 👉 https://klickanalytics.com/user_apis
118
+
119
+ 3. **Export your API key**
120
+
121
+ ```bash
122
+ export KLICKANALYTICS_CLI_API_KEY="your_api_key_here"
123
+ ```
124
+
125
+ A fallback environment variable is also supported:
126
+
127
+ ```bash
128
+ export KA_API_KEY="your_api_key_here"
129
+ ```
130
+
131
+ ---
132
+
133
+ # Basic Usage
134
+
135
+ Display help:
136
+
137
+ ```bash
138
+ ka help
139
+ ```
140
+
141
+ List commands:
142
+
143
+ ```bash
144
+ ka commands
145
+ ```
146
+
147
+ Retrieve symbol profile:
148
+
149
+ ```bash
150
+ ka profile -s TSLA
151
+ ```
152
+
153
+ Get latest quote:
154
+
155
+ ```bash
156
+ ka quote -s TSLA
157
+ ```
158
+
159
+ Retrieve historical prices:
160
+
161
+ ```bash
162
+ ka prices -s TSLA -sd 2025-01-01 -ed 2025-12-31
163
+ ```
164
+
165
+ ---
166
+
167
+ # JSON Output
168
+
169
+ For scripts, automation, and AI workflows, you can request JSON output:
170
+
171
+ ```bash
172
+ ka --json profile -s NVDA
173
+ ```
174
+
175
+ Example output:
176
+
177
+ ```json
178
+ {
179
+ "symbol": "NVDA",
180
+ "name": "NVIDIA Corporation",
181
+ "sector": "Technology"
182
+ }
183
+ ```
184
+
185
+ ---
186
+
187
+ # Local Development
188
+
189
+ To connect the CLI to a local or staging API server:
190
+
191
+ ```bash
192
+ export KA_DEV_ENDPOINT="http://127.0.0.1:8000/cli"
193
+ ```
194
+
195
+ This allows you to test new commands or endpoints locally.
196
+
197
+ ---
198
+
199
+ # Protocol Version
200
+
201
+ Optional protocol version override:
202
+
203
+ ```bash
204
+ export KA_PROTO=v1
205
+ ```
206
+
207
+ Or specify at runtime:
208
+
209
+ ```bash
210
+ ka --version v2 profile -s TSLA
211
+ ```
212
+
213
+ ---
214
+
215
+ # Example Workflows
216
+
217
+ ## Shell Automation
218
+
219
+ ```bash
220
+ for s in AAPL MSFT NVDA TSLA
221
+ do
222
+ ka quote -s $s
223
+ done
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Data Pipeline
229
+
230
+ ```bash
231
+ ka --json prices -s NVDA > prices.json
232
+ ```
233
+
234
+ ---
235
+
236
+ ## AI Agent Workflow
237
+
238
+ ```bash
239
+ ka --json volatility -s NVDA -sd 2025-01-01 -ed 2025-12-31
240
+ ```
241
+
242
+ The structured output can be consumed directly by:
243
+
244
+ - AI agents
245
+ - Python scripts
246
+ - automation workers
247
+ - research pipelines
248
+
249
+ ---
250
+
251
+ # Environment Variables
252
+
253
+ | Variable | Description |
254
+ |---------|-------------|
255
+ | KLICKANALYTICS_CLI_API_KEY | API key for CLI authentication |
256
+ | KA_API_KEY | fallback API key |
257
+ | KA_DEV_ENDPOINT | optional local/staging API endpoint |
258
+ | KA_PROTO | protocol version override |
259
+
260
+ ---
261
+
262
+ # Design Philosophy
263
+
264
+ The CLI intentionally stays lightweight.
265
+
266
+ The client does **not hardcode commands locally**. Instead:
267
+
268
+ - commands are forwarded to the server
269
+ - the server validates and routes them
270
+ - authentication is handled server-side
271
+ - new commands can be added without updating the CLI
272
+
273
+ This architecture keeps the CLI simple and future-proof.
274
+
275
+ ---
276
+
277
+ # Development Install
278
+
279
+ Clone the repository:
280
+
281
+ ```bash
282
+ git clone https://github.com/klickanalytics/klickanalytics-cli.git
283
+ cd klickanalytics-cli
284
+ ```
285
+
286
+ Install locally:
287
+
288
+ ```bash
289
+ pip install -e .
290
+ ```
291
+
292
+ ---
293
+
294
+ # Documentation
295
+
296
+ Full CLI documentation:
297
+
298
+ https://www.klickanalytics.com/cli_documentation
299
+
300
+ ---
301
+
302
+ # License
303
+
304
+ MIT License
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/klickanalytics_cli/__init__.py
5
+ src/klickanalytics_cli/ka_cli.py
6
+ src/klickanalytics_cli.egg-info/PKG-INFO
7
+ src/klickanalytics_cli.egg-info/SOURCES.txt
8
+ src/klickanalytics_cli.egg-info/dependency_links.txt
9
+ src/klickanalytics_cli.egg-info/entry_points.txt
10
+ src/klickanalytics_cli.egg-info/requires.txt
11
+ src/klickanalytics_cli.egg-info/top_level.txt
12
+ tests/test_imports.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ka = klickanalytics_cli.ka_cli:main
@@ -0,0 +1 @@
1
+ klickanalytics_cli
@@ -0,0 +1,3 @@
1
+ def test_import():
2
+ import klickanalytics_cli
3
+ assert klickanalytics_cli is not None