blockshiftnetwork/composio-php

Composio PHP SDK - API client library for Composio

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/blockshiftnetwork/composio-php

v0.0.1-alpha 2025-12-05 22:18 UTC

This package is auto-updated.

Last update: 2025-12-05 23:56:26 UTC


README

PHP Version

Auto-generated PHP client for the Composio API - Build AI applications faster with production-ready toolkits and integrations.

โš ๏ธ Important Notice: This is a generated client library based on Composio's OpenAPI specification. It is not maintained by Composio directly. For official SDKs, please check Composio's official repositories.

๐Ÿš€ What is Composio?

Composio is an open source platform that provides production-ready toolkits for building AI applications faster. With over 150+ integrations with popular services, Composio simplifies the process of connecting AI applications with external tools.

โœจ Key Features

  • ๐Ÿ”— 150+ Integrations: Salesforce, Gmail, Slack, GitHub, and many more
  • ๐Ÿ” Multiple Authentication Methods: OAuth, API Keys, custom flows
  • โšก Production-Ready: Designed for scalable applications
  • ๐Ÿ“š Comprehensive Documentation: Detailed guides and API references
  • ๐Ÿ› ๏ธ Open Source: Open source with community contributions

๐Ÿ“‹ Requirements

  • PHP 8.1 or higher
  • Composer for dependency management
  • PHP Extensions: json, curl, mbstring

๐Ÿ“ฆ Installation

Using Composer

To use this generated client, you can install it from your local repository or create a package. Here's how to add it from a local path:

composer require blockshiftnetwork/composio-php

โš ๏ธ Generation Information

This client was generated using:

  • OpenAPI Generator: v7.17.0
  • API Version: v3.0.0
  • Source: Composio's OpenAPI specification
  • Language: PHP Client
  • Build Date: 2025-12-05

To regenerate this client:

openapi-generator-cli generate -i openapi.json -g php -o composio2 --additional-properties invokerPackage=BlockshiftNetwork\\Composio

๐Ÿš€ Getting Started

Authentication Setup

Composio supports multiple authentication methods:

1. API Key (Recommended)

<?php
require_once 'vendor/autoload.php';

use BlockshiftNetwork\Composio\Configuration;

// Configure API key
$config = Configuration::getDefaultConfiguration()
    ->setApiKey('x-api-key', 'YOUR_API_KEY')
    ->setHost('https://backend.composio.dev');

2. Cookie Authentication

$config = Configuration::getDefaultConfiguration()
    ->setApiKey('authToken', 'YOUR_SESSION_TOKEN')
    ->setApiKeyPrefix('authToken', '');

3. Organization API Key

$config = Configuration::getDefaultConfiguration()
    ->setApiKey('x-org-api-key', 'YOUR_ORG_API_KEY');

Basic Example: List Toolkits

<?php
require_once 'vendor/autoload.php';

use BlockshiftNetwork\Composio\Configuration;
use BlockshiftNetwork\Composio\Api\ToolkitsApi;
use GuzzleHttp\Client;

// Configure authentication
$config = Configuration::getDefaultConfiguration()
    ->setApiKey('x-api-key', 'YOUR_API_KEY');

// Create API instance
$api = new ToolkitsApi(
    new Client(),
    $config
);

