Search code examples
ip-addresswhoispywhois

How to query the RIPE API for JSON


How do you get the RIPE REST API to give you in JSON the same data you'd get from the whois command on the command line?

Eg. Something like the output of

whois 1.1.1.1

Solution

  • Here's how to do this in Python

    from ipwhois import IPWhois
    from pprint import pprint
    
    ip = "1.1.1.1"
    obj = IPWhois(ip)
    results = obj.lookup_rdap(depth=1)
    pprint(results)