https://github.com/jenil/ipinfodb-middlware
An Express middleware to get the client IP & time details from ipinfodb.com
https://github.com/jenil/ipinfodb-middlware
express-middleware ip-address ipinfodb
Last synced: 3 months ago
JSON representation
An Express middleware to get the client IP & time details from ipinfodb.com
- Host: GitHub
- URL: https://github.com/jenil/ipinfodb-middlware
- Owner: jenil
- Created: 2015-12-15T18:30:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-15T18:44:16.000Z (over 9 years ago)
- Last Synced: 2025-01-19T06:14:40.332Z (5 months ago)
- Topics: express-middleware, ip-address, ipinfodb
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Express Middleware for [ipinfodb.com](http://www.ipinfodb.com/ip_location_api.php)
## Install
`npm install ipinfodb-middleware`
## Usage
```javascript
var express = require('express');
var app = express();
var key = 'abcd'; // your ipinfodb.com API key
var ipinfodb = require('ipinfodb-middleware');app.enable('trust proxy');
app.use(ipinfodb({key: key}));
app.get('/', function (req, res) {
// IP info is now available in req.ipinfo
res.json(req.ipinfo);
});app.listen(3000);
```
The `req.ipinfo` will contain the following output if things worked fine.
```json
{
"statusCode": "OK",
"statusMessage": "",
"ipAddress": "122.161.60.x",
"countryCode": "IN",
"countryName": "India",
"regionName": "Delhi",
"cityName": "Delhi",
"zipCode": "110008",
"latitude": "28.6667",
"longitude": "77.2167",
"timeZone": "+05:30"
}
```
---##### Author
Jenil Gogari
- [Website](http://jgog.in)
- [Behance](https://www.behance.net/jenil)
- [Twitter](https://twitter.com/GeekGogari)