Skip to main content

Turn any API into AI-native tools - no reverse engineering needed

Project description

APIGen

Turn any API into Python code. No docs needed.

[!WARNING] Experimental software. Review generated code before production use.

# 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apigen_ai-0.1.1.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apigen_ai-0.1.1-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file apigen_ai-0.1.1.tar.gz.

File metadata

  • Download URL: apigen_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for apigen_ai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7c39f4decc7a4ccae12d903e40a19d8734180fd925227e560b7deda9a2e6e4d8
MD5 8365026f82c8399b80a2b5309eea47da
BLAKE2b-256 f5fdbe0af736130913fc587f2114d3ca4867f0a1aa3d837509a190f62c60bdf6

See more details on using hashes here.

File details

Details for the file apigen_ai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: apigen_ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for apigen_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aafb658631fb34617a98c9089f7355cfd2bec13ae9e98d433c75a524843e88eb
MD5 e5c50d9730a9f22b9cfc0ab8df8b4d80
BLAKE2b-256 155bc8f3ecf16677a1e1719c1b83cb2e4eac4132a4fcd95f4ef9f3a80c54091e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page