DEV Community

Rabist
Rabist

Posted on • Edited on

4

MQL5 HTTP Web Request Using WinINet DLL

An easy-to-use, general-purpose library for sending HTTP web requests in MQL5 using the WinINet DLL.

Introducing an easy-to-use, general-purpose library designed for seamless handling of HTTP web requests in MQL5 through the utilization of the WinINet DLL. This library simplifies the process of incorporating web request functionalities into your MQL5 projects, providing a user-friendly interface for developers. With its intuitive design, the library empowers users to effortlessly send and manage HTTP requests, offering a versatile solution for a wide range of applications within the MQL5 environment. Streamlining the integration of web communication capabilities, this library serves as a valuable resource for developers seeking efficient and reliable methods to interact with online resources in their MQL5 projects.

Example 1:

Send a GET request and retrieve current GMT time.

WininetRequest req;
WininetResponse res;

req.host = "worldtimeapi.org";
req.path = "/api/timezone/Europe/London.txt";

WebReq(req, res);

Print("status: ", res.status);
Print(res.GetDataStr());
Enter fullscreen mode Exit fullscreen mode

Example 2:

Send a POST request and echo it back.

WininetRequest req;
WininetResponse res;

req.method = "POST";
req.host = "httpbin.org";
req.path = "/post";
req.port = 80;
req.headers = "Accept: application/json\r\n"
              "Content-Type: application/json; charset=UTF-8\r\n";

req.data_str = "{'id': 10, 'title': 'foo', 'message': 'bar'}";
StringReplace(req.data_str, "'", "\"");

WebReq(req, res);

Print("status: ", res.status);
Print(res.GetDataStr());
Enter fullscreen mode Exit fullscreen mode

AI Agent image

How to Build an AI Agent with Semantic Kernel (and More!)

Join Developer Advocate Luce Carter for a hands-on tutorial on building an AI-powered dinner recommendation agent. Discover how to integrate Microsoft Semantic Kernel, MongoDB Atlas, C#, and OpenAI for ingredient checks and smart restaurant suggestions.

Watch the video →

Top comments (1)

Collapse
 
paradise_c631bdb30 profile image
Paradise

It seems that Wininet doesn't run in Windows 7,
Do you have any idea?

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

👋 Kindness is contagious

Value this insightful article and join the thriving DEV Community. Developers of every skill level are encouraged to contribute and expand our collective knowledge.

A simple “thank you” can uplift someone’s spirits. Leave your appreciation in the comments!

On DEV, exchanging expertise lightens our path and reinforces our bonds. Enjoyed the read? A quick note of thanks to the author means a lot.

Okay