try {
    // List all available toolkits
    $result = $api->getToolkits();

    echo "Available toolkits:\n";
    foreach ($result->getItems() as $toolkit) {
        echo "- {$toolkit->getName()} ({$toolkit->getSlug()})\n";
        echo "  Description: {$toolkit->getMeta()->getDescription()}\n";
        echo "  Categories: " . implode(', ', $toolkit->getMeta()->getCategories()) . "\n\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Example: Execute a Tool

<?php
use BlockshiftNetwork\Composio\Api\ToolsApi;
use BlockshiftNetwork\Composio\Model\PostToolsExecuteByToolSlugRequest;

// Create tools API instance
$toolsApi = new ToolsApi(
    new Client(),
    $config
);

// Execute a specific tool
$request = new PostToolsExecuteByToolSlugRequest([
    'arguments' => [
        'repository' => 'username/repository',
        'title' => 'Issue created from PHP SDK',
        'body' => 'This issue was created automatically using Composio PHP SDK'
    ],
    'connected_account_id' => 'CONNECTED_ACCOUNT_ID'
]);

try {
    $result = $toolsApi->postToolsExecuteByToolSlug('github_create_issue', $request);
    echo "Issue created successfully:\n";
    echo "URL: {$result->getData()->html_url}\n";
} catch (Exception $e) {
    echo "Error executing tool: " . $e->getMessage() . "\n";
}

Example: Manage Connected Accounts

<?php
use BlockshiftNetwork\Composio\Api\ConnectedAccountsApi;

$connectedAccountsApi = new ConnectedAccountsApi(
    new Client(),
    $config
);

try {
    // List connected accounts
    $accounts = $connectedAccountsApi->getConnectedAccounts();

    echo "Connected accounts:\n";
    foreach ($accounts->getItems() as $account) {
        echo "- {$account->getToolkit()->getName()}: ";
        echo $account->getStatus() === 'ACTIVE' ? 'โœ… Active' : 'โŒ Inactive';
        echo "\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

๐Ÿ“š Available API Endpoints

The SDK provides access to all Composio API endpoints:

Authentication

  • GET /api/v3/auth/session/info - Get current session information
  • POST /api/v3/auth/session/logout - End user session

Toolkits

  • GET /api/v3/toolkits - List available toolkits
  • GET /api/v3/toolkits/{slug} - Get specific toolkit
  • GET /api/v3/toolkits/categories - List categories
  • POST /api/v3/toolkits/multi - Fetch multiple toolkits

Tools

  • GET /api/v3/tools - List available tools
  • GET /api/v3/tools/{tool_slug} - Get specific tool
  • POST /api/v3/tools/execute/{tool_slug} - Execute tool
  • POST /api/v3/tools/execute/{tool_slug}/input - Generate inputs from natural language

Connected Accounts

  • GET /api/v3/connected_accounts - List connected accounts
  • POST /api/v3/connected_accounts - Create new connected account
  • DELETE /api/v3/connected_accounts/{nanoid} - Delete connected account
  • POST /api/v3/connected_accounts/{nanoid}/refresh - Refresh authentication

Tool Router (Experimental)

  • POST /api/v3/tool_router/session - Create tool router session
  • POST /api/v3/tool_router/session/{session_id}/execute - Execute in session

And many more endpoints for managing:

  • Authentication Configurations (/api/v3/auth_configs)
  • Projects and Organizations (/api/v3/org/owner/project)
  • MCP Servers (/api/v3/mcp)
  • Triggers (/api/v3/triggers)
  • Files (/api/v3/files)

๐Ÿ”ง Available Models

The SDK includes PHP models for all Composio entities:

  • Tool - Tool information
  • ConnectedAccount - Connected accounts
  • AuthConfig - Authentication configurations
  • Toolkit - Toolkit information
  • Error - Error handling
  • And many more...

๐Ÿท๏ธ Popular Toolkit Categories

Composio organizes its toolkits into categories:

๐Ÿ’ผ Productivity

  • Gmail - Email management
  • Slack - Team communication
  • Notion - Knowledge management
  • Trello - Project management

๐Ÿ’ป Development

  • GitHub - Version control
  • GitLab - Code repositories
  • Jira - Issue tracking
  • Figma - Collaborative design

๐Ÿ“Š Data & Analytics

  • Salesforce - CRM
  • HubSpot - Marketing and sales
  • Google Sheets - Spreadsheets
  • Airtable - Database

๐Ÿ›’ E-commerce

  • Shopify - Online store
  • Stripe - Payments
  • WooCommerce - WordPress e-commerce

๐Ÿ” Supported Authentication Methods

Composio supports multiple authentication methods:

OAuth 2.0

  • Standard authorization flow
  • Automatic refresh tokens
  • Custom scopes handling

API Keys

  • Static API keys
  • Custom headers
  • Query parameters

Basic Authentication

  • Username/Password
  • HTTP Basic Auth

Custom Methods

  • OAuth 1.0
  • Bearer Tokens
  • Custom headers
  • Form-based authentication

๐Ÿงช Testing

To run the included tests:

# Install development dependencies
composer install --dev

# Run tests
vendor/bin/phpunit

๐Ÿ“– Advanced Examples

Tool Router Session

<?php
use BlockshiftNetwork\Composio\Api\ToolRouterApi;
use BlockshiftNetwork\Composio\Model\PostToolRouterSessionRequest;

$toolRouterApi = new ToolRouterApi(new Client(), $config);

// Create a Tool Router session
$sessionRequest = new PostToolRouterSessionRequest([
    'user_id' => 'user_123',
    'config' => [
        'toolkits' => [
            'enabled' => ['github', 'slack', 'gmail']
        ]
    ]
]);

$session = $toolRouterApi->postToolRouterSession($sessionRequest);
echo "Session created: {$session->getSessionId()}\n";

// Execute in session
$executeRequest = [
    'tool_slug' => 'github_create_issue',
    'arguments' => [
        'repository' => 'user/repo',
        'title' => 'Issue from Tool Router'
    ]
];

$result = $toolRouterApi->postToolRouterSessionBySessionIdExecute(
    $session->getSessionId(),
    $executeRequest
);

Error Handling

<?php
use BlockshiftNetwork\Composio\ApiException;

try {
    $result = $api->someMethod();
} catch (ApiException $e) {
    echo "API Error: {$e->getCode()} {$e->getMessage()}\n";
    echo "Response body: {$e->getResponseBody()}\n";
    echo "Response headers: " . json_encode($e->getResponseHeaders()) . "\n";
} catch (Exception $e) {
    echo "General error: " . $e->getMessage() . "\n";
}

๐ŸŒ Framework Integrations

Laravel

// App/Http/Controllers/ComposioController.php
namespace App\Http\Controllers;

use BlockshiftNetwork\Composio\Configuration;
use BlockshiftNetwork\Composio\Api\ToolkitsApi;

class ComposioController extends Controller
{
    protected $config;
    protected $api;

    public function __construct()
    {
        $this->config = Configuration::getDefaultConfiguration()
            ->setApiKey('x-api-key', config('services.composio.api_key'));

        $this->api = new ToolkitsApi(
            new \GuzzleHttp\Client(),
            $this->config
        );
    }

    public function index()
    {
        $toolkits = $this->api->getToolkits();
        return view('composio.index', ['toolkits' => $toolkits->getItems()]);
    }
}

Symfony

// src/Service/ComposioService.php
namespace App\Service;

use BlockshiftNetwork\Composio\Configuration;
use BlockshiftNetwork\Composio\Api\ToolsApi;

class ComposioService
{
    private Configuration $config;
    private ToolsApi $toolsApi;

    public function __construct(string $apiKey)
    {
        $this->config = Configuration::getDefaultConfiguration()
            ->setApiKey('x-api-key', $apiKey);

        $this->toolsApi = new ToolsApi(
            new \GuzzleHttp\Client(),
            $this->config
        );
    }

    public function executeTool(string $toolSlug, array $arguments): array
    {
        $request = new \BlockshiftNetwork\Composio\Model\PostToolsExecuteByToolSlugRequest([
            'arguments' => $arguments
        ]);

        $result = $this->toolsApi->postToolsExecuteByToolSlug($toolSlug, $request);

        return $result->getData();
    }
}

๐Ÿš€ Best Practices

1. Configuration Management

// Environment variables
$config = Configuration::getDefaultConfiguration()
    ->setApiKey('x-api-key', $_ENV['COMPOSIO_API_KEY'])
    ->setHost($_ENV['COMPOSIO_API_HOST'] ?? 'https://backend.composio.dev');

2. Client Reuse

class ComposioClientFactory
{
    private static ?Configuration $config = null;

    public static function getConfig(): Configuration
    {
        if (self::$config === null) {
            self::$config = Configuration::getDefaultConfiguration()
                ->setApiKey('x-api-key', $_ENV['COMPOSIO_API_KEY']);
        }

        return self::$config;
    }

    public static function createToolkitsApi(): ToolkitsApi
    {
        return new ToolkitsApi(
            new \GuzzleHttp\Client([
                'timeout' => 30,
                'connect_timeout' => 10
            ]),
            self::getConfig()
        );
    }
}

3. Logging

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('composio');
$logger->pushHandler(new StreamHandler('logs/composio.log', Logger::DEBUG));

// Add middleware to Guzzle for logging
$client = new \GuzzleHttp\Client([
    'handler' => \GuzzleHttp\HandlerStack::create(),
]);

$handler = $client->getConfig('handler');
$handler->push(\GuzzleHttp\Middleware::log(
    $logger,
    new \GuzzleHttp\MessageFormatter('{method} {uri} - {code} - {req_body}')
));

โš ๏ธ Important Disclaimers

Library Status

  • This is an auto-generated client library based on Composio's OpenAPI specification
  • Not officially maintained by Composio
  • Generated using OpenAPI Generator v7.17.0
  • Based on Composio API v3.0.0

Limitations

  • This client reflects the state of the OpenAPI specification at the time of generation
  • Features may be outdated if the API has been updated
  • For official support, contact Composio directly or use their official SDKs

When to Use This Client

  • โœ… When you need a PHP client for Composio's API
  • โœ… When there's no official PHP SDK available
  • โœ… For rapid prototyping and development
  • โŒ For production-critical applications without thorough testing

๐Ÿค Contributing

Since this is an auto-generated client, contributions should focus on:

  1. API Specification Updates: Update the OpenAPI spec if Composio releases new versions
  2. Generation Improvements: Enhance the generation process or configuration
  3. Documentation: Improve this README and examples
  4. Bug Reports: Report issues with the generated client

Note: Do not manually edit the generated API files, as they will be overwritten during regeneration. Instead, update the OpenAPI specification and regenerate the client.

๐Ÿ“ License

This generated client follows the licensing terms of the OpenAPI Generator and the Composio API specification. Check the LICENSE file for specific licensing details.

๐Ÿ†˜ Support

Composio Official Support

Generated Client Issues

Since this is an auto-generated client, issues should be reported to:

Important: This generated client is not officially supported by Composio. For official SDK support, please use Composio's official repositories.

๐Ÿ”— Useful Links

๐Ÿ“Š Changelog

Generated Client v1.0.0 (2025-12-05)

  • โœ… Generated from Composio OpenAPI specification v3.0.0
  • โœ… Full support for all API v3 endpoints
  • โœ… PHP models for all entities
  • โœ… Multiple authentication methods
  • โœ… Tool Router support
  • โœ… Complete documentation and examples
  • โœ… Generated using OpenAPI Generator v7.17.0

๐Ÿ”— Useful Links

Official Composio Resources

Generation Tools

Build AI applications faster with Composio's production-ready toolkits ๐Ÿš€