This endpoint allows you to retrieve your public IP address and related network and geolocation information in JSON format.
GET /api/my-ip.php
This endpoint is accessed relative to the website's domain (e.g., https://echomyip.net
).
GET
The endpoint returns a JSON object with the following structure on success (HTTP status 200):
{
"ip": "YOUR_IP_ADDRESS",
"timestamp": "YYYY-MM-DD HH:MM:SS",
"about": "API endpoint to get your public IP address and network information.",
"geolocation": {
"country": "Country Name",
"region": "Region Name",
"city": "City Name",
"timezone": "Timezone",
"latitude": "Latitude",
"longitude": "Longitude"
},
"network": {
"isp": "ISP Name",
"asn": "ASN"
}
}
- ip
: The public IP address of the client making the request.
- timestamp
: The server timestamp when the request was processed.
- about
: A brief description of the endpoint.
- geolocation
: An object containing geolocation details:
- country
: The country derived from the IP address.
- region
: The region/state derived from the IP address.
- city
: The city derived from the IP address.
- timezone
: The timezone derived from the IP address.
- latitude
: The approximate latitude.
- longitude
: The approximate longitude.
- network
: An object containing network details:
- isp
: The Internet Service Provider name.
- asn
: The Autonomous System Number.
To prevent abuse, this endpoint has basic rate limiting applied. Currently, the limit is set to 10 requests per minute per IP address.
If you exceed the rate limit, you will receive an HTTP 429 Too Many Requests status code and a JSON response like this:
{
"error": "Rate limit exceeded. Please try again later."
}
You can access this endpoint using any HTTP client, such as a web browser, curl
, or JavaScript's fetch
API.
Using curl:
curl https://echomyip.net/api/my-ip.php
Using JavaScript (Fetch API):
fetch('https://echomyip.net/api/my-ip.php')
.then(response => {
if (!response.ok) {
if (response.status === 429) {
throw new Error('Rate limit exceeded');
}
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error fetching IP:', error));
```