SDK Initialization
This guide covers how to properly initialize and configure the globalMOO SDKs.
Client Initialization
Each SDK provides a Client class for API interaction:
from globalmoo.client import Client
from globalmoo.credentials import Credentials
# Method 1: Environment Variables
client = Client() # Uses GMOO_API_KEY and GMOO_API_URI
# Method 2: Direct Credentials
credentials = Credentials(
api_key="your-api-key",
base_uri="https://app.globalmoo.com/api/"
)
client = Client(credentials=credentials)
# Method 3: Custom HTTP Client
import httpx
http_client = httpx.Client(
timeout=30.0,
headers={"Custom-Header": "value"}
)
client = Client(credentials=credentials, http_client=http_client)use GlobalMoo\Client;
use GlobalMoo\Credentials;
// Method 1: Environment Variables
$client = new Client();
// Method 2: Direct Credentials
$credentials = new Credentials(
apiKey: "your-api-key",
baseUri: "https://app.globalmoo.com/api/"
);
$client = new Client($credentials);
// Method 3: Custom HTTP Client
use Symfony\Component\HttpClient\HttpClient;
$httpClient = HttpClient::create([
'timeout' => 30.0,
'headers' => ['Custom-Header' => 'value']
]);
$client = new Client($credentials, $httpClient);Environment Variables
The SDKs support these environment variables:
GMOO_API_KEY
Yes
Your API key for authentication
GMOO_API_URI
No
API base URI (defaults to https://app.globalmoo.com/api/)
Debug Mode
Enable debug mode for detailed logging:
HTTP Client Configuration
The SDKs use different HTTP clients:
Python: httpx
PHP: Symfony HttpClient
Node.js: node-fetch
Custom configuration options:
timeout
30.0
Request timeout in seconds
retries
3
Number of retry attempts
backoff
exponential
Retry backoff strategy
headers
{}
Custom HTTP headers
Best Practices
Use environment variables for credentials
Enable debug mode during development
Configure appropriate timeouts
Handle client cleanup (Python/PHP)
Set custom headers when needed
Use typed inputs where available
Configure logging appropriately
Client Lifecycle
Production Configuration
For production environments:
Set appropriate timeouts
Configure retry strategies
Use secure credential storage
Monitor API rate limits
Handle cleanup properly
Log errors appropriately
Use separate API keys
Last updated