Skip to main content

Python client library for APIGEE Service

Project description

APIGEE Client SDK

Python client library for interacting with APIGEE through a centralized service.

Features

  • 🔐 OAuth2 Token Management - Automatic token fetching and caching
  • 🚀 API Proxying - Seamless API calls through APIGEE gateway
  • FastAPI Integration - Built-in router for automatic endpoint proxying
  • 🎯 Type Safe - Full type hints and Pydantic validation
  • 🔄 Async/Await - Modern async Python support
  • 📦 Zero Configuration - Works out of the box

Installation

pip install sso-apigee-client

With FastAPI Support

pip install sso-apigee-client[fastapi]

Quick Start

Basic Usage

import asyncio
from sso_apigee_client import ApigeeClient

async def main():
    # Initialize client
    client = ApigeeClient("http://localhost:8000")
    
    try:
        # Get APIGEE token
        token = await client.get_token()
        print(f"Token: {token}")
        
        # Make API call through APIGEE
        data = await client.call_api(
            method="GET",
            endpoint="/api/v1/users",
            query_params={"page": 1}
        )
        print(f"Data: {data}")
        
    finally:
        await client.close()

asyncio.run(main())

Using Context Manager

async with ApigeeClient("http://localhost:8000") as client:
    users = await client.call_api("GET", "/api/v1/users")
    print(users)

FastAPI Integration

from fastapi import FastAPI
from sso_apigee_client import ApigeeClient, ApigeeRouter

app = FastAPI()
apigee = ApigeeClient("http://localhost:8000")

# Create router with automatic proxying
router = ApigeeRouter(
    apigee_client=apigee,
    apigee_base_path="/api/v1",
    prefix="/api"
)

@router.get("/users")
async def get_users():
    # Automatically proxied through APIGEE!
    pass

@router.get("/users/{user_id}")
async def get_user(user_id: str):
    # Path params automatically handled!
    pass

app.include_router(router)

API Reference

ApigeeClient

Methods

  • get_token(force_refresh=False) - Get APIGEE OAuth2 access token
  • call_api(method, endpoint, **kwargs) - Make authenticated API call via proxy
  • get_token_status() - Get current token status
  • health_check() - Check service health
  • close() - Close HTTP client

ApigeeRouter

FastAPI router that automatically proxies all requests through APIGEE.

Parameters

  • apigee_client - ApigeeClient instance
  • apigee_base_path - Base path for APIGEE endpoints
  • auto_proxy - Enable automatic proxying (default: True)
  • prefix - FastAPI router prefix
  • tags - OpenAPI tags

Route Decorators

  • @router.get(path) - GET endpoint
  • @router.post(path) - POST endpoint
  • @router.put(path) - PUT endpoint
  • @router.delete(path) - DELETE endpoint

Special Parameters

  • apigee_endpoint - Override APIGEE endpoint path
  • skip_apigee - Skip APIGEE proxying for specific route

Configuration

The SDK requires an APIGEE service running. Set up the service:

# Clone the service repository
git clone https://github.com/yourorg/sso-apigee-service

# Configure environment
cp .env.example .env
# Edit .env with your APIGEE credentials

# Run with Docker
docker-compose up -d

Requirements

  • Python 3.11+
  • httpx >= 0.25.0
  • pydantic >= 2.5.0
  • fastapi >= 0.104.0 (optional, for FastAPI integration)

License

MIT License

Support

For issues and questions:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

sso_apigee_client-1.0.2.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

sso_apigee_client-1.0.2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file sso_apigee_client-1.0.2.tar.gz.

File metadata

  • Download URL: sso_apigee_client-1.0.2.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for sso_apigee_client-1.0.2.tar.gz
Algorithm Hash digest
SHA256 e95d9d097c1c8006b91dc0ebf159f6c83d7aafb01fcaa43bb7121ee61c8d6d8b
MD5 df79a691ef472e1dad9aee3b51c7609d
BLAKE2b-256 20539407b7f0719eac8f5060322e2b5fafad365c0d4b729413c1b2ba896c7931

See more details on using hashes here.

File details

Details for the file sso_apigee_client-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sso_apigee_client-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 02cdb8ed79fc74550c9224a05f603a6c1cf6d24e0300c8490272bd38b1b7907d
MD5 4dc00ce3c5112b1102ad44f53b12f315
BLAKE2b-256 3c3bea29394bb0fb51947518482f4fa9507e508c334a8ee2fb06be4d029b92e1

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