API Usage


MyIP provides a blisteringly simple HTTP based API you can call and we also provide responses in a variety of formats. Below you will find the various URL endpoints you can call with an example of their expected response.

URL Response Type Example
https://api.my-ip.io/ip Plain Text
165.227.66.230
https://api.my-ip.io/ip.txt Plain Text
165.227.66.230
https://api.my-ip.io/ip.json JSON
{
	"success": true,
	"ip": "165.227.66.230",
	"type": "IPv4"
}
https://api.my-ip.io/ip.jsonp JSONP
callback({
	"success": true,
	"ip": "165.227.66.230",
	"type": "IPv4"
});
https://api.my-ip.io/ip.jsonp?callback=name JSONP (with named callback)
name({
	"success": true,
	"ip": "165.227.66.230",
	"type": "IPv4"
});
https://api.my-ip.io/ip.xml XML
<?xml version="1.0" encoding="UTF-8"?>
<result>
    <success>true</success>
    <ip>165.227.66.230</ip>
    <type>IPv4</type>
</result>

You will generally call our API using the host api.my-ip.io, however we also have hosts if you just need to target a specific IP version, for example if you're only running on one specific stack. Each is listed below.

Host Supported Versions
api.my-ip.io IPv4, IPv6
api4.my-ip.io IPv4
api6.my-ip.io IPv6

Examples


Below you can find examples of how to call MyIP in a variety of languages. If you have a missing example or a better example please feel free to send it us.

Bash
C# (HttpClient)
C# (WebClient)
Go
Java
JavaScript
JavaScript (jQuery)
Lua
NodeJS
Objective-C
PHP
Perl
PowerShell
Python
Ruby
Scala

Libraries


Don't want to implement everything yourself? You can use one of our free libraries below.

NOTE: Don't see a library for your programming language of choice? If you create one we'll be happy to link to it below. Just send us an e-mail with the details.

Library URL Language Author
https://github.com/Workshell/myip-dotnet
.NET (C#)
Workshell Ltd
https://github.com/Workshell/myip-js
JavaScript
Workshell Ltd