Skip to content

mohidbt/apic

Repository files navigation

APIIngest - OpenAPI to LLM-Ready Markdown Converter

πŸš€ Web tool that converts OpenAPI YAML/JSON specifications into structured, LLM-friendly markdown optimized for AI codegen assistants. api-ingest.com

Deploy to Koyeb

✨ Features

Converter Features

  • Dereferences $ref schemas β€” Inline references for readability
  • Surfaces authentication β€” Security schemes pulled into each endpoint
  • Base URLs highlighted β€” Server information prominently displayed
  • Runnable examples β€” Auto-generated curl commands with placeholders
  • Strict separators β€” Delimiters prevent boundary confusion (Inspired by GitIngest, see below)
  • Tag grouping β€” Organized by tags, alphabetically sorted
  • Type normalization β€” Clean type display (string (uuid), array, etc.)
  • Token-aware β€” Designed to keep endpoint chunks under 2-4K tokens

πŸš€ Quick Start

Local Development

# Clone the repository
git clone https://github.com/mohidbt/apic.git
cd apic

# Terminal 1 - Start Backend
cd backend
pip install -r requirements.txt
python main.py

# Terminal 2 - Start Frontend
cd frontend
npm install
npm run dev

Then open http://localhost:3000 in your browser!

Using the Converter

  1. Web Interface (Recommended)

    • Open http://localhost:3000
    • Drag and drop your OpenAPI YAML/JSON file
    • Click "Convert to Markdown"
    • Download starts automatically!
  2. Command Line

    cd backend
    python transformation.py ../examples/APIs.guru-swagger.yaml
  3. API Endpoint

    curl -X POST http://localhost:8000/convert \
      -F "file=@openapi-spec.yaml" \
      -o output.md

πŸ“ Project Structure

apiingest/
β”œβ”€β”€ backend/               # FastAPI server
β”‚   β”œβ”€β”€ main.py           # API server with file upload
β”‚   β”œβ”€β”€ transformation.py # Core OpenAPIβ†’Markdown converter
β”‚   β”œβ”€β”€ requirements.txt  # Python dependencies
β”‚   └── README.md         # Backend documentation
β”œβ”€β”€ frontend/             # Next.js web application
β”‚   β”œβ”€β”€ src/              # React components and pages
β”‚   β”œβ”€β”€ public/           # Static assets
β”‚   β”œβ”€β”€ package.json      # Node dependencies
β”‚   └── .env.example      # Environment variables template
β”œβ”€β”€ examples/             # Example OpenAPI specifications
β”‚   β”œβ”€β”€ APIs.guru-swagger.yaml
β”‚   β”œβ”€β”€ APIs.guru-swagger.json
β”‚   └── README.md
β”œβ”€β”€ docs/                 # Documentation
β”‚   β”œβ”€β”€ SETUP.md         # Detailed setup guide
β”‚   β”œβ”€β”€ DEPLOYMENT.md    # Koyeb deployment instructions
β”‚   └── QUICK_REFERENCE.md
β”œβ”€β”€ .koyeb/              # Deployment configuration
β”‚   └── config.yaml
└── README.md            # This file

πŸ“– Output Format

The generated markdown follows a strict, LLM-optimized structure:

Header Section

# API Title
**Version:** 1.0.0

Brief description...

## Base URLs
  - https://api.example.com β€” Production
  - https://sandbox.api.example.com β€” Sandbox

## Authentication
  - bearerAuth: HTTP BEARER
  - apiKey: API Key (header: X-API-Key)

Endpoint Blocks

Each endpoint uses strict delimiters (inspired by Gitingest):

================================================================================
ENDPOINT: [GET] /users/{id}
TAGS: Users
SUMMARY: Get a user by ID
DESCRIPTION: Retrieves detailed user information...
AUTH: Bearer token

REQUEST
  Path params:
  - id (string (uuid), required)
  Query params:
  - verbose (boolean, optional)
  Body:
  none

