MyIpMeow Logo

XML API Usage Examples

Fetch and parse your public IPv4 and IPv6 address from our XML endpoint using your favorite tools!

← Back to API Docs
XML Output Example
GET https://myipmeow.com/xml
<myipmeow>
   <ipv4>203.0.113.100</ipv4>
   <ipv6>2001:0db8:85a3:0000:0000:8a2e:0370:7334</ipv6>
</myipmeow>
Parsing with curl and xmllint
Bash
curl -sL https://myipmeow.com/xml | xmllint --xpath 'string(//ipv4)' -
curl -sL https://myipmeow.com/xml | xmllint --xpath 'string(//ipv6)' -

Install xmllint: sudo apt-get install libxml2-utils (Debian) or sudo yum install libxml2 (RedHat)

Parsing with curl and grep
Bash
curl -sL https://myipmeow.com/xml | grep -oP '(?<=\).*?(?=\)'
curl -sL https://myipmeow.com/xml | grep -oP '(?<=\).*?(?=\)'
Parsing Both Addresses
Bash
addresses=$(curl -sL https://myipmeow.com/xml)
ipv4=$(echo $addresses | xmllint --xpath 'string(//ipv4)' -)
ipv6=$(echo $addresses | xmllint --xpath 'string(//ipv6)' -)
echo "IPv4: $ipv4, IPv6: $ipv6"
Code Examples in Different Languages
PHP
<?php
$xml = simplexml_load_file('https://myipmeow.com/xml');
echo $xml->ipv4;
echo $xml->ipv6;
?>
Python
import requests
r = requests.get('https://myipmeow.com/xml')
print(r.text)