Skip to content

Basic Usage using HTTP / Websockets

Introduction

In this section, we’ll walk through the process of sending requests via REST API and PowerShell. A step-by-step video demonstration is included to help you:

  • Understand core concepts of REST API integration.
  • Craft and execute HTTP requests (GET, POST).
  • Use PowerShell commands like Invoke-WebRequest for API interactions.

Whether you’re new to APIs or refining your workflow, this guide and accompanying video will streamline your implementation.

Basic Usage Video

After watching the video, ensure you meet the following requirements for the subsequent guide to function properly:

  • You are using the latest MTsocketAPI version (5.40 or higher)
  • You are using the default HTTP/Websockets port TCP 81
  • You are using the browser on the same computer as the API

If you meet all of the above requirements, please click on the link below (a new window will open):

https://www.mtsocketapi.com/restapi.html

You will see something like this:

Now, in the left panel under ENDPOINTS, click on Quote and then Get Quote

Enter your broker symbol name and then click Send API Request and you will receive the response from MTsocketAPI:

Important

If you receive the message Network Error occurred please carefully check that you have met the three requirements listed above.

Important

Please check with your broker to make sure the symbol name is available. Some brokers use the following symbol format: EURUSD, EURUSD.fx, EUR/USD, and so on.

Additionally, the source code for using the REST API in multiple programming languages is available for your use:

For example, if you're using a Windows computer, select Powershell / WebRequest from the dropdown box.

Copy the code and paste it on a Powershell terminal:

Stream prices using Websockets

Now we will start streaming realtime prices using Websockets.

First, we must open the url:

https://www.mtsocketapi.com/restapi.html

Next, navigate to the Endpoints section and select Websockets -> Track prices. Here, you will enter an array of symbols for which you would like to retrieve prices:

Then, please click Send API request.

To facilitate real-time monitoring of incoming prices, we will utilize the Postman tool. Click on New and then select Websocket:

Please enter the URL and click on the Connect button:

You will see the prices on the Response tab:

Note

You can connect multiple clients to the TCP 81 (HTTP/Websockets).

Important

The new MTsocketAPI version (5.40 or higher) only needs the default port TCP 81 to work (can be changed in the Inputs tab):

Note

Both TCP 77 (commands) and TCP 78 (data) ports were used in previous API versions and will continue to work, but are not required with new API versions.

Detailed Documentation >