apilens-cli
v0.1.3
Published
A lightweight CLI toolkit for inspecting APIs, HTTP behavior, performance, CORS, security headers, and responses.
Maintainers
Readme
🔎 APILens
«Inspect. Understand. Debug.»
APILens is a lightweight command-line toolkit for inspecting APIs and understanding how they behave.
It analyzes API availability, response performance, HTTPS configuration, security headers, CORS policies, redirects, HTTP methods, response structure, content types, and more — directly from your terminal.
✨ Features
- 📡 API Availability — Check whether an endpoint is reachable and inspect its HTTP status.
- ⚡ Response Performance — Measure request latency and classify response speed.
- 🔐 Security Inspection — Check HTTPS and common security-related response headers.
- 🌐 CORS Detection — Inspect common Cross-Origin Resource Sharing headers.
- ↪️ Redirect Detection — Detect redirects and display their destinations.
- 🔧 HTTP Methods — Inspect the server's advertised "Allow" methods.
- 📊 JSON Analysis — Validate and inspect JSON responses.
- 🧩 Response Structure — Detect objects, arrays, item counts, and object keys.
- 📦 Response Size — Measure the size of the returned response.
- 📄 Content-Type Detection — Identify JSON, HTML, plain text, and other response types.
- 📤 Custom Headers — Send custom HTTP request headers.
- 💻 Simple CLI — Designed to be quick and easy to use from the terminal.
- 🪶 Lightweight — Minimal setup and dependency-friendly.
📋 Table of Contents
- Requirements
- Installation
- Usage
- Testing APILens
- Custom Request Headers
- What APILens Checks
- Example Output
- CLI Options
- Notes
Requirements
Before installing APILens, make sure you have:
- Node.js 20 or newer
- npm
- An active internet connection
You can check your Node.js version with:
node --versionInstallation
Install APILens globally using npm:
npm install -g apilens-cliVerify that the installation was successful:
apilens --versionTo view the available commands and options:
apilens --helpUsage
The basic syntax is:
apilens <url>Example
apilens https://jsonplaceholder.typicode.com/postsAPILens sends a request to the specified endpoint and generates an inspection report directly in your terminal.
Testing APILens
You can test APILens using publicly accessible APIs.
JSONPlaceholder
apilens https://jsonplaceholder.typicode.com/postsHTTPBin
apilens https://httpbin.org/jsonExample.com
apilens https://example.comTesting Custom Headers
apilens https://httpbin.org/headers --header "X-Test: APILens"Custom Request Headers
APILens supports custom HTTP request headers using:
--header
or the shorter:
-H
Example
apilens https://httpbin.org/headers --header "X-Test: APILens"Multiple headers can also be supplied.
Windows PowerShell
apilens https://httpbin.org/headers --header "X-Test: APILens" --header "X-Environment: Development"Linux / macOS
apilens https://httpbin.org/headers
--header "X-Test: APILens"
--header "X-Environment: Development"
APILens sends the supplied headers with the request and reports the request information as part of the inspection.
🔍 What APILens Checks
Availability
APILens checks whether the target endpoint can be reached and reports its HTTP status.
Example:
📡 AVAILABILITY
Status ✓ 200 OK
Connection ✓ Reachable
If the endpoint cannot be reached, APILens reports the reason and exits with an error status.
Performance
APILens measures the approximate response latency of the request.
Example:
⚡ PERFORMANCE
Latency 320ms
Assessment ✓ Fast
Response-Time Classification
Response Time| Assessment
"< 500ms"| ✓ Fast
"500–999ms"| ⚠ Moderate
"1000ms+"| 🔴 Slow
Response time can vary depending on your network connection, server location, API load, and other environmental factors.
Security
APILens checks whether the endpoint uses HTTPS and inspects several security-related response headers.
Currently Checked
- "Strict-Transport-Security"
- "Content-Security-Policy"
- "X-Frame-Options"
- "X-Content-Type-Options"
- "Referrer-Policy"
Example:
🔐 SECURITY
HTTPS ✓ Enabled
HSTS ⚠ Missing
Content-Security-Policy ⚠ Missing
X-Frame-Options ⚠ Missing
X-Content-Type-Options ✓ Present
Referrer-Policy ⚠ Missing
«Note: A missing security header does not automatically mean that an API is vulnerable. APILens provides inspection signals that can help developers investigate an endpoint further.»
CORS
APILens checks common Cross-Origin Resource Sharing (CORS) response headers.
It can detect:
- "Access-Control-Allow-Origin"
- "Access-Control-Allow-Methods"
- "Access-Control-Allow-Headers"
- "Access-Control-Allow-Credentials"
Example:
🌐 CORS
Origin ✓
Credentials ✓ true
If no CORS policy is detected:
🌐 CORS
Policy ⚠ Not detected
CORS behavior can depend on the request origin and server configuration.
Redirects
APILens detects HTTP redirects and reports the destination when available.
Example:
↪️ REDIRECTS
Status ⚠ Redirect detected
Destination → https://example.com/ \
If there is no redirect:
↪️ REDIRECTS
Status ✓ No redirect \
HTTP Methods
APILens checks whether the server advertises supported HTTP methods through the "Allow" response header.
Example:
🔧 HTTP METHODS
Allow ✓ GET, POST, PUT, DELETE
If the server does not advertise the header:
🔧 HTTP METHODS
Allow ⚠ Not advertised
«Note: Not advertising an "Allow" header does not necessarily mean that other HTTP methods are unavailable.»
Response Analysis
APILens analyzes the returned response body.
For JSON responses, it checks:
- JSON validity
- Response structure
- Object or array type
- Number of items
- Object keys
- Response size
Example:
📊 RESPONSE ANALYSIS
Type json
Size 26.88 KB
JSON ✓ Valid
Structure array
Items 100
Keys userId, id, title, body
Object Response
For an object response:
📊 RESPONSE ANALYSIS
Type json
Size 0.29 KB
JSON ✓ Valid
Structure object
Keys headers
Content
APILens reports the response "Content-Type".
Example:
📄 CONTENT
Type application/json; charset=utf-8
This allows you to quickly identify whether an endpoint returned:
- JSON
- HTML
- Plain text
- XML
- or another content type
Example Output
Running:
apilens https://jsonplaceholder.typicode.com/postsmay produce output similar to:
╭────────────────────────────────────────╮
│ 🔎 APILENS │
│ API Inspection Toolkit │
╰────────────────────────────────────────╯ \
TARGET https://jsonplaceholder.typicode.com/posts
────────────────────────────────────────
📤 REQUEST
Method GET
Headers None \
📡 AVAILABILITY
Status ✓ 200 OK
Connection ✓ Reachable \
⚡ PERFORMANCE
Latency 320ms
Assessment ✓ Fast \
🔐 SECURITY
HTTPS ✓ Enabled
HSTS ⚠ Missing
Content-Security-Policy ⚠ Missing
X-Frame-Options ⚠ Missing
X-Content-Type-Options ✓ Present
Referrer-Policy ⚠ Missing \
🌐 CORS
Policy ⚠ Not detected
↪️ REDIRECTS
Status ✓ No redirect
🔧 HTTP METHODS
Allow ⚠ Not advertised
📊 RESPONSE ANALYSIS
Type json
Size 26.88 KB
JSON ✓ Valid
Structure array
Items 100
Keys userId, id, title, body
📄 CONTENT
Type application/json; charset=utf-8
────────────────────────────────────────
🔎 APILENS • Inspect. Understand. Debug.
──────────────────────────────────────── \
«Response times, headers, CORS policies, and other results will vary depending on the API being tested.»
CLI Options
Display the Help Menu
apilens --helpDisplay the Installed Version
apilens --versionInspect an API
apilens <url>Add a Custom Request Header
apilens <url> --header "Name: Value"or:
apilens <url> -H "Name: Value"Multiple Headers
Linux / macOS:
apilens
--header "X-Test: APILens"
--header "X-Environment: Development"
Windows PowerShell:
apilens --header "X-Test: APILens" --header "X-Environment: Development"
🧭 Why APILens?
When working with an unfamiliar API, developers often need to manually check multiple things:
- Is the endpoint reachable?
- How fast is it responding?
- Is HTTPS enabled?
- Which security headers are present?
- Is CORS configured?
- Did the server redirect the request?
- What HTTP methods are advertised?
- What type of data was returned?
- Is the response valid JSON?
- What does the response structure look like?
APILens brings these checks together into a single terminal command.
apilens https://api.example.com
Inspect the endpoint. Understand its behavior. Debug faster.
Notes
APILens is an inspection and debugging tool. Its results should be treated as diagnostic information rather than a complete security audit.
Network conditions, server configuration, API behavior, authentication requirements, rate limits, and other factors can affect the results returned by APILens.
🔎 APILens
Inspect. Understand. Debug.
Built for developers who want to understand their APIs without leaving the terminal.
