Generate API Docs From GitHub
Monitors GitHub pushes, detects API route changes, and uses AI to generate and publish professional Markdown documentation to Notion, notifying the team via Slack.
The Problem With API Documentation
API documentation is often the most neglected part of software development. It rarely happens because developers prioritize shipping features and fixing bugs, pushing documentation updates to the end of the line.
New developers join and spend their first weeks reading raw source code. Integration partners wait for documentation that never arrives. Teams even duplicate work because nobody realized an endpoint already existed. Writing documentation manually is slow, repetitive, and adds little creative value. It is the perfect task to hand over to software.
What the Workflow Does
This workflow monitors a GitHub repository for code pushes and creates professional API documentation without manual effort.
When a push lands, the workflow detects which files contain API routes. It fetches the source code, uses an AI agent to parse every HTTP endpoint, and creates clean Markdown documentation. Finally, it publishes the documentation to Notion and notifies the team on Slack. From push to published documentation takes just seconds.
A Key Architecture Decision
The original version used an AI agent to classify which files were API route files. This approach failed because the AI sometimes hallucinated file paths that did not exist when triggered without a real payload, causing the GitHub fetch node to fail.
The solution was replacing the AI classifier with a deterministic code node using regex pattern matching. The code reads only real file paths from the actual push payload, ensuring complete reliability. Use AI where judgment and language understanding are needed, and use deterministic code where precision is required.
How It Works
The workflow processes events through a sequence of nine nodes:
- A webhook trigger receives the GitHub push payload.
- A code node classifies which changed files are API route files, detecting controllers, routes, and endpoint directories across various frameworks.
- A gate node stops the workflow immediately if no API files are found, saving resources.
- The GitHub connector fetches the source code of each detected file in parallel.
- A code node extracts the clean file content from the GitHub response format.
- An AI agent parses every HTTP endpoint to extract the path, method, request body, response structure, and description.
- A second AI agent generates professional Markdown documentation.
- The Notion connector publishes a new documentation page.
- Slack sends the team a notification with a direct link.
Information Extracted by the AI Agent
| Field | Description |
|---|---|
| Path | The exact HTTP path of the endpoint |
| Method | The HTTP method (GET, POST, PUT, DELETE) |
| Parameters | Details on the request body and variables |
| Response | The structure of the expected output |
| Description | A plain-text explanation of what the endpoint does |
Want to showcase your own workflows?
Become a Needle workflow partner and turn your expertise into recurring revenue.
