API Usage

In addition to querying the IP addresses using the main form, you can also leverage the API to request historic information fromt the database

Querying

This API allows for queries of one or more IP address in a single request. In order to reduce the load on the server, please condense your IPs into a single or fewer requests and parse the response to gather information per IP address.

Request

Since our requests include IP addresses with the . character, we are using POST requests to query for the data.

A sample POST request is demonstrated below:


$ curl --silent \
    -H 'Content-type: application/json' \
    -X POST \
    http://awsip.chapinb.com:8080/api/v1.0/query \
    -d '{"ipaddr": ["13.52.4.25", "37.37.37.37", "18.220.48.96"]}'
    
Parameter Description
curl our request tool
--silent supress request statistic information from cURL
-H 'Content-type: application/json' specifying that our request is sending JSON data
-X POST identifying that that this is a POST request
http://awsip.chapinb.com:8080/api/v1.0/query the URL we are querying. Note that you will need to replace awsip.chapinb.com:8080 with the actual host information
-d '{"ipaddr": ["13.52.4.25", "37.37.37.37", "18.220.48.96"]}' the data we are sending with our request.

The request data must contain a key named ipaddr containing a list of one or more IP addresses.

Response

Since our requests include IP addresses with the . character, we are using POST requests to query for the data.

A sample response to the prior request is demonstrated below:

{
  "query_seconds": 0.114051,
  "records": {
    "13.52.4.25": {
      "message": "",
      "results": [
        {
          "cidr": "13.52.0.0/16",
          "first_collected": "2017-09-08T16:27:01",
          "last_collected": "2019-01-13T08:00:01",
          "region": "us-west-1",
          "service": "AMAZON"
        },
        {
          "cidr": "13.52.0.0/16",
          "first_collected": "2017-09-08T16:27:01",
          "last_collected": "2019-01-13T08:00:01",
          "region": "us-west-1",
          "service": "EC2"
        }
      ]
    },
    "18.220.48.96": {
      "message": "",
      "results": [
        {
          "cidr": "18.220.0.0/14",
          "first_collected": "2017-08-24T11:08:39",
          "last_collected": "2019-01-13T08:00:01",
          "region": "us-east-2",
          "service": "AMAZON"
        },
        {
          "cidr": "18.220.0.0/14",
          "first_collected": "2017-08-24T11:08:39",
          "last_collected": "2019-01-13T08:00:01",
          "region": "us-east-2",
          "service": "EC2"
        }
      ]
    },
    "27.37.37.37": {
      "message": "No results found",
      "results": []
    }
  },
  "requested_ips": [
    "13.52.4.25",
    "27.37.37.37",
    "18.220.48.96"
  ]
}