Currently, there doesn’t seem to be a way to discover the current user’s IP address through the API if they’re logged in. However, sometimes this is useful information.
When using the intestactions feature of action=query&prop=info (test if the user is allowed to perform a certain action), it’s possible that the user will get a permission error because they’re using an IP address that has been blocked, including for logged-in users (e. g. a VPN). But the response doesn’t include the affected IP, so the app/script/etc. using the API has no way to present the user with a message like MediaWiki:blockedtext:
… Your current IP address is $3, and the block ID is #$5.
Please include all above details in any queries you make.
It’s possible to make a separate request for the block with that number, of course, but that will only yield the entire IP range, not the IP of the user being affected.
Add an ip prop to the action=query&meta=userinfo module.
Are there any privacy concerns with letting users query their own IP address? (There are plenty of other websites that offer this feature, of course, but perhaps there are some scenarios where it still matters?)