apilayer / locate.now

A simple API for IP address & geolocation lookup.

Home Page:https://locate.now.sh/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

A simple API for IP address & geolocation lookup.

https://locate.now.sh/


Languages

Language:HTML 72.9%Language:JavaScript 27.1%