You can not.
You can define IP addresses on different interfaces, and there can be several. These can be the IP addresses of the local network (10.0.0.0/8, 192.168.0.0/16, etc.), or they can be routed over the Internet.
It seems you are asking: "If I have 192.168.0.3, how can I get my IP address on the Internet?" There is no function call for this: such an IP may exist, it may not exist, maybe even more than a few.
, : - , , , IP-. -, API- .
, uPnP, , .