Skip to content

Commit fde6cdf

Browse files
committed
added http_inspector_client
1 parent 1bfc14f commit fde6cdf

8 files changed

Lines changed: 760 additions & 90 deletions

File tree

.env.example

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,18 @@ AUTH_PASSWORD=my_super_secret_password
2828
SESSION_RESTORE_ENABLED=false
2929

3030
# Enable raw full URL feature (disabled by default).
31-
RAW_FULL_URL=false
31+
RAW_FULL_URL=false
32+
33+
# Base URL of the HTTP Inspector instance
34+
# Default: http://localhost:3000
35+
HTTP_INSPECTOR_URL=http://localhost:3000
36+
37+
# Default token ID to use for operations (optional)
38+
# Can be either the full UUID or 8-character friendly ID
39+
# Example: 550e8400-e29b-41d4-a716-446655440000 or abc12345
40+
HTTP_INSPECTOR_TOKEN=
41+
42+
# Secret for accessing user tokens (optional)
43+
# Required when accessing tokens created via the web UI
44+
# Must be the session ID (UUID) that created the token
45+
HTTP_INSPECTOR_SECRET=

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ prisma/dev.*
2525
nextjs-based/*
2626
llm*.txt
2727
nextjs-based/
28+
__pycache__

README.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,35 @@ The UI is available at http://localhost:3001 and the container persists until yo
7272
| **AUTH_PASSWORD** | No | **-** | Password required for login when authentication is enabled |
7373
| **SESSION_RESTORE_ENABLED** | No | **true** | Enable restoring previous sessions by friendly ID |
7474
| **RAW_FULL_URL** | No | **false** | Include full URL in raw request output |
75+
| **ENABLE_LLM_ENDPOINT** | No | **false** | Enable LLM API endpoints for programmatic access |
76+
77+
## Python Client
78+
79+
A Python client library and CLI tool is available for programmatic access to the LLM API endpoints. The client provides:
80+
81+
- **Token Management**: Create, get, update, and delete webhook tokens
82+
- **Request Inspection**: View captured requests and their details
83+
- **Response Configuration**: Set custom responses for webhook endpoints
84+
- **Environment Configuration**: Configure via environment variables
85+
86+
### Quick Start
87+
88+
```bash
89+
# Get API information
90+
./bin/http_inspector_client info
91+
92+
# Create a webhook token
93+
./bin/http_inspector_client create
94+
95+
# View captured requests
96+
./bin/http_inspector_client get <token-id>
97+
98+
# Get latest request
99+
./bin/http_inspector_client latest <token-id>
100+
101+
# Configure custom response
102+
./bin/http_inspector_client update <token-id> --status 201 --body "Created"
103+
```
75104

76105
## API Reference
77106

@@ -393,6 +422,124 @@ Report authentication status.
393422
}
394423
```
395424

425+
### LLM API
426+
427+
The LLM API provides programmatic access designed for automation tools and LLMs. **Must be enabled with `ENABLE_LLM_ENDPOINT=true`.**
428+
429+
**Key Features:**
430+
- Tokens created via this API are associated with a static LLM session
431+
- No authentication required for LLM-created tokens
432+
- User tokens can be accessed read-only with `?secret=UUID` parameter
433+
- Tokens identified by UUID or 8-character friendlyId
434+
435+
#### GET /api/llm
436+
Get API information and documentation.
437+
438+
**Response:**
439+
```json
440+
{
441+
"name": "HTTP Inspector LLM API",
442+
"version": "1.0.0",
443+
"description": "API endpoints designed for programmatic access",
444+
"endpoints": [...],
445+
"notes": [...]
446+
}
447+
```
448+
449+
#### POST /api/llm/token
450+
Create a new payload token in the LLM session.
451+
452+
**Response:**
453+
```json
454+
{
455+
"id": "550e8400-e29b-41d4-a716-446655440000",
456+
"friendlyId": "abc12345",
457+
"sessionId": "llm-session-static-id",
458+
"createdAt": "2025-01-15T10:30:00.000Z",
459+
"payloadUrl": "http://localhost:3000/api/payload/abc12345",
460+
"responseEnabled": false,
461+
"responseStatus": 200,
462+
"responseHeaders": null,
463+
"responseBody": null
464+
}
465+
```
466+
467+
#### GET /api/llm/token/:token
468+
Get token details and all captured requests.
469+
470+
**Parameters:**
471+
- `:token` - Token ID (UUID) or friendlyId (8-char)
472+
- `?secret=UUID` - Required for user tokens (read-only access)
473+
474+
**Response:**
475+
```json
476+
{
477+
"token": {
478+
"id": "550e8400-e29b-41d4-a716-446655440000",
479+
"friendlyId": "abc12345",
480+
"createdAt": "2025-01-15T10:30:00.000Z",
481+
"payloadUrl": "http://localhost:3000/api/payload/abc12345"
482+
},
483+
"requests": [
484+
{
485+
"id": "650e8400-e29b-41d4-a716-446655440000",
486+
"method": "POST",
487+
"url": "/api/payload/abc12345?test=1",
488+
"headers": {"content-type": "application/json"},
489+
"contentType": "application/json",
490+
"contentLength": 42,
491+
"isBinary": false,
492+
"body": "{\"test\":\"data\"}",
493+
"clientIp": "192.168.1.100",
494+
"remoteIp": "203.0.113.1",
495+
"createdAt": "2025-01-15T10:30:00.000Z"
496+
}
497+
],
498+
"total": 1
499+
}
500+
```
501+
502+
**Notes:** Binary data in request bodies is marked as `[Binary data not included]`.
503+
504+
#### GET /api/llm/token/:token/latest
505+
Get the most recent request for a token.
506+
507+
**Parameters:**
508+
- `:token` - Token ID (UUID) or friendlyId (8-char)
509+
- `?secret=UUID` - Required for user tokens (read-only access)
510+
511+
**Response:** Single request object (same format as requests array above).
512+
513+
**Returns `404`** if no requests exist for the token.
514+
515+
#### PATCH /api/llm/token/:token
516+
Update token response settings. **LLM tokens only** (user tokens not allowed).
517+
518+
**Parameters:**
519+
- `:token` - Token ID (UUID) or friendlyId (8-char)
520+
521+
**Request Body:**
522+
```json
523+
{
524+
"responseEnabled": true,
525+
"responseStatus": 201,
526+
"responseHeaders": "{\"Content-Type\":\"application/json\"}",
527+
"responseBody": "{\"status\":\"created\"}"
528+
}
529+
```
530+
531+
All fields are optional. Configure what the webhook endpoint returns when it receives requests.
532+
533+
**Response:** `{ "ok": true }`
534+
535+
#### DELETE /api/llm/token/:token
536+
Delete a token and all its associated requests. **LLM tokens only** (user tokens not allowed).
537+
538+
**Parameters:**
539+
- `:token` - Token ID (UUID) or friendlyId (8-char)
540+
541+
**Response:** `{ "ok": true }`
542+
396543
### Standard Responses
397544

398545
Common status codes:

0 commit comments

Comments
 (0)