|
3 | 3 | [](https://pypi.org/project/robosystems-client/) |
4 | 4 | [](https://opensource.org/licenses/MIT) |
5 | 5 |
|
6 | | -Official Python Client for the RoboSystems Financial Knowledge Graph API. Access comprehensive financial data including accounting records, SEC filings, and advanced graph analytics through a type-safe, async-ready Python interface. |
| 6 | +Official Python Client for the RoboSystems Financial Knowledge Graph API. Access comprehensive financial data including accounting transactions, financial reports, and advanced graph analytics through a type-safe, async-ready Python interface. |
7 | 7 |
|
8 | 8 | ## Features |
9 | 9 |
|
10 | 10 | - **Type-safe API client** with full type hints and Pydantic models |
11 | 11 | - **Async/await support** for high-performance applications |
12 | | -- **Multi-tenant support** with graph-scoped operations |
13 | | -- **Authentication handling** with API key and SSO support |
14 | | -- **Comprehensive error handling** with custom exceptions |
15 | | -- **Pagination support** for large data sets |
16 | | -- **Streaming query support** for memory-efficient processing of large result sets |
| 12 | +- **Streaming support** for memory-efficient processing of large result sets |
17 | 13 | - **Financial AI Agent** integration for natural language queries |
| 14 | +- **Comprehensive error handling** with custom exceptions |
18 | 15 |
|
19 | 16 | ## Installation |
20 | 17 |
|
21 | 18 | ```bash |
22 | 19 | pip install robosystems-client |
23 | 20 | ``` |
24 | 21 |
|
25 | | -## Quick Start |
26 | | - |
27 | | -```python |
28 | | -from robosystems_client import RoboSystemsSDK |
29 | | -from robosystems_client.api.query import execute_cypher_query |
30 | | -from robosystems_client.models import CypherQueryRequest |
31 | | - |
32 | | -# Initialize the SDK |
33 | | -sdk = RoboSystemsSDK( |
34 | | - base_url="https://api.robosystems.ai", |
35 | | - token="your-api-key", |
36 | | - auth_header_name="X-API-Key", |
37 | | - prefix="" # No prefix needed for API key |
38 | | -) |
39 | | - |
40 | | -# Async usage (recommended) |
41 | | -import asyncio |
42 | | - |
43 | | -async def main(): |
44 | | - # Execute a Cypher query |
45 | | - query = CypherQueryRequest( |
46 | | - query="MATCH (c:Company)-[:HAS_FILING]->(f:Filing) RETURN c.name, f.form_type, f.filing_date LIMIT 10" |
47 | | - ) |
48 | | - result = await execute_cypher_query.asyncio(graph_id="your-graph-id", client=sdk, body=query) |
49 | | - |
50 | | - for row in result.data: |
51 | | - print(f"{row['c.name']} filed {row['f.form_type']} on {row['f.filing_date']}") |
52 | | - |
53 | | -asyncio.run(main()) |
54 | | -``` |
55 | | - |
56 | | -## Key API Endpoints |
57 | | - |
58 | | -### Graph Queries & Analytics |
59 | | -```python |
60 | | -from robosystems_client.api.query import execute_cypher_query |
61 | | -from robosystems_client.api.graph_analytics import get_graph_metrics |
62 | | -from robosystems_client.models import CypherQueryRequest |
63 | | - |
64 | | -# Execute Cypher queries with parameters |
65 | | -query_request = CypherQueryRequest( |
66 | | - query="""MATCH (c:Company {ticker: $ticker})-[:HAS_METRIC]->(m:Metric) |
67 | | - WHERE m.fiscal_year >= $start_year |
68 | | - RETURN m.name, m.value, m.fiscal_year |
69 | | - ORDER BY m.fiscal_year DESC""", |
70 | | - parameters={"ticker": "AAPL", "start_year": 2020} |
71 | | -) |
72 | | -results = await execute_cypher_query.asyncio( |
73 | | - graph_id="your-graph-id", |
74 | | - client=sdk, |
75 | | - body=query_request |
76 | | -) |
77 | | - |
78 | | -# Get graph analytics and metrics |
79 | | -metrics = await get_graph_metrics.asyncio( |
80 | | - graph_id="your-graph-id", |
81 | | - client=sdk |
82 | | -) |
83 | | -print(f"Total nodes: {metrics.total_nodes}") |
84 | | -print(f"Total relationships: {metrics.total_relationships}") |
85 | | -``` |
86 | | - |
87 | | -### Financial AI Agent |
88 | | -```python |
89 | | -from robosystems_client.api.agent import query_financial_agent |
90 | | -from robosystems_client.models import AgentRequest |
91 | | - |
92 | | -# Natural language financial queries |
93 | | -agent_request = AgentRequest( |
94 | | - message="What was Apple's revenue growth over the last 3 years?", |
95 | | - force_extended_analysis=True, |
96 | | - context={"include_schema": True} |
97 | | -) |
98 | | -agent_response = await query_financial_agent.asyncio( |
99 | | - graph_id="your-graph-id", |
100 | | - client=sdk, |
101 | | - body=agent_request |
102 | | -) |
103 | | -print(f"Response: {agent_response.message}") |
104 | | -``` |
105 | | - |
106 | | -### Function Patterns |
107 | | - |
108 | | -Every API endpoint provides multiple calling patterns: |
109 | | - |
110 | | -- **`asyncio()`** - Async call, returns parsed response (recommended) |
111 | | -- **`asyncio_detailed()`** - Async call, returns full Response object |
112 | | -- **`sync()`** - Synchronous call, returns parsed response |
113 | | -- **`sync_detailed()`** - Synchronous call, returns full Response object |
114 | | - |
115 | | -## Streaming Support with Extensions |
| 22 | +## API Reference |
116 | 23 |
|
117 | | -The SDK includes an extensions module with SSE (Server-Sent Events) support for real-time streaming operations: |
| 24 | +- API reference: [https://api.robosystems.ai](https://api.robosystems.ai) |
| 25 | +- API documentation: [https://api.robosystems.ai/docs](https://api.robosystems.ai/docs) |
| 26 | +- OpenAPI specification: [https://api.robosystems.ai/openapi.json](https://api.robosystems.ai/openapi.json) |
118 | 27 |
|
119 | | -```python |
120 | | -from robosystems_client.extensions import ( |
121 | | - SSEClient, |
122 | | - QueryClient, |
123 | | - OperationClient, |
124 | | - RoboSystemsExtensions |
125 | | -) |
126 | | -from robosystems_client.models import CypherQueryRequest |
127 | | - |
128 | | -# Initialize extensions |
129 | | -extensions = RoboSystemsExtensions() |
130 | | - |
131 | | -# Use QueryClient for advanced query operations |
132 | | -query_client = QueryClient(sdk) |
133 | | - |
134 | | -# Execute queries with the query client |
135 | | -query = CypherQueryRequest( |
136 | | - query="""MATCH (c:Company)-[:HAS_METRIC]->(m:Metric) |
137 | | - WHERE m.fiscal_year >= 2020 |
138 | | - RETURN c.name, m.name, m.value, m.fiscal_year |
139 | | - ORDER BY c.name, m.fiscal_year""", |
140 | | - parameters={} |
141 | | -) |
142 | | - |
143 | | -# Monitor long-running operations with SSE |
144 | | -operation_client = OperationClient(sdk) |
145 | | - |
146 | | -# Stream operation events |
147 | | -from robosystems_client.api.operations import stream_operation_events |
148 | | -await stream_operation_events.asyncio( |
149 | | - operation_id="op-123", |
150 | | - client=sdk |
151 | | -) |
152 | | -``` |
| 28 | +## Support |
153 | 29 |
|
154 | | -The extensions module provides: |
155 | | -- SSE client for real-time event streaming |
156 | | -- Query client with advanced query management |
157 | | -- Operation client for monitoring long-running tasks |
158 | | -- Utilities for result processing and caching |
| 30 | +- Issues: [Issues](https://github.com/RoboFinSystems/robosystems-python-client/issues) |
| 31 | +- Discussions: [Discussions](https://github.com/RoboFinSystems/robosystems-python-client/discussions) |
| 32 | +- Projects: [Projects](https://github.com/RoboFinSystems/robosystems-python-client/projects) |
| 33 | +- Wiki: [Wiki](https://github.com/RoboFinSystems/robosystems-python-client/wiki) |
159 | 34 |
|
160 | | -## Error Handling |
| 35 | +## License |
161 | 36 |
|
162 | | -```python |
163 | | -from robosystems_client.types import Response |
164 | | -from robosystems_client.errors import UnexpectedStatus |
165 | | -import httpx |
| 37 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
166 | 38 |
|
167 | | -try: |
168 | | - # API calls that might fail |
169 | | - result = await execute_cypher_query.asyncio( |
170 | | - graph_id="your-graph-id", |
171 | | - client=sdk, |
172 | | - body=query_request |
173 | | - ) |
174 | | -except UnexpectedStatus as e: |
175 | | - # Handle API errors (4xx, 5xx) |
176 | | - print(f"API error: {e.status_code}") |
177 | | - print(f"Error details: {e.content}") |
178 | | - |
179 | | - # Parse error response if JSON |
180 | | - if e.status_code == 400: |
181 | | - error_detail = e.content.decode('utf-8') |
182 | | - print(f"Validation error: {error_detail}") |
183 | | - elif e.status_code == 401: |
184 | | - print("Authentication failed - check your API key") |
185 | | - elif e.status_code == 403: |
186 | | - print("Permission denied - check graph access") |
187 | | - elif e.status_code == 429: |
188 | | - print("Rate limit exceeded - retry later") |
189 | | -except httpx.TimeoutException: |
190 | | - print("Request timed out - try again") |
191 | | -except httpx.NetworkError as e: |
192 | | - print(f"Network error: {e}") |
193 | | -except Exception as e: |
194 | | - print(f"Unexpected error: {type(e).__name__}: {e}") |
195 | | - |
196 | | -# Using detailed responses for better error handling |
197 | | -from robosystems_client.api.query import execute_cypher_query |
198 | | - |
199 | | -response = await execute_cypher_query.asyncio_detailed( |
200 | | - graph_id="your-graph-id", |
201 | | - client=sdk, |
202 | | - body=query_request |
203 | | -) |
204 | | - |
205 | | -if response.status_code == 200: |
206 | | - result = response.parsed |
207 | | - print(f"Success: Query executed successfully") |
208 | | -else: |
209 | | - print(f"Failed with status {response.status_code}") |
210 | | - print(f"Headers: {response.headers}") |
211 | | - print(f"Content: {response.content}") |
212 | | -``` |
213 | | - |
214 | | -## Development |
215 | | - |
216 | | -This Client is auto-generated from the RoboSystems OpenAPI specification to ensure it stays in sync with the latest API changes. |
217 | | - |
218 | | -### Setup |
219 | | - |
220 | | -```bash |
221 | | -just venv |
222 | | -just install |
223 | | -``` |
224 | | - |
225 | | -### Regenerating the Client |
226 | | - |
227 | | -When the API changes, regenerate the Client from the OpenAPI spec: |
228 | | - |
229 | | -```bash |
230 | | -# From localhost (development) |
231 | | -just generate-client http://localhost:8000/openapi.json |
232 | | - |
233 | | -# From staging |
234 | | -just generate-client https://staging.api.robosystems.ai/openapi.json |
235 | | - |
236 | | -# From production |
237 | | -just generate-client https://api.robosystems.ai/openapi.json |
238 | | -``` |
239 | | - |
240 | | -### Testing |
241 | | - |
242 | | -```bash |
243 | | -just test |
244 | | -just test-cov |
245 | | -``` |
246 | | - |
247 | | -### Code Quality |
248 | | - |
249 | | -```bash |
250 | | -just lint |
251 | | -just format |
252 | | -just typecheck |
253 | | -``` |
| 39 | +MIT © 2025 RFS LLC |
0 commit comments