Is there a way to programatically get the IP address of the user?
There is no way to feasible get the public IP address directly from the device itself as there might be any number of firewalls between it and the public internet. The best way to get the IP address of a user is to ping your own server on the web and have it tell you the IP address of the user.
Be careful using the IP for any specific identification or session-ing.
The issue comes into play when there would be two (or more) TV's at the same location accessing the same content/widget. You will only get the IP address for the house internet connection/router not a value specific to the actual TV's IP inside the location network.