JC321 commited on
Commit
b3fe101
·
verified ·
1 Parent(s): 44b2061

Delete API_USAGE.md

Browse files
Files changed (1) hide show
  1. API_USAGE.md +0 -500
API_USAGE.md DELETED
@@ -1,500 +0,0 @@
1
- # API Usage Guide
2
-
3
- Complete guide for using the SEC Financial Report MCP Server API.
4
-
5
- ## Base URL
6
-
7
- After deployment: `https://YOUR_USERNAME-YOUR_SPACE_NAME.hf.space`
8
-
9
- ## Interactive Documentation
10
-
11
- - **Swagger UI**: `{BASE_URL}/docs`
12
- - **ReDoc**: `{BASE_URL}/redoc`
13
-
14
- ## Quick Start
15
-
16
- ### Python Example
17
-
18
- ```python
19
- import requests
20
-
21
- BASE_URL = "https://YOUR_SPACE_URL.hf.space"
22
-
23
- # 1. Search company
24
- response = requests.post(
25
- f"{BASE_URL}/api/search_company",
26
- json={"company_name": "NVIDIA"}
27
- )
28
- company = response.json()
29
- print(f"Found: {company['name']} (CIK: {company['cik']})")
30
-
31
- # 2. Get financial data
32
- response = requests.post(
33
- f"{BASE_URL}/api/get_financial_data",
34
- json={"cik": company['cik'], "period": "2024"}
35
- )
36
- data = response.json()
37
- print(f"Revenue: ${data['total_revenue']:,.0f}")
38
- print(f"Net Income: ${data['net_income']:,.0f}")
39
- print(f"EPS: ${data['earnings_per_share']:.2f}")
40
- ```
41
-
42
- ## Base URL
43
-
44
- ```
45
- https://your-space-name.hf.space
46
- ```
47
-
48
- ## API Endpoints
49
-
50
- ### 1. Search Company by Name
51
-
52
- **Endpoint:** `POST /api/search_company`
53
-
54
- **Request:**
55
- ```json
56
- {
57
- "company_name": "NVIDIA"
58
- }
59
- ```
60
-
61
- **Response:**
62
- ```json
63
- {
64
- "cik": "0001045810",
65
- "name": "NVIDIA CORP",
66
- "ticker": "NVDA",
67
- "error": null
68
- }
69
- ```
70
-
71
- **cURL Example:**
72
- ```bash
73
- curl -X POST "https://your-space-name.hf.space/api/search_company" \
74
- -H "Content-Type: application/json" \
75
- -d '{"company_name": "NVIDIA"}'
76
- ```
77
-
78
- **Python Example:**
79
- ```python
80
- import requests
81
-
82
- url = "https://your-space-name.hf.space/api/search_company"
83
- payload = {"company_name": "NVIDIA"}
84
- response = requests.post(url, json=payload)
85
- print(response.json())
86
- ```
87
-
88
- ---
89
-
90
- ### 2. Get Company Information
91
-
92
- **Endpoint:** `POST /api/get_company_info`
93
-
94
- **Request:**
95
- ```json
96
- {
97
- "cik": "0001045810"
98
- }
99
- ```
100
-
101
- **Response:**
102
- ```json
103
- {
104
- "cik": "0001045810",
105
- "name": "NVIDIA CORP",
106
- "tickers": ["NVDA"],
107
- "sic": "3674",
108
- "sic_description": "Semiconductors & Related Devices",
109
- "error": null
110
- }
111
- ```
112
-
113
- **cURL Example:**
114
- ```bash
115
- curl -X POST "https://your-space-name.hf.space/api/get_company_info" \
116
- -H "Content-Type: application/json" \
117
- -d '{"cik": "0001045810"}'
118
- ```
119
-
120
- **Python Example:**
121
- ```python
122
- import requests
123
-
124
- url = "https://your-space-name.hf.space/api/get_company_info"
125
- payload = {"cik": "0001045810"}
126
- response = requests.post(url, json=payload)
127
- print(response.json())
128
- ```
129
-
130
- ---
131
-
132
- ### 3. Get Company Filings
133
-
134
- **Endpoint:** `POST /api/get_company_filings`
135
-
136
- **Request (All form types):**
137
- ```json
138
- {
139
- "cik": "0001045810",
140
- "form_types": null
141
- }
142
- ```
143
-
144
- **Request (Specific form types):**
145
- ```json
146
- {
147
- "cik": "0001045810",
148
- "form_types": ["10-K", "10-Q"]
149
- }
150
- ```
151
-
152
- **Response:**
153
- ```json
154
- {
155
- "filings": [
156
- {
157
- "form_type": "10-K",
158
- "filing_date": "2024-02-21",
159
- "accession_number": "0001045810-24-000029",
160
- "primary_document": "nvda-20240128.htm"
161
- },
162
- {
163
- "form_type": "10-Q",
164
- "filing_date": "2024-05-22",
165
- "accession_number": "0001045810-24-000067",
166
- "primary_document": "nvda-20240428.htm"
167
- }
168
- ],
169
- "error": null
170
- }
171
- ```
172
-
173
- **cURL Example:**
174
- ```bash
175
- curl -X POST "https://your-space-name.hf.space/api/get_company_filings" \
176
- -H "Content-Type: application/json" \
177
- -d '{"cik": "0001045810", "form_types": ["10-K", "10-Q"]}'
178
- ```
179
-
180
- **Python Example:**
181
- ```python
182
- import requests
183
-
184
- url = "https://your-space-name.hf.space/api/get_company_filings"
185
- payload = {
186
- "cik": "0001045810",
187
- "form_types": ["10-K", "10-Q"]
188
- }
189
- response = requests.post(url, json=payload)
190
- print(response.json())
191
- ```
192
-
193
- ---
194
-
195
- ### 4. Get Company Facts
196
-
197
- **Endpoint:** `POST /api/get_company_facts`
198
-
199
- **Request:**
200
- ```json
201
- {
202
- "cik": "0001045810"
203
- }
204
- ```
205
-
206
- **Response:**
207
- ```json
208
- {
209
- "facts": {
210
- "dei": {
211
- "EntityCommonStockSharesOutstanding": {...},
212
- "EntityPublicFloat": {...}
213
- },
214
- "us-gaap": {
215
- "Revenues": {...},
216
- "NetIncomeLoss": {...},
217
- "EarningsPerShareBasic": {...}
218
- }
219
- },
220
- "error": null
221
- }
222
- ```
223
-
224
- **cURL Example:**
225
- ```bash
226
- curl -X POST "https://your-space-name.hf.space/api/get_company_facts" \
227
- -H "Content-Type: application/json" \
228
- -d '{"cik": "0001045810"}'
229
- ```
230
-
231
- **Python Example:**
232
- ```python
233
- import requests
234
-
235
- url = "https://your-space-name.hf.space/api/get_company_facts"
236
- payload = {"cik": "0001045810"}
237
- response = requests.post(url, json=payload)
238
- print(response.json())
239
- ```
240
-
241
- ---
242
-
243
- ### 5. Get Financial Data for Period
244
-
245
- **Endpoint:** `POST /api/get_financial_data`
246
-
247
- **Request (Annual Data):**
248
- ```json
249
- {
250
- "cik": "0001045810",
251
- "period": "2024"
252
- }
253
- ```
254
-
255
- **Request (Quarterly Data):**
256
- ```json
257
- {
258
- "cik": "0001045810",
259
- "period": "2024Q3"
260
- }
261
- ```
262
-
263
- **Response:**
264
- ```json
265
- {
266
- "period": "2024",
267
- "total_revenue": 60922000000,
268
- "net_income": 29760000000,
269
- "earnings_per_share": 12.04,
270
- "operating_expenses": 11822000000,
271
- "operating_cash_flow": 28091000000,
272
- "source_url": "https://www.sec.gov/Archives/edgar/data/1045810/000104581024000029",
273
- "source_form": "10-K",
274
- "data_source": "us-gaap",
275
- "additional_details": {
276
- "total_revenue_details": {
277
- "tag": "Revenues",
278
- "form": "10-K",
279
- "fy": 2024,
280
- "fp": "FY",
281
- "val": 60922000000,
282
- "start": "2023-01-30",
283
- "end": "2024-01-28",
284
- "accn": "0001045810-24-000029",
285
- "filed": "2024-02-21",
286
- "frame": "CY2023",
287
- "data_source": "us-gaap"
288
- }
289
- },
290
- "error": null
291
- }
292
- ```
293
-
294
- **cURL Example:**
295
- ```bash
296
- curl -X POST "https://your-space-name.hf.space/api/get_financial_data" \
297
- -H "Content-Type: application/json" \
298
- -d '{"cik": "0001045810", "period": "2024"}'
299
- ```
300
-
301
- **Python Example:**
302
- ```python
303
- import requests
304
-
305
- url = "https://your-space-name.hf.space/api/get_financial_data"
306
- payload = {
307
- "cik": "0001045810",
308
- "period": "2024"
309
- }
310
- response = requests.post(url, json=payload)
311
- data = response.json()
312
- print(f"Total Revenue: ${data['total_revenue']:,.0f}")
313
- print(f"Net Income: ${data['net_income']:,.0f}")
314
- print(f"EPS: ${data['earnings_per_share']:.2f}")
315
- ```
316
-
317
- ---
318
-
319
- ## Complete Python Client Example
320
-
321
- ```python
322
- import requests
323
- import json
324
-
325
-
326
- class SECMCPClient:
327
- """Client for SEC Financial Report MCP Server"""
328
-
329
- def __init__(self, base_url):
330
- self.base_url = base_url.rstrip('/')
331
-
332
- def search_company(self, company_name):
333
- """Search company by name"""
334
- url = f"{self.base_url}/api/search_company"
335
- response = requests.post(url, json={"company_name": company_name})
336
- return response.json()
337
-
338
- def get_company_info(self, cik):
339
- """Get company information"""
340
- url = f"{self.base_url}/api/get_company_info"
341
- response = requests.post(url, json={"cik": cik})
342
- return response.json()
343
-
344
- def get_company_filings(self, cik, form_types=None):
345
- """Get company filings"""
346
- url = f"{self.base_url}/api/get_company_filings"
347
- payload = {"cik": cik, "form_types": form_types}
348
- response = requests.post(url, json=payload)
349
- return response.json()
350
-
351
- def get_company_facts(self, cik):
352
- """Get company facts"""
353
- url = f"{self.base_url}/api/get_company_facts"
354
- response = requests.post(url, json={"cik": cik})
355
- return response.json()
356
-
357
- def get_financial_data(self, cik, period):
358
- """Get financial data for period"""
359
- url = f"{self.base_url}/api/get_financial_data"
360
- payload = {"cik": cik, "period": period}
361
- response = requests.post(url, json=payload)
362
- return response.json()
363
-
364
-
365
- # Usage example
366
- if __name__ == "__main__":
367
- # Initialize client
368
- client = SECMCPClient("https://your-space-name.hf.space")
369
-
370
- # Search for a company
371
- company = client.search_company("NVIDIA")
372
- print(f"Found: {company['name']} (CIK: {company['cik']})")
373
-
374
- # Get company information
375
- info = client.get_company_info(company['cik'])
376
- print(f"Industry: {info['sic_description']}")
377
-
378
- # Get recent filings
379
- filings = client.get_company_filings(company['cik'], ["10-K"])
380
- print(f"Recent 10-K filings: {len(filings['filings'])}")
381
-
382
- # Get financial data for 2024
383
- financial_data = client.get_financial_data(company['cik'], "2024")
384
- print(f"FY2024 Revenue: ${financial_data['total_revenue']:,.0f}")
385
- print(f"FY2024 Net Income: ${financial_data['net_income']:,.0f}")
386
- print(f"FY2024 EPS: ${financial_data['earnings_per_share']:.2f}")
387
- ```
388
-
389
- ---
390
-
391
- ## Complete JavaScript/Node.js Client Example
392
-
393
- ```javascript
394
- const axios = require('axios');
395
-
396
- class SECMCPClient {
397
- constructor(baseUrl) {
398
- this.baseUrl = baseUrl.replace(/\/$/, '');
399
- }
400
-
401
- async searchCompany(companyName) {
402
- const response = await axios.post(
403
- `${this.baseUrl}/api/search_company`,
404
- { company_name: companyName }
405
- );
406
- return response.data;
407
- }
408
-
409
- async getCompanyInfo(cik) {
410
- const response = await axios.post(
411
- `${this.baseUrl}/api/get_company_info`,
412
- { cik: cik }
413
- );
414
- return response.data;
415
- }
416
-
417
- async getCompanyFilings(cik, formTypes = null) {
418
- const response = await axios.post(
419
- `${this.baseUrl}/api/get_company_filings`,
420
- { cik: cik, form_types: formTypes }
421
- );
422
- return response.data;
423
- }
424
-
425
- async getCompanyFacts(cik) {
426
- const response = await axios.post(
427
- `${this.baseUrl}/api/get_company_facts`,
428
- { cik: cik }
429
- );
430
- return response.data;
431
- }
432
-
433
- async getFinancialData(cik, period) {
434
- const response = await axios.post(
435
- `${this.baseUrl}/api/get_financial_data`,
436
- { cik: cik, period: period }
437
- );
438
- return response.data;
439
- }
440
- }
441
-
442
- // Usage example
443
- (async () => {
444
- const client = new SECMCPClient('https://your-space-name.hf.space');
445
-
446
- // Search for a company
447
- const company = await client.searchCompany('NVIDIA');
448
- console.log(`Found: ${company.name} (CIK: ${company.cik})`);
449
-
450
- // Get financial data
451
- const financialData = await client.getFinancialData(company.cik, '2024');
452
- console.log(`FY2024 Revenue: $${financialData.total_revenue.toLocaleString()}`);
453
- console.log(`FY2024 Net Income: $${financialData.net_income.toLocaleString()}`);
454
- console.log(`FY2024 EPS: $${financialData.earnings_per_share.toFixed(2)}`);
455
- })();
456
- ```
457
-
458
- ---
459
-
460
- ## Error Handling
461
-
462
- All endpoints return standard HTTP status codes:
463
-
464
- - **200 OK**: Successful request
465
- - **422 Unprocessable Entity**: Invalid request parameters
466
- - **500 Internal Server Error**: Server error
467
-
468
- Error response format:
469
- ```json
470
- {
471
- "detail": "Error message description"
472
- }
473
- ```
474
-
475
- Or for API-specific errors:
476
- ```json
477
- {
478
- "error": "No company found matching 'INVALID_NAME'"
479
- }
480
- ```
481
-
482
- ---
483
-
484
- ## Notes
485
-
486
- - All monetary values are in USD (original values, not converted to millions)
487
- - The `earnings_per_share` value is per share
488
- - Data source: US SEC EDGAR system
489
- - Supports US-GAAP and IFRS standards
490
- - User-Agent: Juntao Peng (jtyxabc@gmail.com)
491
- - Rate limiting follows SEC EDGAR API guidelines (10 requests per second)
492
-
493
- ---
494
-
495
- ## Interactive API Documentation
496
-
497
- Once deployed, you can access interactive API documentation at:
498
-
499
- - Swagger UI: `https://your-space-name.hf.space/docs`
500
- - ReDoc: `https://your-space-name.hf.space/redoc`