Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

apilayer/locate.now

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

locate.now

A simple API for IP address & geolocation lookup.


Visit locate.now.sh for a live demo. Check out my blog and follow me on Twitter.


~ ❯❯❯ curl 'https://locate.now.sh/ip/json'
{"ip":"127.0.0.1"}


Usage

IP address lookup

Format:

https://locate.now.sh/ip/:type
API URI Type Sample Response
https://locate.now.sh/ip text 127.0.0.1
https://locate.now.sh/ip/json json {"ip":"127.0.0.1"}
https://locate.now.sh/ip/jsonp jsonp callback({"ip":"127.0.0.1"})
https://locate.now.sh/ip/jsonp/lookupip jsonp lookupip({"ip":"127.0.0.1"})

Examples:

~ ❯❯❯ curl https://locate.now.sh/ip
127.0.0.1

~ ❯❯❯ wget -qO- https://locate.now.sh/ip/json
{"ip":"127.0.0.1"}

Geolocation lookup

Format:

https://locate.now.sh/geo
API URI Type Sample Response
https://locate.now.sh/geo json {"range":[532553667,543523605],"country":"GB","region":"H8","city":"Liverpool","ll":[51.4157,-3],"metro":0,"zip":0}

Examples:

~ ❯❯❯ curl https://locate.now.sh/geo
{"range":[532553667,543523605],"country":"GB","region":"H8","city":"Liverpool","ll":[51.4157,-3],"metro":0,"zip":0}`

~ ❯❯❯ wget -qO- https://locate.now.sh/geo
{"range":[532553667,543523605],"country":"GB","region":"H8","city":"Liverpool","ll":[51.4157,-3],"metro":0,"zip":0}`

Installation & Configuration

Clone the repository and install all dependencies by running:

~ ❯❯❯ git clone https://github.com/apilayer/locate.now
~ ❯❯❯ cd locate.now/
~/locate.now ❯❯❯ npm install

Subsequently, create a .env file and declare a variable called SECRET (for session security purposes):

~/locate.now ❯❯❯ echo "SECRET=[your-secret-goes-here]" > .env
~/locate.now ❯❯❯ npm start

You can then access the service by navigating to localhost:3000.


Deployment

First, download now:

~ ❯❯❯ npm install -g now

Then, run now from within the directory of locate.now:

~/locate.now ❯❯❯ now

License

Copyright (c) 2018 by apilayer. Some rights reserved.

locate.now is under the terms of the MIT License, following all clarifications stated in the license file.