HTTP API for looking up information about an IPv4 or IPv6 address.
- Application Entrypoint:
dist/api.js
- Starts the HTTP API Express server
package.json
scripts:npm run api
- Runs thedist/api.js
entrypoint to start the HTTP API Express server
package.json --save
Core Dependencies:express
- Fast, unopinionated, minimalist web framework for Node.jscors
- Provides Connect/Express middleware that can be used to enable CORS with various optionssupertest
- HTTP assertions made easy via superagent used to test the Express HTTP API
package.json --save-dev
Development Dependencies:@types/express
- Type definitions forexpress
@types/cors
- Type definitions forcors
@types/supertest
- Type definitions forsupertest
This API is documented in two locations:
- Manually documented - This doc
http_api.md
- Swagger workflow documented in
swagger.md
- NOTE: Hosted Swagger docs has a full IP Address Lookup HTTP API client implementation to use for development/testing!
- GET /
- HTTP response 200
{ "success": true }
- GET "/lookup-ip/209.142.68.29?fields=continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,isp,org,as,asname,mobile,proxy,hosting,query,reverse"
- HTTP response 200
{
"success": true,
"query_start_at": "2023-09-00T00:00:17.000Z",
"query_stop_at": "2023-09-00T00:00:17.050Z",
"query_ms": 50,
"data": {
"queried_ip_addr": "209.142.68.29",
"country": "United States",
"country_code": "US",
"continent": "North America",
"continent_code": "NA",
"region": "CA",
"region_name": "California",
"city": "Test City",
"district": "Test District",
"zip": "55555",
"lat": 50.123,
"lon": -100.123,
"timezone": "America/Los_Angeles",
"offset": -25200,
"isp": "Test ISP",
"org": "Test Company",
"as": "AS123123 Test Company",
"as_name": "TEST-ASNAME",
"is_mobile": false,
"is_proxy": false,
"is_hosting": false,
"reverse": "reverse.123.123.com"
}
}
- GET "/lookup-ip/209.142.68.29?fields=continentCode,countryCode,region,regionName,city,zip,lat,lon"
- HTTP response 200
{
"success": true,
"query_start_at": "2023-09-00T00:00:17.000Z",
"query_stop_at": "2023-09-00T00:00:17.050Z",
"query_ms": 50,
"data": {
"country_code": "US",
"continent_code": "NA",
"region": "CA",
"region_name": "California",
"city": "Test City",
"zip": "55555",
"lat": 50.123,
"lon": -100.123
}
}
- GET "/lookup-ip/?fields=continentCode,countryCode,region,regionName,city,zip,lat,lon"
- HTTP response 400
{
"success": false,
"errors": [
"IP address cannot be empty",
"IP address format invalid"
]
}
- GET "/lookup-ip/209.142.68.256?fields=continentCode,countryCode,region,regionName,city,zip,lat,lon"
- HTTP response 400
{
"success": false,
"errors": [
"IP address format invalid"
]
}
- GET "/lookup-ip/209.142.68.29?fields=continentCode,countryCode,region,regionName,city,zip,lat,lon"
- HTTP response 400
{
"success": false,
"query_start_at": "2023-09-00T00:00:17.000Z",
"query_stop_at": "2023-09-00T00:00:17.050Z",
"query_ms": 50,
"errors": [
"API response status \"fail\" != \"success\"",
"API error message \"invalid query\""
]
}