victorycodedev / metaapi-cloud-php-sdk
PHP SDK for MetaApi, a professional cloud forex API
Package info
github.com/victorycodedev/metaapi-cloud-php-sdk
pkg:composer/victorycodedev/metaapi-cloud-php-sdk
Requires
- php: >=8.2 <9.0
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- pestphp/pest: ^3.0
README
A modern PHP SDK for MetaApi services.
Supported APIs
- MetaTrader account management
- Provisioning profiles
- Account replicas
- MT4/MT5 demo accounts
- Expert advisors
- User quota management
- Known trading servers
- MetaApi REST terminal API
- CopyFactory
- MetaStats
- MT Manager API
- Risk Management API
Real-time streaming/WebSocket support is planned for a future version.
Requirements
- PHP 8.2 or newer
Installation
composer require victorycodedev/metaapi-cloud-php-sdk
Quick Start
Use MetaApiClient as the main SDK entry point:
use Victorycodedev\MetaapiCloudPhpSdk\MetaApiClient; use Victorycodedev\MetaapiCloudPhpSdk\Exceptions\MetaApiException; $metaapi = new MetaApiClient('AUTH_TOKEN'); try { $accounts = $metaapi->accounts()->accounts([ 'limit' => 100, 'offset' => 0, ]); } catch (MetaApiException $exception) { echo $exception->message(); echo $exception->statusCode(); print_r($exception->toArray()); }
All failed MetaApi responses throw MetaApiException. The exception exposes MetaApi's standard error fields using id(), error(), message(), details() and toArray().
Services
$accounts = $metaapi->accounts(); $profiles = $metaapi->provisioningProfiles(); $replicas = $metaapi->accountReplicas(); $terminal = $metaapi->terminal(region: 'london'); $copyFactory = $metaapi->copyFactory(region: 'london'); $metaStats = $metaapi->metaStats(region: 'london'); $manager = $metaapi->manager(region: 'london'); $risk = $metaapi->riskManagement(region: 'london');
Account Management uses MetaApi's global provisioning URL and does not require a region. Regional services default to new-york.
For private/custom regions, pass the service URL:
$manager = $metaapi->manager( serverUrl: 'https://mt-manager-api-v1.my-region.example.com' ); $risk = $metaapi->riskManagement( serverUrl: 'https://risk-management-api-v1.my-region.example.com' );
Documentation
- Account Management
- Provisioning Profiles
- Account Replicas
- Demo Accounts, Expert Advisors, Quotas and MT Servers
- MetaApi REST Terminal API
- CopyFactory
- MetaStats
- MT Manager API
- Risk Management API
- Error Handling
- Custom HTTP Client
- Roadmap
Testing
composer test
API Reference
All official API references can be found on the MetaApi documentation website: https://metaapi.cloud/
Security
If you discover any security related issues, please open an issue.
Contributing
Pull requests are welcome.
How Can I Thank You?
Why not star the GitHub repo? You can also share the link for this repository on Twitter or HackerNews.
Follow me on X: https://x.com/efekpoguavik3
Thanks! Efekpogua Victory.
License
The MIT License (MIT). Please see License File for more information.