API Request

 
Hi,

I want to send GET and POST request to API.
but i didn't know how to do it so i searched for it and found official documentation :  WebRequest - Common Functions - MQL4 Reference

And I tried it's examples code with some different API's

but i don't know how to use JSON Header.

Can some one please help me?

And 

As there is very very less content is there on internet about api request in mql, It will not help me only but other peoples too.

Thanks for Reading.
WebRequest - Common Functions - MQL4 Reference
WebRequest - Common Functions - MQL4 Reference
  • docs.mql4.com
WebRequest - Common Functions - MQL4 Reference
 
Kailash Bai Mina: I want to send GET and POST request to API. but i didn't know how to do it so i searched for it and found official documentation :  WebRequest - Common Functions - MQL4 Reference

And I tried it's examples code with some different API's. but i don't know how to use JSON Header.  Can some one please help me? And As there is very very less content is there on internet about api request in mql, It will not help me only but other peoples too.

HTTP, HTML, XML, JSON, and others, are all protocols not related to MQL coding. For those you will find plenty of information elsewhere on the internet (see below), not necessarily here.

There are however some implementations of JSON parsing in the CodeBase and in Articles which you could study as a reference.

Forum on trading, automated trading systems and testing trading strategies

Auto trading the news

Fernando Carreiro, 2016.09.02 00:18

You will have to collect that data from Websites that are offering those services (be they paid or free). You can use the function WebRequest() to obtain data from the web, but you will have to learn about HTTP, and depending on the API the website provides, you may also need to learn REST,  JSON or XML or even standard HTML. These web protocols are however beyond the scope of this forum, so for more information you will have to search the Internet. Here are some links to get you started:

Please note, that collecting and parsing Web data via an API, is not something for a beginner or newbie coder. It requires at least an intermediate level of coding knowledge and good understanding about web protocols.

I also suggest reading the following threads on here:

EDIT: There are also relevant entries in the Codebase that will be of interest to you (had you done a search):

NB! However, please note that WebRequest() only works in EA's and Scripts but not in Indicators.

Forum on trading, automated trading systems and testing trading strategies

How can i send cookie session from WebRequest?

Fernando Carreiro, 2016.06.06 00:31

Maybe you should first learn about the HTTP protocol and how it all works. The cookie session (or any other header) can be transferred back and forth via the "headers" and "result_headers" arguments/parameters:

You will have to parse "result_headers" in accordance with the HTTP Headers format in order to extract the cookie information (or other header information you may need). Then when submitting a new request you will have to build the "headers" parameter according to the HTTP rules.

Here are some helpful links to get you started:

Please, note that this is not really a MQL coding related issue and you should look for advice and help about HTTP on other forums dedicated to such matters.

 

Ohh, I'm Extremely sorry for the delay.

I didn't got any notifications (I don't know why)
And I thought no one replied me.
//---

Actually, I wanted to send message to telegram and retrieve them from there.

I know how to send telegram message, but don't know How to retrieve them.

Earlier I was asking for JSON, because I thought I will send trading information (like which trade is opened and which is closed)
but then I thought Telegram will be better
But I don't know how to retrieve messages from telegram.

Can you please help me with that?



I really really appreciate your help.

 
Kailash Bai Mina: Actually, I wanted to send message to telegram and retrieve them from there. I know how to send telegram message, but don't know How to retrieve them.


Earlier I was asking for JSON, because I thought I will send trading information (like which trade is opened and which is closed) but then I thought Telegram will be better
But I don't know how to retrieve messages from telegram. Can you please help me with that? I really really appreciate your help.

Learn to use the search function. Search in the CodeBase, search in the Articles, search the internet and most obviously, read Telegram's own documentation on their API.

 
That's How I learnt to send Telegram message.

But Still can't find How to retrieve Telegram Message.

Can you please Help me with that?
 
Actually, There is very very less material I found about telegram messages in mql.

It will be great if you help me a bit with that.
 
Kailash Bai Mina: That's How I learnt to send Telegram message. But Still can't find How to retrieve Telegram Message. Can you please Help me with that?
Kailash Bai Mina: Actually, There is very very less material I found about telegram messages in mql. It will be great if you help me a bit with that.

Sorry, but that cannot be resolved will simple guidance. The Telegram API is quite complex. Detailed mentoring is beyond the scope of what I am willing to do on a public forum.

 
Ok, No Problem.
 
Kailash Bai Mina #:
Ok, No Problem.

I solved this with a c++ dll. Make a http request with curl to your server and done.

 
Genaro Cancino #:

I solved this with a c++ dll. Make a http request with curl to your server and done.

You solved what exactly ?

From my understanding all what the OP asked is doable with mql built-in WebRequest(), no need for a DLL, though it works too of course.

 

Doesn't work anymore. The request is blocked by Cloudflare on behalf of ForexFactory. Didn't try the other link (https://www.mql5.com/en/code/15931) yet.

FFC - Forex Factory Calendar
FFC - Forex Factory Calendar
  • www.mql5.com
Modified version of FF Calendar Indicator with new features.