|
| 1 | +# Installation and Setup |
| 2 | + |
| 3 | +This guide will help you set up your environment to use the StormParse API. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Python 3.7 or higher |
| 8 | +- pip package manager |
| 9 | +- Access to a StormParse API endpoint |
| 10 | + |
| 11 | +## API Reference |
| 12 | +- [https://abit.ly/stormparse-teddynote-api](abit.ly/stormparse-teddynote-api) |
| 13 | + |
| 14 | + |
| 15 | +## Installation Steps |
| 16 | + |
| 17 | +### 1. Install Required Dependencies |
| 18 | + |
| 19 | +The only required dependency is the `requests` library for making HTTP requests: |
| 20 | + |
| 21 | +```bash |
| 22 | +pip install requests |
| 23 | +``` |
| 24 | + |
| 25 | +### 2. Verify Installation |
| 26 | + |
| 27 | +Create a test script to verify everything is working: |
| 28 | + |
| 29 | +```python |
| 30 | +# test_setup.py |
| 31 | +import requests |
| 32 | + |
| 33 | +# Test that requests is installed |
| 34 | +try: |
| 35 | + import requests |
| 36 | + print("✅ requests library installed successfully!") |
| 37 | + |
| 38 | + # Test API connection (replace with your API URL) |
| 39 | + api_url = "https://live-storm-apis-parse-router.sionic.im" |
| 40 | + try: |
| 41 | + response = requests.get(api_url) |
| 42 | + print(f"✅ Connected to API at {api_url}") |
| 43 | + except requests.exceptions.ConnectionError: |
| 44 | + print(f"⚠️ Could not connect to API at {api_url}") |
| 45 | + print(" Make sure the StormParse API server is running") |
| 46 | + |
| 47 | +except ImportError: |
| 48 | + print("❌ requests library not found. Please install with: pip install requests") |
| 49 | +``` |
| 50 | + |
| 51 | +Run the test: |
| 52 | + |
| 53 | +```bash |
| 54 | +python test_setup.py |
| 55 | +``` |
| 56 | + |
| 57 | +## Configuration |
| 58 | + |
| 59 | +### API Endpoint |
| 60 | + |
| 61 | +You'll need to know your StormParse API endpoint URL. Common configurations: |
| 62 | + |
| 63 | +```python |
| 64 | +# Local development |
| 65 | +API_URL = "https://live-storm-apis-parse-router.sionic.im" |
| 66 | + |
| 67 | +# Production server (example) |
| 68 | +API_URL = "https://api.your-domain.com" |
| 69 | + |
| 70 | +# Using environment variables (recommended) |
| 71 | +import os |
| 72 | +API_URL = os.getenv("STORMPARSE_API_URL", "https://live-storm-apis-parse-router.sionic.im") |
| 73 | +``` |
| 74 | + |
| 75 | +### Basic API Test |
| 76 | + |
| 77 | +Test the API endpoints directly: |
| 78 | + |
| 79 | +```python |
| 80 | +import requests |
| 81 | + |
| 82 | +# Your API configuration |
| 83 | +API_BASE_URL = "https://live-storm-apis-parse-router.sionic.im" |
| 84 | +API_KEY = "demo_test" # Replace with your API key |
| 85 | + |
| 86 | +# Test endpoints |
| 87 | +upload_endpoint = f"{API_BASE_URL}/api/v1/parsing/upload" |
| 88 | +status_endpoint = f"{API_BASE_URL}/api/v1/parsing/job/{{job_id}}" |
| 89 | + |
| 90 | +print(f"Upload endpoint: {upload_endpoint}") |
| 91 | +print(f"Status endpoint: {status_endpoint}") |
| 92 | + |
| 93 | +# Test with authorization |
| 94 | +headers = { |
| 95 | + 'Authorization': f'Bearer {API_KEY}', |
| 96 | + 'Accept': '*/*' |
| 97 | +} |
| 98 | + |
| 99 | +# Note: You'll need to include these headers in all API requests |
| 100 | +``` |
| 101 | + |
| 102 | +## Understanding the API |
| 103 | + |
| 104 | +StormParse uses a simple two-step process: |
| 105 | + |
| 106 | +1. **Upload** - POST your document to `/api/v1/parsing/upload` |
| 107 | + - Returns a `job_id` |
| 108 | + |
| 109 | +2. **Check Status & Get Results** - GET from `/api/v1/parsing/job/{job_id}` |
| 110 | + - Returns job status and parsed content when complete |
| 111 | + |
| 112 | +## Troubleshooting |
| 113 | + |
| 114 | +### Common Issues |
| 115 | + |
| 116 | +1. **Connection refused error** |
| 117 | + - Verify the API server is running |
| 118 | + - Check the API URL is correct |
| 119 | + - Ensure no firewall is blocking the connection |
| 120 | + |
| 121 | +2. **requests not found** |
| 122 | + ```bash |
| 123 | + pip install requests |
| 124 | + ``` |
| 125 | + |
| 126 | +3. **SSL Certificate errors (for HTTPS endpoints)** |
| 127 | + ```python |
| 128 | + # For development only - not recommended for production |
| 129 | + import requests |
| 130 | + from requests.packages.urllib3.exceptions import InsecureRequestWarning |
| 131 | + requests.packages.urllib3.disable_warnings(InsecureRequestWarning) |
| 132 | + |
| 133 | + # Make requests with verify=False |
| 134 | + response = requests.get(api_url, verify=False) |
| 135 | + ``` |
| 136 | + |
| 137 | +## Next Steps |
| 138 | + |
| 139 | +Now that you have the environment set up, proceed to [Your First Parse](./02-first-parse.md) to start parsing documents! |
0 commit comments