well, if using python, from this page,
[Login to see the link]
use the first answer, I got the first IP,
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
print(s.getsockname()[0])
s.close()
use the second answer, I got the second IP,
socket.gethostbyname(socket.gethostname())
it is not uncommon for an adapter to have multiple IPs.
maybe return all IPs , on return only the "primary" IP (the one with a default route).