Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sebamar88/bytekit/llms.txt

Use this file to discover all available pages before exploring further.

The ByteKit CLI provides powerful tools for inspecting APIs and generating TypeScript types directly from your terminal.

Installation

Install ByteKit globally to use the CLI:
npm install -g bytekit
Or use it directly with npx:
npx bytekit --help

Available Commands

The CLI supports three main modes of operation:

1. Simple API Fetching

Fetch and display API responses without any type generation:
bytekit https://api.example.com/users
Output:
📡 Fetching GET https://api.example.com/users...
[
  {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com"
  }
]

2. Type Generation

Generate TypeScript types from a single API endpoint:
bytekit --type https://api.example.com/users
See Type Generation for detailed usage.

3. Swagger/OpenAPI Integration

Generate all TypeScript DTOs from a Swagger specification:
bytekit --swagger https://api.example.com/swagger.json
See Swagger Integration for detailed usage.

Command-Line Options

OptionDescriptionDefault
--typeGenerate TypeScript types from API responseSaves to src/types/{endpoint}.ts
--swaggerGenerate all TypeScript DTOs from Swagger/OpenAPI specSaves to src/types/api-docs.ts
--method=<METHOD>HTTP method (GET, POST, PUT, DELETE, PATCH)GET
--body=<json>JSON body for the requestNone
--header=<key:val>Custom HTTP header (can be used multiple times)None
--headers=<key:val>Alias for --headerNone
--help, -hDisplay help information-

Help Output

Run bytekit --help to see all available options:
bytekit CLI - API Inspection & Type Generation

Usage:
  bytekit [options] <url>

Options:
  --type                Generate TypeScript types from a single API response.
                        Saves to src/types/{endpoint}.ts
  --swagger             Generate all TypeScript DTOs from a Swagger/OpenAPI spec.
                        Saves to src/types/api-docs.ts
  --method=<METHOD>     HTTP method (GET, POST, PUT, DELETE, PATCH). Default: GET.
  --body=<body>         JSON body for the request.
  --header=<key:val>    Custom HTTP header (can be used multiple times).
  --headers=<key:val>   Alias for --header.

Examples:
  bytekit https://api.example.com/users
  bytekit --type https://api.example.com/users
  bytekit --swagger https://api.example.com/swagger.json
  bytekit --type --method=POST --body='{"name":"test"}' https://api.example.com/users

Common Use Cases

Inspecting an API Endpoint

Quickly test an API endpoint without writing any code:
bytekit https://jsonplaceholder.typicode.com/posts/1

Generating Types for a REST API

Fetch user data and generate TypeScript interfaces:
bytekit --type https://api.example.com/users/123
This creates src/types/users.ts with inferred types.

Working with POST Requests

Generate types from a POST endpoint with a request body:
bytekit --type --method=POST --body='{"username":"test"}' https://api.example.com/login

Adding Custom Headers

Include authentication or custom headers:
bytekit --type --header="Authorization: Bearer token123" https://api.example.com/protected

Multiple Headers

Add multiple headers to your request:
bytekit --type \
  --header="Authorization: Bearer token123" \
  --header="X-API-Key: abc123" \
  https://api.example.com/data

Error Handling

The CLI provides clear error messages for common issues: Missing URL:
bytekit --type
# Error: Missing URL
HTTP Errors:
bytekit https://api.example.com/invalid
# Error: HTTP 404: Not Found
Network Errors:
bytekit https://invalid-domain.example
# Error: fetch failed

Output Directory

Generated type files are automatically saved to:
  • Type Generation: src/types/{endpoint}.ts
  • Swagger Generation: src/types/api-docs.ts
The CLI creates the src/types/ directory if it doesn’t exist.

Next Steps

Type Generation

Learn how to generate TypeScript types from API endpoints

Swagger Integration

Generate types from OpenAPI/Swagger specifications

Build docs developers (and LLMs) love