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.1.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.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sso_apigee_client-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 e6991d6da4fe11d95532c4a50def43543d7c59ef476631ef8041b61e590b6e40
MD5 07c8ffd8e3d31fe149aceff1f2048669
BLAKE2b-256 1bbc18eacb39d067bf650f93adab15d3e6458049ff41cd365b1aa43d8b7e5f2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sso_apigee_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bbec8ac310e0303ddebb2230daebdcd141837c7e7e329512c3b45159523c9ff8
MD5 d3fa040f0173a550c131f20d32d57c51
BLAKE2b-256 af925702b7a694599ae02f8e8680cef38b6cd861e4081042e27aee0258ee7471

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