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.0.tar.gz (11.0 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.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sso_apigee_client-1.0.0.tar.gz
  • Upload date:
  • Size: 11.0 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.0.tar.gz
Algorithm Hash digest
SHA256 252fe12b611af714656b80633959c60fed85389f83ab6cf3768c0ae83e4b9f4b
MD5 19d879cac8ea093677ba889049a258a6
BLAKE2b-256 0f3364574c76e48e78f502cf3bdc9eb0f05a55d7638214e3f6882c3a4c26a841

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sso_apigee_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0a6c2b234cc692d4d09101835d75dc8f010fbd9fea58519148e739a7f3181ee
MD5 d2810033fe43258712fa38b2714f1c96
BLAKE2b-256 0d01abc09450320362f853144c98a3132a701c852b250c2afc7b29ec0bb98372

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