Gives geolocation / timezone infos about an IP
- Node >=18
- Download token from
https://www.ip2location.com
set in .env (DOWNLOAD_TOKEN
)
yarn setup
: Run post-install setupyarn setup
yarn test
The API key should be set as the header X-Api-Key
on every request.
yarn dev
: Start the development watcheryarn start
: Start the server
The endpoints are the following :
/api/ip/{XXX.XXX.XXX.XXX}
: Get some infos about a v4 or v6 IP (exemple response)/api/timezone
: List the timezones (exemple response)/api/ip/{XXX.XXX.XXX.XXX}
: Get some infos about a timezone (exemple response)
GET http://localhost:9393/api/ip/1.1.1.1
{
data: {
ip: "1.1.1.1"
ipNo: "16843009" // IP in decimal format
countryShort: "US"
countryLong: "United States of America"
region: "California"
city: "San Jose"
zipCode: "95101"
latitude: 37.33939
longitude: -121.894958
timeZone: "America/Los_Angeles"
}
}
GET http://localhost:9393/api/timezone
{
data: [
{
name "Pacific/Midway"
country_code "UM"
dst "0" // Daylight Saving Time
gmt_offset -39600 // Offset to GMT in seconds
},
...,
{
name "Europe/Paris"
country_code "FR"
dst "1"
gmt_offset 7200
},
...
]
}
GET http://localhost:9393/api/timezone/Europe/Paris
{
data: {
name "Europe/Paris"
country_code "FR"
dst "1"
gmt_offset 7200
},
}