JC321 commited on
Commit
b6d52e5
·
verified ·
1 Parent(s): e65eb23

Delete mcp_client_examples.json

Browse files
Files changed (1) hide show
  1. mcp_client_examples.json +0 -619
mcp_client_examples.json DELETED
@@ -1,619 +0,0 @@
1
- {
2
- "mcp_server_info": {
3
- "name": "SEC Financial Report MCP Server",
4
- "description": "FastAPI-based MCP Server for querying SEC EDGAR financial data",
5
- "base_url_local": "http://localhost:7860",
6
- "base_url_deployed": "https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space",
7
- "documentation": {
8
- "swagger_ui": "/docs",
9
- "redoc": "/redoc"
10
- }
11
- },
12
-
13
- "api_endpoints": {
14
-
15
- "1_search_company": {
16
- "name": "Search Company by Name",
17
- "endpoint": "/api/search_company",
18
- "method": "POST",
19
- "description": "Search for a company by name and retrieve its CIK number",
20
-
21
- "request_example": {
22
- "company_name": "NVIDIA"
23
- },
24
-
25
- "response_success": {
26
- "cik": "0001045810",
27
- "name": "NVIDIA CORP",
28
- "ticker": "NVDA",
29
- "error": null
30
- },
31
-
32
- "response_not_found": {
33
- "cik": null,
34
- "name": null,
35
- "ticker": null,
36
- "error": "No company found matching 'INVALID_COMPANY'"
37
- },
38
-
39
- "curl_example": "curl -X POST 'https://YOUR_SPACE.hf.space/api/search_company' -H 'Content-Type: application/json' -d '{\"company_name\": \"NVIDIA\"}'",
40
-
41
- "python_example": "import requests\nresponse = requests.post('https://YOUR_SPACE.hf.space/api/search_company', json={'company_name': 'NVIDIA'})\nprint(response.json())",
42
-
43
- "javascript_example": "fetch('https://YOUR_SPACE.hf.space/api/search_company', {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({company_name: 'NVIDIA'})\n}).then(r => r.json()).then(console.log)",
44
-
45
- "notes": [
46
- "Returns exact match first, then partial matches",
47
- "CIK is zero-padded to 10 digits",
48
- "Search is case-insensitive"
49
- ]
50
- },
51
-
52
- "2_get_company_info": {
53
- "name": "Get Company Information",
54
- "endpoint": "/api/get_company_info",
55
- "method": "POST",
56
- "description": "Retrieve detailed company information using CIK",
57
-
58
- "request_example": {
59
- "cik": "0001045810"
60
- },
61
-
62
- "response_success": {
63
- "cik": "0001045810",
64
- "name": "NVIDIA CORP",
65
- "tickers": ["NVDA"],
66
- "sic": "3674",
67
- "sic_description": "Semiconductors & Related Devices",
68
- "error": null
69
- },
70
-
71
- "response_not_found": {
72
- "cik": null,
73
- "name": null,
74
- "tickers": null,
75
- "sic": null,
76
- "sic_description": null,
77
- "error": "No company information found for CIK: 9999999999"
78
- },
79
-
80
- "curl_example": "curl -X POST 'https://YOUR_SPACE.hf.space/api/get_company_info' -H 'Content-Type: application/json' -d '{\"cik\": \"0001045810\"}'",
81
-
82
- "python_example": "import requests\nresponse = requests.post('https://YOUR_SPACE.hf.space/api/get_company_info', json={'cik': '0001045810'})\ninfo = response.json()\nprint(f\"Company: {info['name']}\")\nprint(f\"Industry: {info['sic_description']}\")",
83
-
84
- "javascript_example": "fetch('https://YOUR_SPACE.hf.space/api/get_company_info', {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({cik: '0001045810'})\n}).then(r => r.json()).then(data => console.log(data.name))",
85
-
86
- "notes": [
87
- "CIK must be zero-padded to 10 digits",
88
- "SIC code represents industry classification",
89
- "Multiple tickers may exist for one company"
90
- ]
91
- },
92
-
93
- "3_get_company_filings": {
94
- "name": "Get Company Filings",
95
- "endpoint": "/api/get_company_filings",
96
- "method": "POST",
97
- "description": "Retrieve company SEC filings with optional form type filter",
98
-
99
- "request_all_forms": {
100
- "cik": "0001045810",
101
- "form_types": null
102
- },
103
-
104
- "request_specific_forms": {
105
- "cik": "0001045810",
106
- "form_types": ["10-K", "10-Q"]
107
- },
108
-
109
- "response_success": {
110
- "filings": [
111
- {
112
- "form_type": "10-K",
113
- "filing_date": "2024-02-21",
114
- "accession_number": "0001045810-24-000029",
115
- "primary_document": "nvda-20240128.htm"
116
- },
117
- {
118
- "form_type": "10-Q",
119
- "filing_date": "2024-11-20",
120
- "accession_number": "0001045810-24-000147",
121
- "primary_document": "nvda-20241027.htm"
122
- }
123
- ],
124
- "error": null
125
- },
126
-
127
- "response_not_found": {
128
- "filings": [],
129
- "error": "No filings found for CIK: 0001045810"
130
- },
131
-
132
- "curl_example": "curl -X POST 'https://YOUR_SPACE.hf.space/api/get_company_filings' -H 'Content-Type: application/json' -d '{\"cik\": \"0001045810\", \"form_types\": [\"10-K\", \"10-Q\"]}'",
133
-
134
- "python_example": "import requests\nresponse = requests.post(\n 'https://YOUR_SPACE.hf.space/api/get_company_filings',\n json={'cik': '0001045810', 'form_types': ['10-K', '10-Q']}\n)\nfilings = response.json()['filings']\nfor filing in filings[:5]:\n print(f\"{filing['form_type']}: {filing['filing_date']}\")",
135
-
136
- "javascript_example": "fetch('https://YOUR_SPACE.hf.space/api/get_company_filings', {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({cik: '0001045810', form_types: ['10-K']})\n}).then(r => r.json()).then(data => data.filings.forEach(f => console.log(f.form_type)))",
137
-
138
- "form_types_reference": {
139
- "10-K": "Annual report (US companies)",
140
- "10-Q": "Quarterly report (US companies)",
141
- "20-F": "Annual report (Foreign private issuers)",
142
- "8-K": "Current report (major events)",
143
- "S-1": "Registration statement"
144
- },
145
-
146
- "notes": [
147
- "Set form_types to null to get all filing types",
148
- "Filings are returned in reverse chronological order",
149
- "Most companies file multiple forms per year"
150
- ]
151
- },
152
-
153
- "4_get_company_facts": {
154
- "name": "Get Company Financial Facts",
155
- "endpoint": "/api/get_company_facts",
156
- "method": "POST",
157
- "description": "Retrieve complete XBRL financial facts data for a company",
158
-
159
- "request_example": {
160
- "cik": "0001045810"
161
- },
162
-
163
- "response_structure": {
164
- "facts": {
165
- "us-gaap": {
166
- "Revenues": {
167
- "label": "Revenues",
168
- "description": "Amount of revenue recognized...",
169
- "units": {
170
- "USD": [
171
- {
172
- "end": "2024-01-28",
173
- "val": 60922000000,
174
- "accn": "0001045810-24-000029",
175
- "fy": 2024,
176
- "fp": "FY",
177
- "form": "10-K",
178
- "filed": "2024-02-21",
179
- "frame": "CY2023"
180
- }
181
- ]
182
- }
183
- },
184
- "NetIncomeLoss": "...",
185
- "EarningsPerShareBasic": "..."
186
- },
187
- "ifrs-full": {
188
- "Revenue": "..."
189
- },
190
- "dei": {
191
- "EntityCommonStockSharesOutstanding": "..."
192
- }
193
- },
194
- "error": null
195
- },
196
-
197
- "curl_example": "curl -X POST 'https://YOUR_SPACE.hf.space/api/get_company_facts' -H 'Content-Type: application/json' -d '{\"cik\": \"0001045810\"}'",
198
-
199
- "python_example": "import requests\nresponse = requests.post(\n 'https://YOUR_SPACE.hf.space/api/get_company_facts',\n json={'cik': '0001045810'}\n)\nfacts = response.json()['facts']\nprint(f\"Available standards: {list(facts.keys())}\")\nif 'us-gaap' in facts:\n print(f\"US-GAAP metrics count: {len(facts['us-gaap'])}\")",
200
-
201
- "javascript_example": "fetch('https://YOUR_SPACE.hf.space/api/get_company_facts', {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({cik: '0001045810'})\n}).then(r => r.json()).then(data => console.log(Object.keys(data.facts)))",
202
-
203
- "notes": [
204
- "Response can be very large (several MB)",
205
- "Contains historical data for all reported periods",
206
- "Supports both US-GAAP and IFRS standards",
207
- "Best for advanced analysis requiring raw XBRL data"
208
- ]
209
- },
210
-
211
- "5_get_financial_data_annual": {
212
- "name": "Get Annual Financial Data",
213
- "endpoint": "/api/get_financial_data",
214
- "method": "POST",
215
- "description": "Extract key financial metrics for a specific fiscal year",
216
-
217
- "request_example": {
218
- "cik": "0001045810",
219
- "period": "2024"
220
- },
221
-
222
- "response_success": {
223
- "period": "2024",
224
- "total_revenue": 60922000000,
225
- "net_income": 29760000000,
226
- "earnings_per_share": 12.04,
227
- "operating_expenses": 11822000000,
228
- "operating_cash_flow": 28091000000,
229
- "source_url": "https://www.sec.gov/Archives/edgar/data/1045810/000104581024000029",
230
- "source_form": "10-K",
231
- "data_source": "us-gaap",
232
- "additional_details": {
233
- "total_revenue_details": {
234
- "tag": "Revenues",
235
- "form": "10-K",
236
- "fy": 2024,
237
- "fp": "FY",
238
- "val": 60922000000,
239
- "start": "2023-01-30",
240
- "end": "2024-01-28",
241
- "accn": "0001045810-24-000029",
242
- "filed": "2024-02-21",
243
- "frame": "CY2023",
244
- "data_source": "us-gaap"
245
- }
246
- },
247
- "error": null
248
- },
249
-
250
- "curl_example": "curl -X POST 'https://YOUR_SPACE.hf.space/api/get_financial_data' -H 'Content-Type: application/json' -d '{\"cik\": \"0001045810\", \"period\": \"2024\"}'",
251
-
252
- "python_example": "import requests\nresponse = requests.post(\n 'https://YOUR_SPACE.hf.space/api/get_financial_data',\n json={'cik': '0001045810', 'period': '2024'}\n)\ndata = response.json()\nprint(f\"Period: FY{data['period']}\")\nprint(f\"Revenue: ${data['total_revenue']:,.0f}\")\nprint(f\"Net Income: ${data['net_income']:,.0f}\")\nprint(f\"EPS: ${data['earnings_per_share']:.2f}\")\nprint(f\"Source: {data['source_form']}\")",
253
-
254
- "javascript_example": "fetch('https://YOUR_SPACE.hf.space/api/get_financial_data', {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({cik: '0001045810', period: '2024'})\n}).then(r => r.json()).then(data => {\n console.log(`Revenue: $${(data.total_revenue / 1e9).toFixed(2)}B`);\n console.log(`Net Income: $${(data.net_income / 1e9).toFixed(2)}B`);\n})",
255
-
256
- "notes": [
257
- "Period format: 'YYYY' for annual data",
258
- "All monetary values in USD (original values)",
259
- "EPS is per share value",
260
- "Data sourced from 10-K (US) or 20-F (foreign) forms"
261
- ]
262
- },
263
-
264
- "6_get_financial_data_quarterly": {
265
- "name": "Get Quarterly Financial Data",
266
- "endpoint": "/api/get_financial_data",
267
- "method": "POST",
268
- "description": "Extract key financial metrics for a specific quarter",
269
-
270
- "request_example": {
271
- "cik": "0001045810",
272
- "period": "2024Q3"
273
- },
274
-
275
- "response_success": {
276
- "period": "2024Q3",
277
- "total_revenue": 30040000000,
278
- "net_income": 19309000000,
279
- "earnings_per_share": 7.81,
280
- "operating_expenses": 3932000000,
281
- "operating_cash_flow": 14502000000,
282
- "source_url": "https://www.sec.gov/Archives/edgar/data/1045810/000104581024000147",
283
- "source_form": "10-Q",
284
- "data_source": "us-gaap",
285
- "additional_details": null,
286
- "error": null
287
- },
288
-
289
- "curl_example": "curl -X POST 'https://YOUR_SPACE.hf.space/api/get_financial_data' -H 'Content-Type: application/json' -d '{\"cik\": \"0001045810\", \"period\": \"2024Q3\"}'",
290
-
291
- "python_example": "import requests\n\n# Get multiple quarters for comparison\nquarters = ['2024Q1', '2024Q2', '2024Q3']\nfor quarter in quarters:\n response = requests.post(\n 'https://YOUR_SPACE.hf.space/api/get_financial_data',\n json={'cik': '0001045810', 'period': quarter}\n )\n data = response.json()\n if not data.get('error'):\n print(f\"{quarter}: Revenue ${data['total_revenue']/1e9:.2f}B\")",
292
-
293
- "javascript_example": "// Compare Q3 vs Q2\nconst periods = ['2024Q3', '2024Q2'];\nPromise.all(periods.map(period =>\n fetch('https://YOUR_SPACE.hf.space/api/get_financial_data', {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({cik: '0001045810', period})\n }).then(r => r.json())\n)).then(results => results.forEach(d => \n console.log(`${d.period}: $${(d.total_revenue/1e9).toFixed(2)}B`)\n))",
294
-
295
- "quarter_reference": {
296
- "Q1": "First quarter (typically Jan-Mar or similar)",
297
- "Q2": "Second quarter (typically Apr-Jun or similar)",
298
- "Q3": "Third quarter (typically Jul-Sep or similar)",
299
- "Q4": "Fourth quarter (typically Oct-Dec or similar)"
300
- },
301
-
302
- "notes": [
303
- "Period format: 'YYYYQX' where X is 1, 2, 3, or 4",
304
- "Data sourced from 10-Q forms",
305
- "Foreign companies (20-F filers) typically don't file quarterly reports",
306
- "Quarters may not align with calendar year for all companies"
307
- ]
308
- },
309
-
310
- "7_health_check": {
311
- "name": "Health Check",
312
- "endpoint": "/health",
313
- "method": "GET",
314
- "description": "Check if the MCP server is running and healthy",
315
-
316
- "request": "No request body required (GET request)",
317
-
318
- "response": {
319
- "status": "healthy",
320
- "service": "SEC Financial Report MCP Server"
321
- },
322
-
323
- "curl_example": "curl https://YOUR_SPACE.hf.space/health",
324
-
325
- "python_example": "import requests\nresponse = requests.get('https://YOUR_SPACE.hf.space/health')\nif response.json()['status'] == 'healthy':\n print('✓ Server is running')",
326
-
327
- "javascript_example": "fetch('https://YOUR_SPACE.hf.space/health')\n .then(r => r.json())\n .then(data => console.log(`Status: ${data.status}`))",
328
-
329
- "notes": [
330
- "No authentication required",
331
- "Use for monitoring and health checks",
332
- "Always returns 200 if server is running"
333
- ]
334
- },
335
-
336
- "8_advanced_search": {
337
- "name": "Advanced Company Search",
338
- "endpoint": "/api/advanced_search",
339
- "method": "POST",
340
- "description": "Advanced search supporting both company name and CIK (uses FinancialAnalyzer.search_company)",
341
-
342
- "request_by_name": {
343
- "company_input": "Apple"
344
- },
345
-
346
- "request_by_cik": {
347
- "company_input": "0000320193"
348
- },
349
-
350
- "response_success": {
351
- "cik": "0000320193",
352
- "name": "Apple Inc.",
353
- "tickers": ["AAPL"],
354
- "sic": "3571",
355
- "sic_description": "Electronic Computers",
356
- "error": null
357
- },
358
-
359
- "curl_example": "curl -X POST 'https://YOUR_SPACE.hf.space/api/advanced_search' -H 'Content-Type: application/json' -d '{\"company_input\": \"Apple\"}'" ,
360
-
361
- "python_example": "import requests\n\n# Search by name\nresponse = requests.post(\n 'https://YOUR_SPACE.hf.space/api/advanced_search',\n json={'company_input': 'Apple'}\n)\nprint(response.json())\n\n# Search by CIK\nresponse = requests.post(\n 'https://YOUR_SPACE.hf.space/api/advanced_search',\n json={'company_input': '0000320193'}\n)\nprint(response.json())",
362
-
363
- "javascript_example": "// Flexible search - works with both name and CIK\nfetch('https://YOUR_SPACE.hf.space/api/advanced_search', {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({company_input: 'Apple'})\n}).then(r => r.json()).then(console.log)",
364
-
365
- "notes": [
366
- "Automatically detects if input is CIK (numeric, 8+ digits) or company name",
367
- "Returns full company information including SIC",
368
- "More intelligent than basic search_company endpoint"
369
- ]
370
- },
371
-
372
- "9_extract_financial_metrics": {
373
- "name": "Extract Multi-Year Financial Metrics",
374
- "endpoint": "/api/extract_financial_metrics",
375
- "method": "POST",
376
- "description": "Extract financial metrics for multiple years (both annual and quarterly data)",
377
-
378
- "request_example": {
379
- "cik": "0001045810",
380
- "years": 3
381
- },
382
-
383
- "response_success": {
384
- "metrics": [
385
- {
386
- "period": "2024",
387
- "total_revenue": 60922000000,
388
- "net_income": 29760000000,
389
- "earnings_per_share": 12.04,
390
- "operating_expenses": 11822000000,
391
- "operating_cash_flow": 28091000000,
392
- "source_form": "10-K",
393
- "data_source": "us-gaap"
394
- },
395
- {
396
- "period": "2024Q4",
397
- "total_revenue": 35082000000,
398
- "net_income": 19309000000,
399
- "earnings_per_share": 7.81,
400
- "source_form": "10-Q"
401
- },
402
- {
403
- "period": "2024Q3",
404
- "total_revenue": 30040000000,
405
- "net_income": 16599000000,
406
- "earnings_per_share": 6.70,
407
- "source_form": "10-Q"
408
- }
409
- ],
410
- "count": 3,
411
- "error": null
412
- },
413
-
414
- "curl_example": "curl -X POST 'https://YOUR_SPACE.hf.space/api/extract_financial_metrics' -H 'Content-Type: application/json' -d '{\"cik\": \"0001045810\", \"years\": 3}'",
415
-
416
- "python_example": "import requests\nimport pandas as pd\n\nresponse = requests.post(\n 'https://YOUR_SPACE.hf.space/api/extract_financial_metrics',\n json={'cik': '0001045810', 'years': 3}\n)\ndata = response.json()\n\n# Convert to DataFrame for easy analysis\ndf = pd.DataFrame(data['metrics'])\nprint(f\"Retrieved {data['count']} periods\")\nprint(df[['period', 'total_revenue', 'net_income', 'earnings_per_share']])",
417
-
418
- "javascript_example": "fetch('https://YOUR_SPACE.hf.space/api/extract_financial_metrics', {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({cik: '0001045810', years: 3})\n}).then(r => r.json()).then(data => {\n console.log(`Found ${data.count} periods`);\n data.metrics.forEach(m => {\n console.log(`${m.period}: Revenue $${(m.total_revenue/1e9).toFixed(2)}B`);\n });\n})",
419
-
420
- "notes": [
421
- "Returns both annual (e.g., '2024') and quarterly (e.g., '2024Q3') data",
422
- "Data is automatically formatted and sorted by period",
423
- "Years parameter: min=1, max=10, default=3",
424
- "Very useful for trend analysis and historical comparison"
425
- ]
426
- },
427
-
428
- "10_get_latest_financial_data": {
429
- "name": "Get Latest Financial Data",
430
- "endpoint": "/api/get_latest_financial_data",
431
- "method": "POST",
432
- "description": "Get the most recent annual financial data for a company",
433
-
434
- "request_example": {
435
- "cik": "0001045810"
436
- },
437
-
438
- "response_success": {
439
- "period": "2024",
440
- "total_revenue": 60922000000,
441
- "net_income": 29760000000,
442
- "earnings_per_share": 12.04,
443
- "operating_expenses": 11822000000,
444
- "operating_cash_flow": 28091000000,
445
- "source_url": "https://www.sec.gov/Archives/edgar/data/1045810/000104581024000029",
446
- "source_form": "10-K",
447
- "data_source": "us-gaap",
448
- "error": null
449
- },
450
-
451
- "curl_example": "curl -X POST 'https://YOUR_SPACE.hf.space/api/get_latest_financial_data' -H 'Content-Type: application/json' -d '{\"cik\": \"0001045810\"}' ",
452
-
453
- "python_example": "import requests\n\nresponse = requests.post(\n 'https://YOUR_SPACE.hf.space/api/get_latest_financial_data',\n json={'cik': '0001045810'}\n)\ndata = response.json()\n\nif not data.get('error'):\n print(f\"Latest Data: FY{data['period']}\")\n print(f\"Revenue: ${data['total_revenue']:,.0f}\")\n print(f\"Net Income: ${data['net_income']:,.0f}\")\n print(f\"EPS: ${data['earnings_per_share']:.2f}\")\n print(f\"Source: {data['source_form']}\")\nelse:\n print(f\"Error: {data['error']}\")",
454
-
455
- "javascript_example": "fetch('https://YOUR_SPACE.hf.space/api/get_latest_financial_data', {\n method: 'POST',\n headers: {'Content-Type': 'application/json'},\n body: JSON.stringify({cik: '0001045810'})\n}).then(r => r.json()).then(data => {\n if (!data.error) {\n console.log(`Latest FY${data.period}`);\n console.log(`Revenue: $${(data.total_revenue/1e9).toFixed(2)}B`);\n console.log(`Net Income: $${(data.net_income/1e9).toFixed(2)}B`);\n }\n})",
456
-
457
- "notes": [
458
- "Automatically finds and returns the most recent annual report data",
459
- "Saves you from having to manually determine the latest year",
460
- "Returns data from most recent 10-K or 20-F filing",
461
- "Ideal for getting current snapshot without knowing fiscal year"
462
- ]
463
- }
464
- },
465
-
466
- "complete_workflow_examples": {
467
-
468
- "example_1_basic_company_analysis": {
469
- "name": "Basic Company Financial Analysis",
470
- "description": "Search a company and get its latest annual financial data",
471
- "steps": [
472
- {
473
- "step": 1,
474
- "action": "Search for company",
475
- "endpoint": "/api/search_company",
476
- "request": {
477
- "company_name": "Apple"
478
- },
479
- "extract": "cik"
480
- },
481
- {
482
- "step": 2,
483
- "action": "Get company information",
484
- "endpoint": "/api/get_company_info",
485
- "request": {
486
- "cik": "{{cik_from_step_1}}"
487
- },
488
- "extract": "name, tickers, sic_description"
489
- },
490
- {
491
- "step": 3,
492
- "action": "Get latest annual financial data",
493
- "endpoint": "/api/get_financial_data",
494
- "request": {
495
- "cik": "{{cik_from_step_1}}",
496
- "period": "2024"
497
- },
498
- "extract": "total_revenue, net_income, earnings_per_share"
499
- }
500
- ],
501
- "python_code": "import requests\n\nBASE_URL = 'https://YOUR_SPACE.hf.space'\n\n# Step 1: Search company\nresponse = requests.post(f'{BASE_URL}/api/search_company', \n json={'company_name': 'Apple'})\ncompany = response.json()\ncik = company['cik']\nprint(f\"Found: {company['name']} (CIK: {cik})\")\n\n# Step 2: Get company info\nresponse = requests.post(f'{BASE_URL}/api/get_company_info',\n json={'cik': cik})\ninfo = response.json()\nprint(f\"Industry: {info['sic_description']}\")\n\n# Step 3: Get financial data\nresponse = requests.post(f'{BASE_URL}/api/get_financial_data',\n json={'cik': cik, 'period': '2024'})\ndata = response.json()\nprint(f\"FY2024 Revenue: ${data['total_revenue']:,.0f}\")\nprint(f\"FY2024 Net Income: ${data['net_income']:,.0f}\")\nprint(f\"FY2024 EPS: ${data['earnings_per_share']:.2f}\")"
502
- },
503
-
504
- "example_2_quarterly_trend_analysis": {
505
- "name": "Quarterly Revenue Trend Analysis",
506
- "description": "Analyze revenue trends across multiple quarters",
507
- "steps": [
508
- {
509
- "step": 1,
510
- "action": "Get Q1 2024 data",
511
- "endpoint": "/api/get_financial_data",
512
- "request": {
513
- "cik": "0001045810",
514
- "period": "2024Q1"
515
- }
516
- },
517
- {
518
- "step": 2,
519
- "action": "Get Q2 2024 data",
520
- "endpoint": "/api/get_financial_data",
521
- "request": {
522
- "cik": "0001045810",
523
- "period": "2024Q2"
524
- }
525
- },
526
- {
527
- "step": 3,
528
- "action": "Get Q3 2024 data",
529
- "endpoint": "/api/get_financial_data",
530
- "request": {
531
- "cik": "0001045810",
532
- "period": "2024Q3"
533
- }
534
- }
535
- ],
536
- "python_code": "import requests\nimport pandas as pd\n\nBASE_URL = 'https://YOUR_SPACE.hf.space'\nCIK = '0001045810' # NVIDIA\n\n# Get quarterly data\nquarters = ['2024Q1', '2024Q2', '2024Q3']\ndata_list = []\n\nfor quarter in quarters:\n response = requests.post(\n f'{BASE_URL}/api/get_financial_data',\n json={'cik': CIK, 'period': quarter}\n )\n data = response.json()\n if not data.get('error'):\n data_list.append({\n 'Quarter': quarter,\n 'Revenue': data['total_revenue'] / 1e9, # Convert to billions\n 'Net Income': data['net_income'] / 1e9,\n 'EPS': data['earnings_per_share']\n })\n\n# Create DataFrame and analyze\ndf = pd.DataFrame(data_list)\nprint(df)\nprint(f\"\\nRevenue Growth Q2->Q3: {((df.iloc[2]['Revenue'] / df.iloc[1]['Revenue']) - 1) * 100:.1f}%\")"
537
- },
538
-
539
- "example_3_multi_company_comparison": {
540
- "name": "Compare Multiple Companies",
541
- "description": "Compare financial metrics across different companies",
542
- "companies": ["NVIDIA", "AMD", "Intel"],
543
- "python_code": "import requests\n\nBASE_URL = 'https://YOUR_SPACE.hf.space'\ncompanies = ['NVIDIA', 'AMD', 'Intel']\nperiod = '2024'\n\nresults = []\nfor company_name in companies:\n # Search company\n response = requests.post(\n f'{BASE_URL}/api/search_company',\n json={'company_name': company_name}\n )\n company = response.json()\n \n if not company.get('error'):\n # Get financial data\n response = requests.post(\n f'{BASE_URL}/api/get_financial_data',\n json={'cik': company['cik'], 'period': period}\n )\n data = response.json()\n \n if not data.get('error'):\n results.append({\n 'Company': company['name'],\n 'Revenue (B)': data['total_revenue'] / 1e9,\n 'Net Income (B)': data['net_income'] / 1e9,\n 'EPS': data['earnings_per_share']\n })\n\n# Print comparison\nfor result in results:\n print(f\"{result['Company']}:\")\n print(f\" Revenue: ${result['Revenue (B)']:.2f}B\")\n print(f\" Net Income: ${result['Net Income (B)']:.2f}B\")\n print(f\" EPS: ${result['EPS']:.2f}\\n\")"
544
- },
545
-
546
- "example_4_filing_history_analysis": {
547
- "name": "Analyze Filing History",
548
- "description": "Get and analyze a company's filing history",
549
- "python_code": "import requests\nfrom datetime import datetime\n\nBASE_URL = 'https://YOUR_SPACE.hf.space'\nCIK = '0001045810'\n\n# Get all 10-K filings\nresponse = requests.post(\n f'{BASE_URL}/api/get_company_filings',\n json={'cik': CIK, 'form_types': ['10-K']}\n)\nfilings = response.json()['filings']\n\nprint(f\"Found {len(filings)} annual reports (10-K)\\n\")\n\n# Analyze filing dates\nfor filing in filings[:5]: # Last 5 years\n filing_date = datetime.strptime(filing['filing_date'], '%Y-%m-%d')\n print(f\"Form: {filing['form_type']}\")\n print(f\"Filed: {filing_date.strftime('%B %d, %Y')}\")\n print(f\"Document: {filing['primary_document']}\")\n print(f\"Accession: {filing['accession_number']}\")\n print()"
550
- }
551
- },
552
-
553
- "error_handling_examples": {
554
-
555
- "handling_company_not_found": {
556
- "scenario": "Company name not found in database",
557
- "python_code": "import requests\n\nBASE_URL = 'https://YOUR_SPACE.hf.space'\n\nresponse = requests.post(\n f'{BASE_URL}/api/search_company',\n json={'company_name': 'INVALID_COMPANY_XYZ'}\n)\nresult = response.json()\n\nif result.get('error'):\n print(f\"Error: {result['error']}\")\n # Handle error: ask user to try again, suggest alternatives, etc.\nelse:\n print(f\"Found: {result['name']}\")"
558
- },
559
-
560
- "handling_no_financial_data": {
561
- "scenario": "No financial data available for requested period",
562
- "python_code": "import requests\n\nBASE_URL = 'https://YOUR_SPACE.hf.space'\n\nresponse = requests.post(\n f'{BASE_URL}/api/get_financial_data',\n json={'cik': '0001045810', 'period': '1990'}\n)\ndata = response.json()\n\nif data.get('error'):\n print(f\"No data available: {data['error']}\")\n # Try different period or notify user\nelif not data.get('total_revenue'):\n print(\"Warning: Incomplete data for this period\")\n # Handle partial data\nelse:\n print(f\"Revenue: ${data['total_revenue']:,.0f}\")"
563
- },
564
-
565
- "handling_network_errors": {
566
- "scenario": "Handle network errors and timeouts",
567
- "python_code": "import requests\nfrom requests.exceptions import RequestException, Timeout\n\nBASE_URL = 'https://YOUR_SPACE.hf.space'\n\ntry:\n response = requests.post(\n f'{BASE_URL}/api/search_company',\n json={'company_name': 'NVIDIA'},\n timeout=10 # 10 seconds timeout\n )\n response.raise_for_status() # Raise error for 4xx/5xx status\n data = response.json()\n print(f\"Success: {data['name']}\")\n \nexcept Timeout:\n print(\"Request timed out. Server may be slow or unavailable.\")\nexcept RequestException as e:\n print(f\"Network error occurred: {e}\")\nexcept Exception as e:\n print(f\"Unexpected error: {e}\")"
568
- },
569
-
570
- "handling_validation_errors": {
571
- "scenario": "Handle request validation errors (422 status)",
572
- "python_code": "import requests\n\nBASE_URL = 'https://YOUR_SPACE.hf.space'\n\n# Invalid request (missing required field)\nresponse = requests.post(\n f'{BASE_URL}/api/search_company',\n json={'wrong_field': 'value'}\n)\n\nif response.status_code == 422:\n errors = response.json()['detail']\n print(\"Validation errors:\")\n for error in errors:\n field = error['loc'][-1]\n message = error['msg']\n print(f\" - {field}: {message}\")\nelse:\n data = response.json()\n print(data)"
573
- }
574
- },
575
-
576
- "best_practices": {
577
- "rate_limiting": {
578
- "description": "SEC EDGAR API has rate limits (10 requests per second)",
579
- "recommendation": "Add delays between requests when fetching multiple companies",
580
- "python_example": "import requests\nimport time\n\nBASE_URL = 'https://YOUR_SPACE.hf.space'\ncompanies = ['NVIDIA', 'AMD', 'Intel', 'TSMC']\n\nfor company in companies:\n response = requests.post(\n f'{BASE_URL}/api/search_company',\n json={'company_name': company}\n )\n print(response.json())\n time.sleep(0.2) # 200ms delay = max 5 requests/second"
581
- },
582
-
583
- "caching_results": {
584
- "description": "Cache results to avoid repeated API calls for same data",
585
- "python_example": "import requests\nimport json\nfrom pathlib import Path\n\ncache_file = Path('financial_data_cache.json')\n\ndef get_financial_data(cik, period):\n # Try to load from cache\n cache = {}\n if cache_file.exists():\n cache = json.loads(cache_file.read_text())\n \n cache_key = f\"{cik}_{period}\"\n if cache_key in cache:\n print(\"Using cached data\")\n return cache[cache_key]\n \n # Fetch from API\n response = requests.post(\n 'https://YOUR_SPACE.hf.space/api/get_financial_data',\n json={'cik': cik, 'period': period}\n )\n data = response.json()\n \n # Save to cache\n cache[cache_key] = data\n cache_file.write_text(json.dumps(cache, indent=2))\n \n return data"
586
- },
587
-
588
- "error_handling": {
589
- "description": "Always check for errors in API responses",
590
- "python_example": "def safe_api_call(endpoint, payload):\n try:\n response = requests.post(endpoint, json=payload, timeout=10)\n response.raise_for_status()\n data = response.json()\n \n if data.get('error'):\n print(f\"API Error: {data['error']}\")\n return None\n \n return data\n except Exception as e:\n print(f\"Request failed: {e}\")\n return None\n\n# Usage\nresult = safe_api_call(\n 'https://YOUR_SPACE.hf.space/api/search_company',\n {'company_name': 'NVIDIA'}\n)\nif result:\n print(f\"Found: {result['name']}\")"
591
- },
592
-
593
- "data_validation": {
594
- "description": "Validate data before using it in calculations",
595
- "python_example": "def calculate_profit_margin(financial_data):\n revenue = financial_data.get('total_revenue')\n net_income = financial_data.get('net_income')\n \n # Validate data exists and is valid\n if not revenue or not net_income:\n return None\n if revenue <= 0:\n return None\n \n # Calculate margin\n margin = (net_income / revenue) * 100\n return round(margin, 2)\n\n# Usage\ndata = get_financial_data('0001045810', '2024')\nmargin = calculate_profit_margin(data)\nif margin:\n print(f\"Profit Margin: {margin}%\")\nelse:\n print(\"Unable to calculate profit margin\")"
596
- }
597
- },
598
-
599
- "notes": {
600
- "data_format": "All monetary values are in USD (original amounts, not scaled)",
601
- "eps_format": "Earnings per share is per-share value",
602
- "period_formats": {
603
- "annual": "YYYY (e.g., '2024')",
604
- "quarterly": "YYYYQX (e.g., '2024Q3')"
605
- },
606
- "supported_forms": {
607
- "10-K": "Annual report for US companies",
608
- "10-Q": "Quarterly report for US companies",
609
- "20-F": "Annual report for foreign private issuers"
610
- },
611
- "accounting_standards": ["US-GAAP", "IFRS"],
612
- "user_agent": "Juntao Peng Financial Report Metrics App (jtyxabc@gmail.com)",
613
- "rate_limiting": "Follow SEC EDGAR guidelines (10 requests per second)",
614
- "documentation_urls": {
615
- "swagger_ui": "/docs",
616
- "redoc": "/redoc"
617
- }
618
- }
619
- }