Skip to content

A powerful tool for automatically analyzing and documenting REST APIs with React frontend and Python backend

Notifications You must be signed in to change notification settings

carnal1234/universal-api-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Universal API Generator

A powerful tool for automatically analyzing and documenting REST APIs with a modern React frontend and Python backend.

🌐 Live Demo

Try it now: https://universal-api-generator.onrender.com/

Experience the Universal API Generator in action! The live demo allows you to:

  • Analyze any public API endpoint
  • Generate comprehensive Swagger documentation
  • View interactive API documentation with Swagger UI
  • Test the full functionality without installation

Example APIs to try:

  • https://api.github.com - GitHub API
  • https://jsonplaceholder.typicode.com - JSONPlaceholder API
  • https://api.openf1.org/v1 - OpenF1 API

πŸ“‹ Overview

Universal API Generator is a comprehensive solution that combines:

  • Python Backend: Intelligent API analysis and Swagger specification generation
  • React Frontend: Modern, responsive UI with Swagger UI integration
  • Integrated Server: Single command to run both frontend and backend

πŸ—οΈ Architecture

universal_api_generator/
β”œβ”€β”€ universal_api_backend/     # Python backend
β”‚   β”œβ”€β”€ app.py                # Flask server
β”‚   β”œβ”€β”€ universal_api_generator.py  # Main API analyzer
β”‚   β”œβ”€β”€ swagger_generator.py   # Swagger spec generator
β”‚   β”œβ”€β”€ run_server.py         # Integrated server runner
β”‚   └── requirements.txt      # Python dependencies
β”œβ”€β”€ universal_api_frontend/    # React frontend
β”‚   β”œβ”€β”€ src/                  # React source code
β”‚   β”œβ”€β”€ public/               # Static assets
β”‚   β”œβ”€β”€ package.json          # NPM configuration
β”‚   └── tailwind.config.js    # Tailwind CSS config
└── README.md                 # This file

πŸš€ Quick Start

Option 1: Integrated Server (Recommended)

# Clone the repository
git clone <your-repo-url>
cd universal_api_generator

# Run the integrated server
cd universal_api_backend
python3 run_server.py

# Open http://localhost:5000 in your browser

Option 2: Separate Frontend/Backend

# Backend: Generate API documentation
cd universal_api_backend
python3 universal_api_generator.py https://api.example.com --swagger

# Frontend: Start React development server
cd universal_api_frontend
npm install
npm run dev

πŸ”§ Features

Backend Features

  • βœ… Intelligent Endpoint Discovery: Automatic detection of API endpoints
  • βœ… Custom Endpoint Support: Specify exact endpoints for targeted analysis
  • βœ… Parameter Analysis: Comprehensive parameter type detection and validation
  • βœ… CRUD Operation Detection: Automatic identification of Create, Read, Update, Delete operations
  • βœ… Swagger Generation: Generate OpenAPI/Swagger specifications
  • βœ… Response Schema Analysis: Infer data structures from API responses

Frontend Features

  • βœ… Modern UI: Clean, responsive design inspired by open-lovable
  • βœ… Swagger UI Integration: Professional API documentation viewer
  • βœ… Custom Endpoints: Specify exact endpoints for efficient analysis
  • βœ… Advanced Options: API name, description, and custom endpoint configuration
  • βœ… Tailwind CSS: Modern utility-first styling
  • βœ… Real-time Feedback: Progress indicators and status updates

Integration Features

  • βœ… Single Command: Run both frontend and backend with one command
  • βœ… Auto-build: Automatic frontend building and dependency installation
  • βœ… API Endpoints: RESTful API for frontend-backend communication
  • βœ… Error Handling: Graceful error handling and user feedback

πŸ“– Usage

Command Line Usage

# Basic analysis
python3 universal_api_backend/universal_api_generator.py https://api.example.com

# With custom endpoints
python3 universal_api_backend/universal_api_generator.py https://api.example.com -e /users /posts --swagger

# From endpoints file
python3 universal_api_backend/universal_api_generator.py https://api.example.com -f endpoints.txt --swagger

Web Interface Usage

  1. Start Server: Run python3 run_server.py
  2. Open Browser: Navigate to http://localhost:5000
  3. Enter API URL: Add your API URL and optional custom endpoints
  4. Generate Docs: Click "Analyze API" to generate documentation
  5. View Results: Swagger UI displays the generated documentation

πŸ› οΈ Installation

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • npm or yarn

Backend Setup

cd universal_api_backend
pip install -r requirements.txt

Frontend Setup

cd universal_api_frontend
npm install

πŸ”§ Configuration

Backend Configuration

  • Timeout: Adjust request timeout in universal_api_generator.py
  • Delay: Configure delay between requests
  • Custom Endpoints: Specify exact endpoints for targeted analysis

Frontend Configuration

  • Styling: Modify tailwind.config.js for theme customization
  • Components: Update src/styles.js for component-specific styles
  • API Integration: Configure API endpoints in src/App.js

πŸ“ Project Structure

Backend (universal_api_backend/)

  • app.py - Flask server with API endpoints
  • universal_api_generator.py - Main API analysis engine
  • swagger_generator.py - Swagger specification generator
  • run_server.py - Integrated server runner
  • build_frontend.py - Frontend build automation
  • requirements.txt - Python dependencies

Frontend (universal_api_frontend/)

  • src/App.js - Main React component
  • src/index.js - Application entry point
  • src/styles.js - Tailwind CSS component styles
  • src/index.css - Global styles and Tailwind directives
  • package.json - NPM configuration and scripts
  • tailwind.config.js - Tailwind CSS configuration

πŸš€ Deployment

Development

# Integrated mode
cd universal_api_backend
python3 run_server.py

# Separate mode
cd universal_api_frontend && npm run dev  # Frontend
cd universal_api_backend && python3 app.py  # Backend

Production

# Build frontend
cd universal_api_frontend
npm run build

# Run production server
cd universal_api_backend
python3 app.py

πŸ› οΈ Troubleshooting

Common Issues

  • 404 Errors: Build frontend manually with python3 build_frontend.py
  • npm Not Found: Install Node.js from https://nodejs.org/
  • Port Conflicts: Use different port with FLASK_PORT=5001 python3 app.py
  • Dependencies: Install with pip install -r requirements.txt

Debug Mode

# Enable debug logging
cd universal_api_backend
FLASK_DEBUG=1 python3 app.py

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • open-lovable: UI design inspiration
  • Swagger UI: API documentation viewer
  • Tailwind CSS: Utility-first CSS framework
  • Flask: Python web framework
  • React: Frontend framework

πŸ“ž Support

For issues and questions:

  • Create an issue on GitHub
  • Check the troubleshooting section
  • Review the documentation in each directory

Made with ❀️ for the developer community

About

A powerful tool for automatically analyzing and documenting REST APIs with React frontend and Python backend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •