Download the PHP package oyi77/metaapi-cloud-php-sdk without Composer
On this page you can find all versions of the php package oyi77/metaapi-cloud-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oyi77/metaapi-cloud-php-sdk
More information about oyi77/metaapi-cloud-php-sdk
Files in oyi77/metaapi-cloud-php-sdk
Package metaapi-cloud-php-sdk
Short Description PHP SDK for MetaApi, a professional cloud forex API
License MIT
Homepage https://github.com/oyi77/metaapi-cloud-php-sdk
Informations about the package metaapi-cloud-php-sdk
Metaapi PHP SDK
A PHP Package that let you seamlessly perform API calls to MetaApi https://metaapi.cloud/
This SDK provides access to:
- Account Management API
- CopyFactory (Copy Trading) API
- MetaStats (Trading Statistics) API
- Provisioning Profile API
- Token Management API
- Risk Management API
Installation
To install the SDK in your project you need to install the package via composer:
Usage
MetaApi Websocket (RPC & Real-time streaming)
This SDK now includes a minimal Socket.IO-based websocket client for MetaApi RPC API and MetaApi real-time streaming API (see the guideline docs in guideline/ and the official websocket docs on metaapi.cloud).
RPC Connection (Request/Response)
Streaming Connection (Continuous Synchronization)
Examples
For complete working examples, see the examples/ directory:
MetaApi Examples:
examples/metaapi/rpc_example.php- RPC connection usageexamples/metaapi/streaming_example.php- Streaming with typed listenersexamples/metaapi/historical_data_example.php- Historical candles and ticks
CopyFactory Examples:
examples/copyfactory/copy_trade_example.php- CopyFactory strategy setupexamples/copyfactory/webhooks_example.php- Webhook CRUD operations
Risk Management Examples:
examples/risk_management/equity_tracking_example.php- Equity tracker CRUD
Account Management
You can create an instance of the SDK like so for Account Management:
All methods throws exceptions when the request is not successful, so be sure to put your code in a try and catch block.
You can add a trading account and starts a cloud API server for the trading account like so:
if the request was successful , you will get the the account id and state, else an Exception will be thrown
You can read an account by the id
You can read all trading accounts in your metaapi account
You can update an account
Undeploy an account
Deploy an account
Redeploy an account
Delete an account
Create configuration link for end-user account setup
CopyFactory
You can create an instance of the SDK like so for Copyfactory:
To generate a strategy id
To get all your strategies
To get a single strategy
To update a strategy
To remove a strategy
To get all your subscribers
To get a subscriber
To update a subscriber data
To remove a subscriber
To delete a subscription
Webhooks
CopyFactory supports webhooks for receiving trading signals.
Create a webhook
Update a webhook
Get webhooks
Delete a webhook
Copy Trade
To Copy a trade from provider to subscriber. I recommend you create a strategy before hand and save to your database before you perform a copy trade, but its not compulsory as the package will create one for you. You can always read all your strategies in your account with the " $copyfactory->strategies()".
To Copy trade do:
Note: copying a trade will take some seconds to finish, you you can have a loading indicator as feedback.
MetaStats
You can get metrics for you account
You can create an instance of the SDK like so for MetaStats:
To get metrics:
To get open trades for MetaApi account:
To get account trades for a time range:
Provisioning Profile API
Provisioning profiles can be used as an alternative way to create MetaTrader accounts if automatic broker settings detection has failed.
Create a provisioning profile
Get provisioning profiles
Get, update, and delete provisioning profile
Token Management API
Generate narrowed-down tokens for use in Web or Mobile applications.
Narrow down token to specific applications
Narrow down token to specific roles
Narrow down token to specific resources
Narrow down token with combined restrictions
Get access rules manifest
Risk Management API
Risk Management API for executing trading challenges and competitions.
Create and manage trackers
Get tracker events and statistics
Expert Advisor Management
Manage custom expert advisors (EAs) for MT4 accounts on G1 infrastructure. Note: EAs using DLLs are not supported.
Create an expert advisor
Get expert advisors
Update and delete expert advisor
Historical Data API
Retrieve historical market data (candles and ticks). Available on G1 and MT4 G2 instances only.
Get historical candles
Get historical ticks
Demo Account Generator API
Create MT4 and MT5 demo accounts. Note: Not all MT4/MT5 servers allow creating demo accounts using this method.
Create MT4 demo account
Create MT5 demo account
Manager API
Access and manage MT4 and MT5 servers. For detailed endpoint documentation, see: https://metaapi.cloud/docs/manager/
The Manager API provides generic methods for accessing MT Manager endpoints:
Latency Monitor
Track API latencies for monitoring and optimization.
Logging Support
Enable logging for debugging and monitoring. Supports PSR-3 compatible loggers and file logging.
Pagination Helper
The SDK includes a pagination helper utility for working with paginated responses:
Testing
API Reference
All API references can be found on 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? I'd love the attention! you can share the link for this repository on Twitter or HackerNews?
Don't forget to follow me on twitter!
Thanks! Efekpogua Victory.
About This Repository
So here's the story - I was working on a project that needed to integrate with MetaApi, and I found this PHP SDK that looked promising. Turned out it was created by Efekpogua Victory a couple years back, and it worked fine for basic stuff. But when I dug deeper, I realized it was missing a bunch of features that the Python SDK already had.
The original SDK hadn't been touched in like 2 years, and I really needed those missing APIs. Instead of starting from scratch (which would've been a pain), I decided to fork it and bring it up to speed. I spent some time going through the Python SDK docs and examples, figuring out what was missing, then added all the REST API stuff that should've been there.
Now I'm maintaining this actively, so if you find bugs or need something added, just open an issue. I'll get to it faster than the previous maintainer did (no offense to the original author - we all get busy).
Credits
Big shoutout to Efekpogua Victory for building the initial version of this SDK. He did the hard work of setting up the foundation, and without that, I'd still be writing HTTP wrappers from scratch. So thanks for that!
I (Oyi77) forked it and updated everything to match what the Python SDK can do. The goal is to keep this thing maintained and useful for anyone who needs a PHP SDK for MetaApi.
License
The MIT License (MIT). Please see License File or more information.