BGP.guru

BGP.guru

Nerd blog.

14 Sep 2014

IP Quail API

While I’ve been supporting making requests to ipquail.com with useragent curl and responding with only plaintext, I don’t have a formal API for the site. Being inspired by the recent Arin on the Road talks on their Whois-RWS and Reg-RWS systems, I set out to start to write an API for ipquail.com.

I chose to write it using Python/Flask, and deploy it using uWSGI/nginx. Several hours later, I now have code up on Github, and a functioning beta version online which returns the remote_addr of the client, JSONified.

This is the output so far:

curl -i http://6.ipquail.com/ip/api/v1.0/remote_addr
HTTP/1.1 200 OK
Server: nginx/1.6.2
Date: Wed, 24 Sep 2014 05:46:56 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Allow-Headers: X-Requested-With,Accept,Content-Type,Origin

{
	"ip": "2604:4280:d00d:202:79f2:da92:6e9:c7c3"
}

API Documentation (for now)

GET http://4.ipquail.com/ip/api/v1.0/remote_addr

Gets the current IPv4 address.

GET http://6.ipquail.com/ip/api/v1.0/remote_addr

Gets the current IPv6 address.

Update 2014-09-24: This has been updated with the production URLs, headers, and documentation. You’ll notice if you read the ipquail/README.md that I actually generate the production API responses using simple HTML/SSI and some header fakery. :-)


Theodore Baschak - Theo is a network engineer with experience operating core internet technologies like HTTP, HTTPS and DNS. He has extensive experience running service provider networks with OSPF, MPLS, and BGP.