ownapi 1.0.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.
Files changed (63) hide show
  1. ownapi-1.0.0/MANIFEST.in +58 -0
  2. ownapi-1.0.0/PKG-INFO +287 -0
  3. ownapi-1.0.0/README.md +268 -0
  4. ownapi-1.0.0/cli.py +1017 -0
  5. ownapi-1.0.0/compiler.py +948 -0
  6. ownapi-1.0.0/core/__init__.py +19 -0
  7. ownapi-1.0.0/core/api_keys.py +523 -0
  8. ownapi-1.0.0/core/auto_repair.py +682 -0
  9. ownapi-1.0.0/core/base_client.py +165 -0
  10. ownapi-1.0.0/core/consent.py +169 -0
  11. ownapi-1.0.0/core/form_automation.py +1044 -0
  12. ownapi-1.0.0/core/hitl_queue.py +886 -0
  13. ownapi-1.0.0/core/onboarding.py +1457 -0
  14. ownapi-1.0.0/core/token_store.py +223 -0
  15. ownapi-1.0.0/healer.py +2074 -0
  16. ownapi-1.0.0/master_mcp.py +193 -0
  17. ownapi-1.0.0/ownapi/__init__.py +94 -0
  18. ownapi-1.0.0/ownapi/cli.py +309 -0
  19. ownapi-1.0.0/ownapi/sdk.py +436 -0
  20. ownapi-1.0.0/ownapi.egg-info/SOURCES.txt +60 -0
  21. ownapi-1.0.0/pyproject.toml +70 -0
  22. ownapi-1.0.0/recorder.py +486 -0
  23. ownapi-1.0.0/registry/coingecko/__init__.py +5 -0
  24. ownapi-1.0.0/registry/coingecko/client.py +84 -0
  25. ownapi-1.0.0/registry/coingecko/schema.json +23 -0
  26. ownapi-1.0.0/registry/edevlet/__init__.py +5 -0
  27. ownapi-1.0.0/registry/edevlet/client.py +54 -0
  28. ownapi-1.0.0/registry/edevlet/schema.json +14 -0
  29. ownapi-1.0.0/registry/enuygun/__init__.py +5 -0
  30. ownapi-1.0.0/registry/enuygun/client.py +78 -0
  31. ownapi-1.0.0/registry/enuygun/schema.json +13 -0
  32. ownapi-1.0.0/registry/github_trending/__init__.py +5 -0
  33. ownapi-1.0.0/registry/github_trending/client.py +90 -0
  34. ownapi-1.0.0/registry/github_trending/schema.json +31 -0
  35. ownapi-1.0.0/registry/hackernews/__init__.py +5 -0
  36. ownapi-1.0.0/registry/hackernews/client.py +90 -0
  37. ownapi-1.0.0/registry/hackernews/schema.json +38 -0
  38. ownapi-1.0.0/registry/hepsiburada/__init__.py +5 -0
  39. ownapi-1.0.0/registry/hepsiburada/client.py +32 -0
  40. ownapi-1.0.0/registry/hepsiburada/schema.json +23 -0
  41. ownapi-1.0.0/registry/linkedin_jobs/__init__.py +5 -0
  42. ownapi-1.0.0/registry/linkedin_jobs/client.py +241 -0
  43. ownapi-1.0.0/registry/linkedin_jobs/schema.json +46 -0
  44. ownapi-1.0.0/registry/pegasus/__init__.py +5 -0
  45. ownapi-1.0.0/registry/pegasus/client.py +141 -0
  46. ownapi-1.0.0/registry/pegasus/schema.json +76 -0
  47. ownapi-1.0.0/registry/thy/__init__.py +5 -0
  48. ownapi-1.0.0/registry/thy/client.py +1796 -0
  49. ownapi-1.0.0/registry/thy/schema.json +46 -0
  50. ownapi-1.0.0/registry/trendyol/__init__.py +5 -0
  51. ownapi-1.0.0/registry/trendyol/client.py +228 -0
  52. ownapi-1.0.0/registry/trendyol/schema.json +30 -0
  53. ownapi-1.0.0/registry/ucak_bileti/client.py +94 -0
  54. ownapi-1.0.0/registry/ucak_bileti/schema.json +47 -0
  55. ownapi-1.0.0/registry/wikipedia/__init__.py +5 -0
  56. ownapi-1.0.0/registry/wikipedia/client.py +64 -0
  57. ownapi-1.0.0/registry/wikipedia/schema.json +31 -0
  58. ownapi-1.0.0/registry/yahoo_finance/__init__.py +5 -0
  59. ownapi-1.0.0/registry/yahoo_finance/client.py +98 -0
  60. ownapi-1.0.0/registry/yahoo_finance/schema.json +22 -0
  61. ownapi-1.0.0/server.py +891 -0
  62. ownapi-1.0.0/setup.cfg +4 -0
  63. ownapi-1.0.0/static/index.html +2401 -0
