APIGen
Turn any API into Python code. No docs needed.
# Generate from any API
$ apigen generate https://api.github.com
# Use it immediately
>>> from generated_tools.api_github_com import ApiGithubCom
>>> client = ApiGithubCom(api_key="ghp_...")
>>> user = client.list_user()
>>> print(user['login'])
'your-username'
What it does
Point APIGen at any API URL. Get working Python code with methods, auth, and type hints.
Works with:
- APIs that have OpenAPI specs
- APIs that don't have any docs
- Public and authenticated APIs
Install
pip install apigen-ai
Quick start
# Public API
apigen generate https://jsonplaceholder.typicode.com
# Authenticated API
apigen generate https://api.github.com
Generated code goes in generated_tools/.
Example: GitHub API
apigen generate https://api.github.com
Creates generated_tools/api.github.com.py with:
class ApiGithubCom:
def __init__(self, api_key=None):
self.base_url = "https://api.github.com"
self.api_key = api_key
def list_user(self) -> Dict:
"""Get authenticated user"""
...
def list_users(self, page=None, limit=None) -> Dict:
"""List all users"""
...
def get_users(self, id) -> Dict:
"""Get specific user"""
...
Use it:
import importlib.util
spec = importlib.util.spec_from_file_location(
"api", "generated_tools/api.github.com.py"
)
api = importlib.util.module_from_spec(spec)
spec.loader.exec_module(api)
client = api.ApiGithubCom(api_key="ghp_your_token")
user = client.list_user()
print(f"Logged in as: {user['login']}")
How it works
Phase 1: Check for OpenAPI spec
- Probes
/openapi.json,/swagger.json, etc. - Parses endpoints, parameters, auth
- Generates full method signatures
Phase 2: Probe the API
- Tests common patterns (
/users,/api/v1,/products) - Detects auth from response headers
- Infers parameters from responses
- Discovers ID-based endpoints
Result: Clean Python code that works.
Commands
# Generate tool
apigen generate <url>
# Skip Elasticsearch (faster)
apigen generate <url> --skip-index
# Search catalog (requires Elasticsearch)
apigen search "payment apis"
# Setup Elasticsearch
apigen setup
Configuration
Optional .env file:
ELASTICSEARCH_HOST=localhost
ELASTICSEARCH_PORT=9200
ELASTICSEARCH_USER=elastic
ELASTICSEARCH_PASSWORD=changeme
Requirements
- Python 3.11+
- Elasticsearch 8.15+ (optional, for search)
- Docker (optional, for Elasticsearch)
What gets generated
Every tool includes:
- Method signatures with parameters
- Authentication (Bearer, API key, OAuth)
- Type hints
- Docstrings
- Error handling
- Query parameter support
Limitations
- Review generated code before production
- Complex auth may need manual tweaks
- No rate limiting
- No WebSocket/GraphQL support yet
Contributing
Issues and PRs welcome.
Areas for improvement:
- More auth methods
- Better parameter inference
- GraphQL support
- WebSocket support
License
MIT
Metadata
Release files for apigen-ai 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| apigen_ai-0.1.1.tar.gz | 12.8 kB | Without provenance | Details for apigen_ai-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apigen_ai-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for apigen_ai-0.1.1-py3-none-any.whl |
Total release size: 27.9 kB
Release files / apigen_ai-0.1.1.tar.gz
| Download URL | apigen_ai-0.1.1.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c39f4decc7a4ccae12d903e40a19d8734180fd925227e560b7deda9a2e6e4d8
|
|
BLAKE2b-256 checksum How to use checksums |
f5fdbe0af736130913fc587f2114d3ca4867f0a1aa3d837509a190f62c60bdf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / apigen_ai-0.1.1-py3-none-any.whl
| Download URL | apigen_ai-0.1.1-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aafb658631fb34617a98c9089f7355cfd2bec13ae9e98d433c75a524843e88eb
|
|
BLAKE2b-256 checksum How to use checksums |
155bc8f3ecf16677a1e1719c1b83cb2e4eac4132a4fcd95f4ef9f3a80c54091e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for apigen-ai 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.