There is such a site: wtfismyip.com, where you can conveniently get the address in a text file or json. I don’t know much about Linux (RouterOS is Linux after all) and I can’t figure out how to parse the IP address that this site gives out.
I found an example of saving the address to a file.
/tool fetch url="https://wtfismyip.com/text" mode=https dst-path=ip.txt
local ip [file get ip.txt contents ]
:put $ip
But I would not like to write something to the Mikrotik disk. I would like to immediately get a ready-made ip.
Moreover, I would like to have two options: from text and from json.
Thank you, I was just planning to start working on scripts again closer to the New Year, and in particular parsing json. Now I will know what to focus on.
Special thanks for this site and code. Before this, I could not find a site where the address is obtained separately (in a file, in json, or something else)
Now Mikrotik has a built-in function for deserializing JSON. But I can’t parse the answer. Can you show an example of how to do this for the JSON format for this example https://api.ipify.org?format=json?