@@ -0,0 +1,58 @@
1
+ include pyproject.toml
2
+ include README.md
3
+ include healer.py
4
+ include server.py
5
+ include master_mcp.py
6
+ include compiler.py
7
+ include recorder.py
8
+ include cli.py
9
+
10
+ recursive-include ownapi *.py
11
+ recursive-include core *.py
12
+ recursive-include registry *.py schema.json
13
+ recursive-include static *.html *.css *.js
14
+
15
+ prune .sessions
16
+ prune */.sessions
17
+ prune */*/.sessions
18
+ prune .browser_profile
19
+ prune */.browser_profile
20
+ prune */*/.browser_profile
21
+ prune .cursor
22
+ prune .git
23
+ prune .github
24
+ prune .pytest_cache
25
+ prune __pycache__
26
+ prune */__pycache__
27
+ prune */*/__pycache__
28
+ prune tests
29
+ prune test
30
+ prune build
31
+ prune dist
32
+ prune own_api
33
+ prune shadow_api
34
+ prune ownapi.egg-info
35
+ prune own_api.egg-info
36
+ prune shadow_api.egg-info
37
+
38
+ global-exclude captured_traffic.json
39
+ global-exclude session_tokens.json
40
+ global-exclude .env
41
+ global-exclude .env.*
42
+ global-exclude *.env
43
+ global-exclude test_*.py
44
+ global-exclude *_test.py
45
+ global-exclude tests.py
46
+ global-exclude *.pyc
47
+ global-exclude *.pyo
48
+ global-exclude *.pyd
49
+ global-exclude .DS_Store
50
+
51
+ exclude agent_demo.py
52
+ exclude generated_client.py
53
+ exclude generated_mcp.py
54
+ exclude Dockerfile
55
+ exclude OwnAPI-Desktop-Launcher.bat
56
+ exclude requirements.txt
57
+ exclude .gitignore
58
+ exclude .railwayignore
ownapi-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,287 @@
1
+ Metadata-Version: 2.4
2
+ Name: ownapi
3
+ Version: 1.0.0
4
+ Summary: OwnAPI — Enterprise User-Delegated Browser Middleware, Auto-Validated API Compiler, and MCP Engine
5
+ Author: Ali
6
+ License: MIT
7
+ Keywords: own-api,user-delegated,browser-middleware,plaid-style,playwright,mcp,fastmcp
8
+ Requires-Python: >=3.9
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: playwright>=1.40.0
11
+ Requires-Dist: pydantic>=2.0.0
12
+ Requires-Dist: mcp>=1.0.0
13
+ Requires-Dist: typer>=0.9.0
14
+ Requires-Dist: rich>=13.0.0
15
+ Requires-Dist: python-dotenv>=1.0.0
16
+ Requires-Dist: openai>=1.0.0
17
+ Requires-Dist: fastapi>=0.100.0
18
+ Requires-Dist: uvicorn>=0.23.0
19
+
20
+ <div align="center">
21
+
22
+ # ⚡ OwnAPI
23
+
24
+ ### **OwnAPI — The Plaid-Style User-Delegated Browser Middleware for AI Agents. Turn any API-less, WAF-protected website into a self-healing MCP & Function-Calling tool.**
25
+
26
+ [![License: MIT](https://img.shields.io/badge/License-MIT-emerald.svg)](#license)
27
+ [![Python 3.10+](https://img.shields.io/badge/Python-3.10%2B-blue.svg)](https://www.python.org/)
28
+ [![MCP Ready](https://img.shields.io/badge/MCP-Model%20Context%20Protocol-indigo.svg)](#enterprise-web-dashboard--mcp-server)
29
+ [![Registry Validation](https://img.shields.io/badge/Verified%20Registry-11%2F11%20(100%25%203x%20Auto--Test)-success.svg)](#pre-built-registry-marketplace)
30
+ [![Architecture](https://img.shields.io/badge/Architecture-User--Delegated%20Browser%20Tunnel-purple.svg)](#system-architecture)
31
+
32
+ **Zero Proxies · Zero TLS Spoofing · 3x Auto-Validated Connectors · Self-Healing 2.0 · Async HITL Queue · Cryptographic ToS Shield**
33
+
34
+ [Quickstart](#-30-second-quickstart) · [Why OwnAPI?](#-why-ownapi-the-problem-with-scrapers) · [Architecture](#-system-architecture) · [Comparison](#-how-ownapi-compares) · [Pre-Built Marketplace](#-pre-built-registry-marketplace) · [Enterprise REST & Dashboard](#-enterprise-web-dashboard--rest-api)
35
+
36
+ </div>
37
+
38
+ ---
39
+
40
+ ## 🚨 Why OwnAPI? (The Problem with Scrapers)
41
+
42
+ Over **90% of enterprise and consumer workflows**—airlines, local banking portals, legacy ERPs, regional e-commerce platforms, and healthcare systems— either have **no public API** or hide their real capabilities behind undocumented internal XHR/Fetch endpoints protected by **Cloudflare Turnstile, PerimeterX (HUMAN), Akamai Bot Manager, and DataDome**.
43
+
44
+ Today, engineering teams building AI Agents face two broken choices:
45
+
46
+ 1. **Traditional Scrapers (`curl_cffi`, residential proxies, headless Selenium):**
47
+ - **Technically Fragile:** Modern WAFs inspect TLS JA3/JA4 fingerprints, HTTP/2 frame ordering, Canvas/WebGL entropy, and behavioral telemetry. Spoofed requests break within days.
48
+ - **Legally Toxic:** Bypassing access controls from third-party servers using rotating proxy pools violates the Computer Fraud and Abuse Act (CFAA) and website Terms of Service—making it uninvestable and unusable for regulated enterprises.
49
+ 2. **Raw Cloud Browser Infrastructure (Browserbase / Raw Playwright DOM Agents):**
50
+ - **Slow & Expensive:** Letting an LLM click DOM elements step-by-step takes 30–90 seconds per task, burns $0.10–$0.50 in vision/DOM tokens per run, and fails whenever a CSS class changes.
51
+
52
+ ### 🛡️ The OwnAPI Paradigm Shift: User-Delegated Browser Middleware
53
+
54
+ **OwnAPI is not a scraper.** Inspired by how **Plaid** pioneered user-delegated financial connectivity, OwnAPI acts as an **authenticated, user-delegated browser middleware (`User-Delegated In-Browser Fetch Tunnel`)**:
55
+
56
+ - **100% Real Browser Execution (`page.evaluate("fetch(...)")`):** Instead of spoofing TLS packets from a server, OwnAPI executes structured `fetch()` calls directly inside the user's real, authenticated Chromium browser context using the user's genuine IP, hardware fingerprint, and cookies.
57
+ - **Compiler + 3x Auto-Test Validator Loop:** You perform an action once in a browser window. OwnAPI intercepts the underlying JSON XHR/Fetch traffic, synthesizes a clean Python SDK & MCP connector via GPT-4o, and **automatically runs 3 consecutive live validation tests**—self-repairing any schema bugs before registering the tool.
58
+ - **Self-Healing 2.0 (Nightly Auto-Repair):** If a target website changes its internal API schema at 2:00 AM, OwnAPI's `AutoRepairEngine` detects the drift, re-captures live network traffic, rewrites `client.py`, and re-validates it with 3x Auto-Test automatically.
59
+ - **Async Human-in-the-Loop (HITL) Queue:** When running unattended background agents (`non_interactive=True`), if a target site triggers a CAPTCHA or 2FA challenge, the agent never crashes—OwnAPI pauses the task in a persistent `PENDING_USER_APPROVAL` queue so a human operator can solve the challenge with one click from the CLI or Web Dashboard.
60
+ - **Cryptographic ToS & User-Delegation Audit Trail:** Every onboarding and execution logs a SHA-256 signed user-delegation consent record (`.sessions/{tenant_id}/consent_audit.json`), providing enterprise compliance teams with an immutable audit log.
61
+
62
+ ---
63
+
64
+ ## 📊 How OwnAPI Compares
65
+
66
+ | Capability | Traditional Scrapers (`curl_cffi` / Proxies) | Cloud Browser Infra (Browserbase / Raw Playwright) | ⚡ **OwnAPI (User-Delegated Middleware)** |
67
+ | :--- | :---: | :---: | :---: |
68
+ | **Execution Latency** | ~500ms *(until blocked)* | 25s – 90s *(LLM DOM clicking)* | **1.5s – 3.0s *(Direct In-Browser `fetch()`)* ** |
69
+ | **WAF Survival (Cloudflare / PerimeterX / Akamai)** | ❌ Low *(TLS/IP bans)* | ⚠️ Medium *(Datacenter ASN flagged)* | **✅ 100% *(Genuine User Session + HITL Fallback)* ** |
70
+ | **Self-Healing Schema Drift** | ❌ Manual rewrite required | ⚠️ Brittle DOM selectors | **✅ Automated Nightly `AutoRepairEngine` + 3x Validator** |
71
+ | **Legal & ToS Compliance Shield** | ❌ High Risk *(Proxy evasion)* | ⚠️ Grey Area | **✅ Plaid-Style User Delegation + SHA-256 Audit Log** |
72
+ | **Async Human-in-the-Loop (HITL) Queue** | ❌ Crashes on CAPTCHA | ❌ Manual custom code | **✅ Built-in `PENDING_USER_APPROVAL` Queue & Replay** |
73
+ | **MCP & OpenAI Function-Calling Ready** | ❌ Raw HTML/JSON | ❌ Requires custom wrapper | **✅ Instant `master_mcp.py` & Unified `OwnAPIClient`** |
74
+ | **Marginal Cost per Call** | $$$ *(Residential Proxy GBs)* | $$$ *(Vision LLM + Cloud VM mins)* | **$0.00 *(Runs over compiled JSON tunnel)* ** |
75
+
76
+ ---
77
+
78
+ ## 🏗️ System Architecture
79
+
80
+ ```text
81
+ +---------------------------------------------------------------------------------------------------+
82
+ | AI AGENTS & ENTERPRISE CLIENTS |
83
+ | Claude Desktop / Cursor (MCP) | OpenAI Function Calling | REST API & Web UI |
84
+ +-----------------------------------------+-----------------------------+---------------------------+
85
+ |
86
+ v
87
+ +---------------------------------------------------------------------------------------------------+
88
+ | 5. ENTERPRISE WEB DASHBOARD, REST API & MASTER MCP SERVER |
89
+ | server.py (FastAPI + static/index.html) | master_mcp.py (Dynamic FastMCP Tool Router) |
90
+ | own_api/sdk.py (OwnAPIClient) | core/consent.py (SHA-256 ToS Delegation Audit) |
91
+ +---------------------------------------------------------------------------------------------------+
92
+ | | |
93
+ | (1) Onboard & Compile | (2) Execute Tool Call | (3) Nightly Cron (03:00)
94
+ v v v
95
+ +----------------------------------+ +------------------------------------+ +---------------------------------+
96
+ | 1. RECORD, COMPILE & 3x VERIFY | | 2. USER-DELEGATED BROWSER TUNNEL | | 3. SELF-HEALING 2.0 ENGINE |
97
+ | (core/onboarding.py) | | (healer.py & core/token_store) | | (core/auto_repair.py) |
98
+ | | | | | |
99
+ | - Captures live XHR/Fetch JSON | | - Multi-Tenant Isolated Profiles | | - Runs validate_all_services() |
100
+ | - Filters telemetry & noise | | (.sessions/{tenant}/{service}) | | - Detects schema/endpoint drift |
101
+ | - Synthesizes BaseOwnClient code | | - Local Desktop Chrome OR Cloud | | - Re-captures live site traffic |
102
+ | & JSON Schema via GPT-4o | | CDP WebSocket (mode=local|cloud) | | - GPT-4o AST self-repair loop |
103
+ | - Runs 3x Live Auto-Test Loop | | - Executes in-page fetch() with | | - Writes timestamped audit to |
104
+ | - Auto-repairs on failure | | real cookies, IP & WebGL state | | auto_repair_report.json |
105
+ +----------------------------------+ +-----------------+------------------+ +---------------------------------+
106
+ |
107
+ +---------------------+---------------------+
108
+ | WAF / CAPTCHA / 2FA Challenge Detected? |
109
+ +---------------------+---------------------+
110
+ |
111
+ +-----------------------------+-----------------------------+
112
+ | Interactive Mode | Non-Interactive Agent Mode
113
+ v v
114
+ +---------------------------------+ +------------------------------------+
115
+ | Interactive Browser Prompt | | 4. ASYNC HITL APPROVAL QUEUE |
116
+ | - Brings Chrome window to front | | (core/hitl_queue.py) |
117
+ | - User solves CAPTCHA once | | - Enqueues PENDING_USER_APPROVAL |
118
+ | - Harvests fresh cookies | | - Saves to .sessions/hitl_queue |
119
+ | - Replays fetch() automatically | | - 1-Click Approve & Replay via |
120
+ +---------------------------------+ | Web Dashboard or `own-api queue` |
121
+ +------------------------------------+
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 🚀 30-Second Quickstart
127
+
128
+ ### 1. Installation
129
+
130
+ ```bash
131
+ git clone https://github.com/your-org/own-api.git
132
+ cd own-api
133
+ pip install -e .
134
+ playwright install chromium
135
+ ```
136
+
137
+ Configure your OpenAI API key in `.env` (used for natural language routing, zero-code site compilation, and nightly self-healing):
138
+
139
+ ```bash
140
+ echo "OPENAI_API_KEY=sk-your-api-key" > .env
141
+ ```
142
+
143
+ ### 2. Launch the Enterprise Web Dashboard & Live Playground
144
+
145
+ Start the FastAPI server and interactive SaaS Web Dashboard on `http://localhost:8000`:
146
+
147
+ ```bash
148
+ own-api serve --port 8000
149
+ ```
150
+
151
+ Open **`http://localhost:8000`** in your browser to explore:
152
+ - **Registry Marketplace:** Inspect all 11 pre-built connectors with live `3/3 Auto-Test Verified` badges.
153
+ - **Live Playground:** Execute natural language queries (`POST /api/v1/ask`) or direct parameterized tool calls (`POST /api/v1/call`) with real-time latency metrics.
154
+ - **HITL Queue & Self-Healing 2.0:** Trigger full-fleet validation (`POST /api/v1/auto-repair`) or approve pending CAPTCHA/2FA tasks with one click.
155
+ - **ToS Consent Audit:** Inspect cryptographic SHA-256 user-delegation signatures (`GET /api/v1/consent`).
156
+
157
+ ### 3. CLI Commands (`own-api`)
158
+
159
+ ```bash
160
+ # List all registered & 3x-verified connectors
161
+ own-api list
162
+
163
+ # Ask the AI Agent in natural language (automatically selects & runs the right tool)
164
+ own-api ask "What is the current stock price of NVDA on Yahoo Finance?"
165
+ own-api ask "Find the top 5 trending repositories for 'mcp server' on GitHub"
166
+ own-api ask "Search Bitcoin market cap and USD price on CoinGecko"
167
+
168
+ # Call a specific connector directly with JSON parameters
169
+ own-api call yahoo_finance --params '{"symbol": "NVDA"}' --tenant default --mode local
170
+
171
+ # Turn ANY website into a verified API in 60 seconds (Record -> Compile -> 3x Auto-Test)
172
+ own-api add stripe_docs --url "https://docs.stripe.com" --desc "Search Stripe documentation"
173
+
174
+ # Run Self-Healing 2.0 validation & automatic repair across all services
175
+ own-api validate --all
176
+
177
+ # Start the nightly background Self-Healing 2.0 daemon (runs daily at 03:00)
178
+ own-api auto-repair --daemon --schedule "03:00"
179
+
180
+ # Inspect and approve Human-in-the-Loop (HITL) tasks
181
+ own-api queue list
182
+ own-api queue approve <task_id>
183
+ ```
184
+
185
+ ### 4. Python SDK (`OwnAPIClient`)
186
+
187
+ Use `OwnAPIClient` directly inside your LangChain, LlamaIndex, CrewAI, or custom agent pipelines:
188
+
189
+ ```python
190
+ from own_api import OwnAPIClient
191
+
192
+ # Initialize with multi-tenant isolation, execution mode ("local" or "cloud"), and HITL policy
193
+ client = OwnAPIClient(
194
+ tenant_id="enterprise_user_42",
195
+ mode="local", # "local" (user's Chrome) or "cloud" (CDP WebSocket / Docker)
196
+ non_interactive=False, # Set True for background agents to enqueue CAPTCHAs to HITL Queue
197
+ auto_accept_tos=True, # Logs SHA-256 User-Delegation Consent signature
198
+ )
199
+
200
+ # 1. Direct deterministic connector call
201
+ nvda_quote = client.call("yahoo_finance", symbol="NVDA")
202
+ print(nvda_quote["quote"]["regularMarketPrice"])
203
+
204
+ # 2. Natural language agent execution (GPT-4o tool routing)
205
+ answer = client.ask("Compare Bitcoin price on CoinGecko and find top MCP repos on GitHub")
206
+ print(answer)
207
+
208
+ # 3. Export OpenAI Function-Calling / Tool definitions for your own agent loop
209
+ tools = client.get_openai_tools()
210
+ ```
211
+
212
+ ### 5. Connect to Claude Desktop / Cursor (MCP Server)
213
+
214
+ Add `master_mcp.py` to your `claude_desktop_config.json` or `.cursor/mcp.json`:
215
+
216
+ ```json
217
+ {
218
+ "mcpServers": {
219
+ "own-api": {
220
+ "command": "python",
221
+ "args": ["master_mcp.py"]
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ Every connector inside `registry/` is automatically exposed as a strongly-typed MCP tool (`own_yahoo_finance`, `own_coingecko`, `own_github_trending`, `own_thy`, etc.) alongside meta-tools for health diagnostics and HITL queue management.
228
+
229
+ ---
230
+
231
+ ## 🌐 Pre-Built Registry Marketplace
232
+
233
+ OwnAPI ships with **11 pre-built, live-tested connectors** in `registry/`, all verified through our **3x Auto-Test Validator Loop (`100%` pass rate)**:
234
+
235
+ ### 🌍 Global Developer, Finance & Knowledge Connectors
236
+
237
+ | Service ID | Target Platform | Primary Method & Signature | Protection / Mode | Auto-Test Status |
238
+ | :--- | :--- | :--- | :--- | :---: |
239
+ | **`yahoo_finance`** | Yahoo Finance | `get_stock_quote(symbol="NVDA")` | Rate-Limited Financial Edge / In-Browser Tunnel | ✅ `BAŞARILI (3/3)` |
240
+ | **`coingecko`** | CoinGecko | `search_crypto(query="bitcoin")` | Cloudflare WAF / In-Browser Tunnel | ✅ `BAŞARILI (3/3)` |
241
+ | **`github_trending`** | GitHub | `search_repositories(query="mcp server", limit=5)` | GitHub API Edge / In-Browser Tunnel | ✅ `BAŞARILI (3/3)` |
242
+ | **`hackernews`** | Hacker News (Algolia) | `search_stories(query="AI", limit=5)` | Cloudfront / In-Browser Tunnel | ✅ `BAŞARILI (3/3)` |
243
+ | **`wikipedia`** | Wikipedia REST API | `search_summary(query="Artificial intelligence", lang="en")` | Wikimedia Edge / In-Browser Tunnel | ✅ `BAŞARILI (3/3)` |
244
+
245
+ ### ✈️ Enterprise Airlines & E-Commerce Connectors (High-WAF Showcase)
246
+
247
+ | Service ID | Target Platform | Primary Method & Signature | WAF / Bot Protection | Auto-Test Status |
248
+ | :--- | :--- | :--- | :--- | :---: |
249
+ | **`thy`** | Turkish Airlines | `search_flights(origin="IST", destination="SAW", date=...)` | **Akamai + PerimeterX (HUMAN)** | ✅ `BAŞARILI (3/3)` |
250
+ | **`pegasus`** | Pegasus Airlines | `search_flights(origin="SAW", destination="AYT", date=...)` | **Cloudflare Enterprise** | ✅ `BAŞARILI (3/3)` |
251
+ | **`enuygun`** | Enuygun Travel | `search_flights(origin="IST", destination="ADB", date=...)` | **Cloudflare Turnstile** | ✅ `BAŞARILI (3/3)` |
252
+ | **`ucak_bileti`** | Uçak Bileti | `search_flights(origin="IST", destination="ESB", date=...)` | **WAF + Session Token Guard** | ✅ `BAŞARILI (3/3)` |
253
+ | **`trendyol`** | Trendyol E-Commerce | `search_products(query="iphone", limit=5)` | **Cloudflare + Custom Anti-Bot** | ✅ `BAŞARILI (3/3)` |
254
+ | **`hepsiburada`** | Hepsiburada Marketplace | `search_products(query="laptop", limit=5)` | **Akamai Bot Manager** | ✅ `BAŞARILI (3/3)` |
255
+
256
+ ---
257
+
258
+ ## 🖥️ Enterprise Web Dashboard & REST API
259
+
260
+ When you run `own-api serve --port 8000`, `server.py` exposes a complete REST API for your internal microservices alongside the single-page SaaS Dashboard (`static/index.html`):
261
+
262
+ | Endpoint | Method | Description |
263
+ | :--- | :---: | :--- |
264
+ | `/` | `GET` | Serves the 4-tab TailwindCSS Dark-Mode Enterprise Web Dashboard & Live Playground. |
265
+ | `/api/v1/services` | `GET` | Lists all registered services, schemas, `validation_status`, and fleet-wide `validation_rate`. |
266
+ | `/api/v1/call` | `POST` | Executes a deterministic service call (`service`, `params`, `tenant_id`, `mode`, `non_interactive`) with latency tracking. |
267
+ | `/api/v1/ask` | `POST` | Runs the natural language GPT-4o agent across all registered tools (`prompt`, `tenant_id`). |
268
+ | `/api/v1/validate/{service}` | `POST` | Triggers the 3x Auto-Test Validator Loop (+ GPT-4o self-repair if needed) for a single service. |
269
+ | `/api/v1/auto-repair` | `POST` | Triggers `AutoRepairEngine.validate_all_services()` across the entire registry and saves the audit report. |
270
+ | `/api/v1/auto-repair/report` | `GET` | Returns the latest `.sessions/auto_repair_report.json` health & repair telemetry. |
271
+ | `/api/v1/hitl/queue` | `GET` | Returns all `PENDING_USER_APPROVAL` and resolved Human-in-the-Loop tasks. |
272
+ | `/api/v1/hitl/approve/{task_id}` | `POST` | Opens the interactive browser window for the human operator to solve CAPTCHA/2FA and replays the queued request. |
273
+ | `/api/v1/consent` | `GET` | Returns the cryptographic SHA-256 User-Delegation & ToS consent audit trail across all tenants. |
274
+
275
+ ---
276
+
277
+ ## 🔒 Security, Privacy & Legal Architecture
278
+
279
+ 1. **Zero Credential Harvesting:** OwnAPI never asks for or stores plaintext usernames or passwords. Authentication happens directly inside the user's local Chrome profile (`.sessions/{tenant_id}/chrome_profile_{service}`).
280
+ 2. **Multi-Tenant Isolation:** Every tenant's cookies, browser storage, and consent audit logs are strictly isolated under `.sessions/{tenant_id}/`.
281
+ 3. **Explicit User Delegation (`core/consent.py`):** Before onboarding a target site or executing delegated calls, OwnAPI records a timestamped, SHA-256 hashed attestation confirming the user is acting as an authorized human account holder delegating their own browser session.
282
+
283
+ ---
284
+
285
+ ## 📄 License
286
+
287
+ Distributed under the **MIT License**. Built for the global AI Agent ecosystem.
ownapi-1.0.0/README.md ADDED
@@ -0,0 +1,268 @@
1
+ <div align="center">
2
+
3
+ # ⚡ OwnAPI
4
+
5
+ ### **OwnAPI — The Plaid-Style User-Delegated Browser Middleware for AI Agents. Turn any API-less, WAF-protected website into a self-healing MCP & Function-Calling tool.**
6
+
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-emerald.svg)](#license)
8
+ [![Python 3.10+](https://img.shields.io/badge/Python-3.10%2B-blue.svg)](https://www.python.org/)
9
+ [![MCP Ready](https://img.shields.io/badge/MCP-Model%20Context%20Protocol-indigo.svg)](#enterprise-web-dashboard--mcp-server)
10
+ [![Registry Validation](https://img.shields.io/badge/Verified%20Registry-11%2F11%20(100%25%203x%20Auto--Test)-success.svg)](#pre-built-registry-marketplace)
11
+ [![Architecture](https://img.shields.io/badge/Architecture-User--Delegated%20Browser%20Tunnel-purple.svg)](#system-architecture)
12
+
13
+ **Zero Proxies · Zero TLS Spoofing · 3x Auto-Validated Connectors · Self-Healing 2.0 · Async HITL Queue · Cryptographic ToS Shield**
14
+
15
+ [Quickstart](#-30-second-quickstart) · [Why OwnAPI?](#-why-ownapi-the-problem-with-scrapers) · [Architecture](#-system-architecture) · [Comparison](#-how-ownapi-compares) · [Pre-Built Marketplace](#-pre-built-registry-marketplace) · [Enterprise REST & Dashboard](#-enterprise-web-dashboard--rest-api)
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ ## 🚨 Why OwnAPI? (The Problem with Scrapers)
22
+
23
+ Over **90% of enterprise and consumer workflows**—airlines, local banking portals, legacy ERPs, regional e-commerce platforms, and healthcare systems— either have **no public API** or hide their real capabilities behind undocumented internal XHR/Fetch endpoints protected by **Cloudflare Turnstile, PerimeterX (HUMAN), Akamai Bot Manager, and DataDome**.
24
+
25
+ Today, engineering teams building AI Agents face two broken choices:
26
+
27
+ 1. **Traditional Scrapers (`curl_cffi`, residential proxies, headless Selenium):**
28
+ - **Technically Fragile:** Modern WAFs inspect TLS JA3/JA4 fingerprints, HTTP/2 frame ordering, Canvas/WebGL entropy, and behavioral telemetry. Spoofed requests break within days.
29
+ - **Legally Toxic:** Bypassing access controls from third-party servers using rotating proxy pools violates the Computer Fraud and Abuse Act (CFAA) and website Terms of Service—making it uninvestable and unusable for regulated enterprises.
30
+ 2. **Raw Cloud Browser Infrastructure (Browserbase / Raw Playwright DOM Agents):**
31
+ - **Slow & Expensive:** Letting an LLM click DOM elements step-by-step takes 30–90 seconds per task, burns $0.10–$0.50 in vision/DOM tokens per run, and fails whenever a CSS class changes.
32
+
33
+ ### 🛡️ The OwnAPI Paradigm Shift: User-Delegated Browser Middleware
34
+
35
+ **OwnAPI is not a scraper.** Inspired by how **Plaid** pioneered user-delegated financial connectivity, OwnAPI acts as an **authenticated, user-delegated browser middleware (`User-Delegated In-Browser Fetch Tunnel`)**:
36
+
37
+ - **100% Real Browser Execution (`page.evaluate("fetch(...)")`):** Instead of spoofing TLS packets from a server, OwnAPI executes structured `fetch()` calls directly inside the user's real, authenticated Chromium browser context using the user's genuine IP, hardware fingerprint, and cookies.
38
+ - **Compiler + 3x Auto-Test Validator Loop:** You perform an action once in a browser window. OwnAPI intercepts the underlying JSON XHR/Fetch traffic, synthesizes a clean Python SDK & MCP connector via GPT-4o, and **automatically runs 3 consecutive live validation tests**—self-repairing any schema bugs before registering the tool.
39
+ - **Self-Healing 2.0 (Nightly Auto-Repair):** If a target website changes its internal API schema at 2:00 AM, OwnAPI's `AutoRepairEngine` detects the drift, re-captures live network traffic, rewrites `client.py`, and re-validates it with 3x Auto-Test automatically.
40
+ - **Async Human-in-the-Loop (HITL) Queue:** When running unattended background agents (`non_interactive=True`), if a target site triggers a CAPTCHA or 2FA challenge, the agent never crashes—OwnAPI pauses the task in a persistent `PENDING_USER_APPROVAL` queue so a human operator can solve the challenge with one click from the CLI or Web Dashboard.
41
+ - **Cryptographic ToS & User-Delegation Audit Trail:** Every onboarding and execution logs a SHA-256 signed user-delegation consent record (`.sessions/{tenant_id}/consent_audit.json`), providing enterprise compliance teams with an immutable audit log.
42
+
43
+ ---
44
+
45
+ ## 📊 How OwnAPI Compares
46
+
47
+ | Capability | Traditional Scrapers (`curl_cffi` / Proxies) | Cloud Browser Infra (Browserbase / Raw Playwright) | ⚡ **OwnAPI (User-Delegated Middleware)** |
48
+ | :--- | :---: | :---: | :---: |
49
+ | **Execution Latency** | ~500ms *(until blocked)* | 25s – 90s *(LLM DOM clicking)* | **1.5s – 3.0s *(Direct In-Browser `fetch()`)* ** |
50
+ | **WAF Survival (Cloudflare / PerimeterX / Akamai)** | ❌ Low *(TLS/IP bans)* | ⚠️ Medium *(Datacenter ASN flagged)* | **✅ 100% *(Genuine User Session + HITL Fallback)* ** |
51
+ | **Self-Healing Schema Drift** | ❌ Manual rewrite required | ⚠️ Brittle DOM selectors | **✅ Automated Nightly `AutoRepairEngine` + 3x Validator** |
52
+ | **Legal & ToS Compliance Shield** | ❌ High Risk *(Proxy evasion)* | ⚠️ Grey Area | **✅ Plaid-Style User Delegation + SHA-256 Audit Log** |
53
+ | **Async Human-in-the-Loop (HITL) Queue** | ❌ Crashes on CAPTCHA | ❌ Manual custom code | **✅ Built-in `PENDING_USER_APPROVAL` Queue & Replay** |
54
+ | **MCP & OpenAI Function-Calling Ready** | ❌ Raw HTML/JSON | ❌ Requires custom wrapper | **✅ Instant `master_mcp.py` & Unified `OwnAPIClient`** |
55
+ | **Marginal Cost per Call** | $$$ *(Residential Proxy GBs)* | $$$ *(Vision LLM + Cloud VM mins)* | **$0.00 *(Runs over compiled JSON tunnel)* ** |
56
+
57
+ ---
58
+
59
+ ## 🏗️ System Architecture
60
+
61
+ ```text
62
+ +---------------------------------------------------------------------------------------------------+
63
+ | AI AGENTS & ENTERPRISE CLIENTS |
64
+ | Claude Desktop / Cursor (MCP) | OpenAI Function Calling | REST API & Web UI |
65
+ +-----------------------------------------+-----------------------------+---------------------------+
66
+ |
67
+ v
68
+ +---------------------------------------------------------------------------------------------------+
69
+ | 5. ENTERPRISE WEB DASHBOARD, REST API & MASTER MCP SERVER |
70
+ | server.py (FastAPI + static/index.html) | master_mcp.py (Dynamic FastMCP Tool Router) |
71
+ | own_api/sdk.py (OwnAPIClient) | core/consent.py (SHA-256 ToS Delegation Audit) |
72
+ +---------------------------------------------------------------------------------------------------+
73
+ | | |
74
+ | (1) Onboard & Compile | (2) Execute Tool Call | (3) Nightly Cron (03:00)
75
+ v v v
76
+ +----------------------------------+ +------------------------------------+ +---------------------------------+
77
+ | 1. RECORD, COMPILE & 3x VERIFY | | 2. USER-DELEGATED BROWSER TUNNEL | | 3. SELF-HEALING 2.0 ENGINE |
78
+ | (core/onboarding.py) | | (healer.py & core/token_store) | | (core/auto_repair.py) |
79
+ | | | | | |
80
+ | - Captures live XHR/Fetch JSON | | - Multi-Tenant Isolated Profiles | | - Runs validate_all_services() |
81
+ | - Filters telemetry & noise | | (.sessions/{tenant}/{service}) | | - Detects schema/endpoint drift |
82
+ | - Synthesizes BaseOwnClient code | | - Local Desktop Chrome OR Cloud | | - Re-captures live site traffic |
83
+ | & JSON Schema via GPT-4o | | CDP WebSocket (mode=local|cloud) | | - GPT-4o AST self-repair loop |
84
+ | - Runs 3x Live Auto-Test Loop | | - Executes in-page fetch() with | | - Writes timestamped audit to |
85
+ | - Auto-repairs on failure | | real cookies, IP & WebGL state | | auto_repair_report.json |
86
+ +----------------------------------+ +-----------------+------------------+ +---------------------------------+
87
+ |
88
+ +---------------------+---------------------+
89
+ | WAF / CAPTCHA / 2FA Challenge Detected? |
90
+ +---------------------+---------------------+
91
+ |
92
+ +-----------------------------+-----------------------------+
93
+ | Interactive Mode | Non-Interactive Agent Mode
94
+ v v
95
+ +---------------------------------+ +------------------------------------+
96
+ | Interactive Browser Prompt | | 4. ASYNC HITL APPROVAL QUEUE |
97
+ | - Brings Chrome window to front | | (core/hitl_queue.py) |
98
+ | - User solves CAPTCHA once | | - Enqueues PENDING_USER_APPROVAL |
99
+ | - Harvests fresh cookies | | - Saves to .sessions/hitl_queue |
100
+ | - Replays fetch() automatically | | - 1-Click Approve & Replay via |
101
+ +---------------------------------+ | Web Dashboard or `own-api queue` |
102
+ +------------------------------------+
103
+ ```
104
+
105
+ ---
106
+
107
+ ## 🚀 30-Second Quickstart
108
+
109
+ ### 1. Installation
110
+
111
+ ```bash
112
+ git clone https://github.com/your-org/own-api.git
113
+ cd own-api
114
+ pip install -e .
115
+ playwright install chromium
116
+ ```
117
+
118
+ Configure your OpenAI API key in `.env` (used for natural language routing, zero-code site compilation, and nightly self-healing):
119
+
120
+ ```bash
121
+ echo "OPENAI_API_KEY=sk-your-api-key" > .env
122
+ ```
123
+
124
+ ### 2. Launch the Enterprise Web Dashboard & Live Playground
125
+
126
+ Start the FastAPI server and interactive SaaS Web Dashboard on `http://localhost:8000`:
127
+
128
+ ```bash
129
+ own-api serve --port 8000
130
+ ```
131
+
132
+ Open **`http://localhost:8000`** in your browser to explore:
133
+ - **Registry Marketplace:** Inspect all 11 pre-built connectors with live `3/3 Auto-Test Verified` badges.
134
+ - **Live Playground:** Execute natural language queries (`POST /api/v1/ask`) or direct parameterized tool calls (`POST /api/v1/call`) with real-time latency metrics.
135
+ - **HITL Queue & Self-Healing 2.0:** Trigger full-fleet validation (`POST /api/v1/auto-repair`) or approve pending CAPTCHA/2FA tasks with one click.
136
+ - **ToS Consent Audit:** Inspect cryptographic SHA-256 user-delegation signatures (`GET /api/v1/consent`).
137
+
138
+ ### 3. CLI Commands (`own-api`)
139
+
140
+ ```bash
141
+ # List all registered & 3x-verified connectors
142
+ own-api list
143
+
144
+ # Ask the AI Agent in natural language (automatically selects & runs the right tool)
145
+ own-api ask "What is the current stock price of NVDA on Yahoo Finance?"
146
+ own-api ask "Find the top 5 trending repositories for 'mcp server' on GitHub"
147
+ own-api ask "Search Bitcoin market cap and USD price on CoinGecko"
148
+
149
+ # Call a specific connector directly with JSON parameters
150
+ own-api call yahoo_finance --params '{"symbol": "NVDA"}' --tenant default --mode local
151
+
152
+ # Turn ANY website into a verified API in 60 seconds (Record -> Compile -> 3x Auto-Test)
153
+ own-api add stripe_docs --url "https://docs.stripe.com" --desc "Search Stripe documentation"
154
+
155
+ # Run Self-Healing 2.0 validation & automatic repair across all services
156
+ own-api validate --all
157
+
158
+ # Start the nightly background Self-Healing 2.0 daemon (runs daily at 03:00)
159
+ own-api auto-repair --daemon --schedule "03:00"
160
+
161
+ # Inspect and approve Human-in-the-Loop (HITL) tasks
162
+ own-api queue list
163
+ own-api queue approve <task_id>
164
+ ```
165
+
166
+ ### 4. Python SDK (`OwnAPIClient`)
167
+
168
+ Use `OwnAPIClient` directly inside your LangChain, LlamaIndex, CrewAI, or custom agent pipelines:
169
+
170
+ ```python
171
+ from own_api import OwnAPIClient
172
+
173
+ # Initialize with multi-tenant isolation, execution mode ("local" or "cloud"), and HITL policy
174
+ client = OwnAPIClient(
175
+ tenant_id="enterprise_user_42",
176
+ mode="local", # "local" (user's Chrome) or "cloud" (CDP WebSocket / Docker)
177
+ non_interactive=False, # Set True for background agents to enqueue CAPTCHAs to HITL Queue
178
+ auto_accept_tos=True, # Logs SHA-256 User-Delegation Consent signature
179
+ )
180
+
181
+ # 1. Direct deterministic connector call
182
+ nvda_quote = client.call("yahoo_finance", symbol="NVDA")
183
+ print(nvda_quote["quote"]["regularMarketPrice"])
184
+
185
+ # 2. Natural language agent execution (GPT-4o tool routing)
186
+ answer = client.ask("Compare Bitcoin price on CoinGecko and find top MCP repos on GitHub")
187
+ print(answer)
188
+
189
+ # 3. Export OpenAI Function-Calling / Tool definitions for your own agent loop
190
+ tools = client.get_openai_tools()
191
+ ```
192
+
193
+ ### 5. Connect to Claude Desktop / Cursor (MCP Server)
194
+
195
+ Add `master_mcp.py` to your `claude_desktop_config.json` or `.cursor/mcp.json`:
196
+
197
+ ```json
198
+ {
199
+ "mcpServers": {
200
+ "own-api": {
201
+ "command": "python",
202
+ "args": ["master_mcp.py"]
203
+ }
204
+ }
205
+ }
206
+ ```
207
+
208
+ Every connector inside `registry/` is automatically exposed as a strongly-typed MCP tool (`own_yahoo_finance`, `own_coingecko`, `own_github_trending`, `own_thy`, etc.) alongside meta-tools for health diagnostics and HITL queue management.
209
+
210
+ ---
211
+
212
+ ## 🌐 Pre-Built Registry Marketplace
213
+
214
+ OwnAPI ships with **11 pre-built, live-tested connectors** in `registry/`, all verified through our **3x Auto-Test Validator Loop (`100%` pass rate)**:
215
+
216
+ ### 🌍 Global Developer, Finance & Knowledge Connectors
217
+
218
+ | Service ID | Target Platform | Primary Method & Signature | Protection / Mode | Auto-Test Status |
219
+ | :--- | :--- | :--- | :--- | :---: |
220
+ | **`yahoo_finance`** | Yahoo Finance | `get_stock_quote(symbol="NVDA")` | Rate-Limited Financial Edge / In-Browser Tunnel | ✅ `BAŞARILI (3/3)` |
221
+ | **`coingecko`** | CoinGecko | `search_crypto(query="bitcoin")` | Cloudflare WAF / In-Browser Tunnel | ✅ `BAŞARILI (3/3)` |
222
+ | **`github_trending`** | GitHub | `search_repositories(query="mcp server", limit=5)` | GitHub API Edge / In-Browser Tunnel | ✅ `BAŞARILI (3/3)` |
223
+ | **`hackernews`** | Hacker News (Algolia) | `search_stories(query="AI", limit=5)` | Cloudfront / In-Browser Tunnel | ✅ `BAŞARILI (3/3)` |
224
+ | **`wikipedia`** | Wikipedia REST API | `search_summary(query="Artificial intelligence", lang="en")` | Wikimedia Edge / In-Browser Tunnel | ✅ `BAŞARILI (3/3)` |
225
+
226
+ ### ✈️ Enterprise Airlines & E-Commerce Connectors (High-WAF Showcase)
227
+
228
+ | Service ID | Target Platform | Primary Method & Signature | WAF / Bot Protection | Auto-Test Status |
229
+ | :--- | :--- | :--- | :--- | :---: |
230
+ | **`thy`** | Turkish Airlines | `search_flights(origin="IST", destination="SAW", date=...)` | **Akamai + PerimeterX (HUMAN)** | ✅ `BAŞARILI (3/3)` |
231
+ | **`pegasus`** | Pegasus Airlines | `search_flights(origin="SAW", destination="AYT", date=...)` | **Cloudflare Enterprise** | ✅ `BAŞARILI (3/3)` |
232
+ | **`enuygun`** | Enuygun Travel | `search_flights(origin="IST", destination="ADB", date=...)` | **Cloudflare Turnstile** | ✅ `BAŞARILI (3/3)` |
233
+ | **`ucak_bileti`** | Uçak Bileti | `search_flights(origin="IST", destination="ESB", date=...)` | **WAF + Session Token Guard** | ✅ `BAŞARILI (3/3)` |
234
+ | **`trendyol`** | Trendyol E-Commerce | `search_products(query="iphone", limit=5)` | **Cloudflare + Custom Anti-Bot** | ✅ `BAŞARILI (3/3)` |
235
+ | **`hepsiburada`** | Hepsiburada Marketplace | `search_products(query="laptop", limit=5)` | **Akamai Bot Manager** | ✅ `BAŞARILI (3/3)` |
236
+
237
+ ---
238
+
239
+ ## 🖥️ Enterprise Web Dashboard & REST API
240
+
241
+ When you run `own-api serve --port 8000`, `server.py` exposes a complete REST API for your internal microservices alongside the single-page SaaS Dashboard (`static/index.html`):
242
+
243
+ | Endpoint | Method | Description |
244
+ | :--- | :---: | :--- |
245
+ | `/` | `GET` | Serves the 4-tab TailwindCSS Dark-Mode Enterprise Web Dashboard & Live Playground. |
246
+ | `/api/v1/services` | `GET` | Lists all registered services, schemas, `validation_status`, and fleet-wide `validation_rate`. |
247
+ | `/api/v1/call` | `POST` | Executes a deterministic service call (`service`, `params`, `tenant_id`, `mode`, `non_interactive`) with latency tracking. |
248
+ | `/api/v1/ask` | `POST` | Runs the natural language GPT-4o agent across all registered tools (`prompt`, `tenant_id`). |
249
+ | `/api/v1/validate/{service}` | `POST` | Triggers the 3x Auto-Test Validator Loop (+ GPT-4o self-repair if needed) for a single service. |
250
+ | `/api/v1/auto-repair` | `POST` | Triggers `AutoRepairEngine.validate_all_services()` across the entire registry and saves the audit report. |
251
+ | `/api/v1/auto-repair/report` | `GET` | Returns the latest `.sessions/auto_repair_report.json` health & repair telemetry. |
252
+ | `/api/v1/hitl/queue` | `GET` | Returns all `PENDING_USER_APPROVAL` and resolved Human-in-the-Loop tasks. |
253
+ | `/api/v1/hitl/approve/{task_id}` | `POST` | Opens the interactive browser window for the human operator to solve CAPTCHA/2FA and replays the queued request. |
254
+ | `/api/v1/consent` | `GET` | Returns the cryptographic SHA-256 User-Delegation & ToS consent audit trail across all tenants. |
255
+
256
+ ---
257
+
258
+ ## 🔒 Security, Privacy & Legal Architecture
259
+
260
+ 1. **Zero Credential Harvesting:** OwnAPI never asks for or stores plaintext usernames or passwords. Authentication happens directly inside the user's local Chrome profile (`.sessions/{tenant_id}/chrome_profile_{service}`).
261
+ 2. **Multi-Tenant Isolation:** Every tenant's cookies, browser storage, and consent audit logs are strictly isolated under `.sessions/{tenant_id}/`.
262
+ 3. **Explicit User Delegation (`core/consent.py`):** Before onboarding a target site or executing delegated calls, OwnAPI records a timestamped, SHA-256 hashed attestation confirming the user is acting as an authorized human account holder delegating their own browser session.
263
+
264
+ ---
265
+
266
+ ## 📄 License
267
+
268
+ Distributed under the **MIT License**. Built for the global AI Agent ecosystem.