Skip to content

Utkarsharma7/Automatic-API-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Automatic API Generator

A web-based tool to quickly generate and serve custom API endpoints using a simple UI. Define endpoints, methods, and responses, and the backend will serve them instantly—no coding required!


Features

  • Dynamic API Creation: Add multiple endpoints with custom methods and responses.
  • Supports GET & POST: Define GET (JSON or text response) and POST (JSON schema) endpoints.
  • Persistent Storage: Endpoints are saved in urls.json and persist across server restarts.
  • Live Feedback: User-friendly error messages for invalid input.
  • View All Endpoints: Easily view all configured endpoints via /endpoints.

Getting Started

Prerequisites

  • Node.js (v14+ recommended)
  • npm (comes with Node.js)

Installation

  1. Clone the repository:

    git clone <your-repo-url>
    cd automatic-api-generater/Automatic-API-Generator
  2. Install dependencies:

    npm install
  3. Start the server:

    npm start

    The server will run on http://localhost:8000.


Usage

  1. Open the app:
    Go to http://localhost:8000 in your browser.

  2. Configure endpoints:

    • Enter the number of endpoints you want to create.
    • For each endpoint, specify:
      • Endpoint Name: (e.g., /api/users)
      • HTTP Method: GET or POST
      • Response Data:
        • For GET: Enter JSON or plain text (e.g., {"msg": "Hello"} or Hello World)
        • For POST: Enter a JSON schema (e.g., {"username": "string", "age": "number"})
  3. Generate API:
    Click "⚡ Generate API Configuration".

    • Success and error messages will be shown for feedback.
    • Endpoints are saved to urls.json.
  4. Test your endpoints:

    • Use tools like Postman, curl, or your browser to hit your custom endpoints.
    • Example:
      curl http://localhost:8000/api/users
  5. View all endpoints:
    Visit http://localhost:8000/endpoints to see all configured endpoints.


File Structure

Automatic-API-Generator/
  ├── app.js              # Main Express server
  ├── urls.json           # Stores all user-defined endpoints
  ├── package.json        # Project metadata and dependencies
  └── public/
      ├── index.html      # Main UI
      ├── scripts.js      # Frontend logic
      └── styles.css      # UI styles

Error Handling

  • If you send invalid JSON to the backend, you'll get:
    {
      "success": false,
      "error": "Invalid JSON: Please send a valid JSON body."
    }
  • The UI provides live feedback for JSON validation and server errors.

Customization

  • You can extend supported HTTP methods by editing the frontend and backend.
  • To reset all endpoints, clear the urls.json file.

License

ISC


Author

  • Utkarsh Sharma

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published