RESPONSES
  - 200 (application/json): Success
    - id: string (uuid, required)
    - name: string (required)
    - email: string (email, required)
  - 404: User not found

EXAMPLE (curl)
curl -X GET \
  "https://api.example.com/users/123?verbose=true" \
  -H "Authorization: Bearer $TOKEN"
================================================================================

🎯 Why This Format?

LLM Benefits

  1. Strict Delimiters β€” = bars prevent AI from confusing endpoint boundaries
  2. Dereferenced Schemas β€” No need to chase $ref pointers during code generation
  3. Inline Auth β€” Security requirements visible per-endpoint
  4. Runnable Examples β€” Copy-paste curl commands with placeholder variables
  5. Normalized Types β€” Consistent type display helps pattern recognition
  6. Tag Grouping β€” Logical organization mimics developer thinking
  7. Token-Optimized β€” Chunks designed to fit in context windows

Inspired by Gitingest

This format borrows from Gitingest's approach:

  • Three-section structure (header, TOC, content)
  • Repeated delimiters between entries
  • Stable, deterministic ordering
  • Noise filtering for clarity

🌐 Deployment

Deploy to Koyeb

Two deployment options:

Option 1: Single Service (Recommended for Simple Deployments)

Deploy backend + frontend together in one container.

See KOYEB_SINGLE_SERVICE.md for detailed instructions.

Quick steps:

  1. Use root-level Dockerfile
  2. Set environment variables (PORT, ALLOWED_ORIGINS, etc.)
  3. Deploy as one service
  4. Both services run together via supervisord

Environment Variables:

PORT=8000
ALLOWED_ORIGINS=https://{{ KOYEB_PUBLIC_DOMAIN }}/
NEXT_PUBLIC_API_URL=http://localhost:8000
NODE_ENV=production

Option 2: Two Separate Services (Recommended for Production)

Deploy backend and frontend as independent services.

See docs/DEPLOYMENT.md for complete instructions.

Quick Overview:

  1. Deploy backend service (FastAPI) from backend/ directory
  2. Deploy frontend service (Next.js) from frontend/ directory
  3. Set environment variables for both services
  4. Update CORS settings with deployed URLs

πŸ› οΈ Technology Stack

Backend

  • FastAPI β€” Modern Python web framework
  • uvicorn β€” ASGI server
  • PyYAML β€” YAML parsing
  • Python 3.8+

Frontend

  • Next.js 15 β€” React framework
  • TypeScript β€” Type safety
  • Tailwind CSS β€” Styling
  • shadcn/ui β€” UI components
  • Sonner β€” Toast notifications

πŸ“š Documentation

πŸ§ͺ Testing

Try it with the included examples:

# Backend directory
cd backend

# Convert example spec
python transformation.py ../examples/APIs.guru-swagger.yaml

# Start API server for testing
python main.py

🀝 Contributing

Contributions welcome! This project prioritizes LLM readability over human aesthetics.

Key principles:

  1. Strict structure β€” Consistent delimiters and ordering
  2. Inline critical info β€” Auth, types, examples per endpoint
  3. Token efficiency β€” Truncate where necessary
  4. Deterministic output β€” Same input = same output

πŸ“ License

MIT β€” Feel free to use, modify, and distribute.

πŸ”— Related Projects

  • Gitingest β€” LLM-optimized code repository digests

πŸ’‘ Use Cases

  • AI Coding Assistants β€” Feed API docs to Claude, GPT, etc.
  • API Documentation β€” Generate readable docs from OpenAPI specs
  • Developer Onboarding β€” Clear, structured API references
  • RAG Systems β€” Token-optimized chunks for retrieval
  • Code Generation β€” Help AI understand your API structure

πŸ› Issues & Support

Found a bug or have a question?

πŸŽ‰ Acknowledgments

Built with inspiration from:

  • Gitingest's LLM-friendly formatting approach
  • OpenAPI Specification community
  • Modern web development best practices

Made with ❀️ for developers working with LLMs

About

Let Codegen Agents finally understand API docs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published