Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.0.0+

RDAP Domain Lookup using rdap.org

See more HTTP Misc Examples

Demonstrates doing an RDAP domain lookup using the rdap.org public RDAP server.

Chilkat Rust Downloads

Rust

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let http = chilkat::Http::new();

// Send HTTP requests to https://rdap.org/<type>/<object>, where <type> is the object type (one of domain, ip, autnum, entity etc)
// and <object> is the object identifier (eg example.com, 192.168.0.1, 64496, etc).

// For example, here's a lookup for "oracle.com"
let sb_response = chilkat::StringBuilder::new();
if http.quick_get_sb("https://rdap.org/domain/oracle.com", &sb_response).is_err() {
    println!("{}", http.last_error_text());
    return;
}

let status_code = http.last_status();
if status_code != 200 {
    println!("Error response:");
    println!("{}", sb_response.get_as_string().unwrap_or_default());
    println!("status code: {}", status_code);
    return;
}

// Load the JSON response and examine..

// Use this online tool to generate parsing code from sample JSON: 
// Generate Parsing Code from JSON

let json = chilkat::JsonObject::new();
let _ = json.load_sb(&sb_response);
json.set_emit_compact(false);
println!("{}", json.emit().unwrap_or_default());

// Here's a sample response, and the parsing code generated from the above online tool follows..

// {
//   "objectClassName": "domain",
//   "handle": "607513_DOMAIN_COM-VRSN",
//   "ldhName": "ORACLE.COM",
//   "links": [
//     {
//       "value": "https:\/\/rdap.verisign.com\/com\/v1\/domain\/ORACLE.COM",
//       "rel": "self",
//       "href": "https:\/\/rdap.verisign.com\/com\/v1\/domain\/ORACLE.COM",
//       "type": "application\/rdap+json"
//     },
//     {
//       "value": "https:\/\/rdap.markmonitor.com\/rdap\/domain\/ORACLE.COM",
//       "rel": "related",
//       "href": "https:\/\/rdap.markmonitor.com\/rdap\/domain\/ORACLE.COM",
//       "type": "application\/rdap+json"
//     }
//   ],
//   "status": [
//     "client delete prohibited",
//     "client transfer prohibited",
//     "client update prohibited",
//     "server delete prohibited",
//     "server transfer prohibited",
//     "server update prohibited"
//   ],
//   "entities": [
//     {
//       "objectClassName": "entity",
//       "handle": "292",
//       "roles": [
//         "registrar"
//       ],
//       "publicIds": [
//         {
//           "type": "IANA Registrar ID",
//           "identifier": "292"
//         }
//       ],
//       "vcardArray": [
//         "vcard",
//         [
//           [
//             "version",
//             {},
//             "text",
//             "4.0"
//           ],
//           [
//             "fn",
//             {},
//             "text",
//             "MarkMonitor Inc."
//           ]
//         ]
//       ],
//       "entities": [
//         {
//           "objectClassName": "entity",
//           "roles": [
//             "abuse"
//           ],
//           "vcardArray": [
//             "vcard",
//             [
//               [
//                 "version",
//                 {},
//                 "text",
//                 "4.0"
//               ],
//               [
//                 "fn",
//                 {},
//                 "text",
//                 ""
//               ],
//               [
//                 "tel",
//                 {
//                   "type": "voice"
//                 },
//                 "uri",
//                 "tel:+1.2086851750"
//               ],
//               [
//                 "email",
//                 {},
//                 "text",
//                 "abusecomplaints@markmonitor.com"
//               ]
//             ]
//           ]
//         }
//       ]
//     }
//   ],
//   "events": [
//     {
//       "eventAction": "registration",
//       "eventDate": "1988-12-02T05:00:00Z"
//     },
//     {
//       "eventAction": "expiration",
//       "eventDate": "2025-12-01T05:00:00Z"
//     },
//     {
//       "eventAction": "last changed",
//       "eventDate": "2024-10-30T09:32:52Z"
//     },
//     {
//       "eventAction": "last update of RDAP database",
//       "eventDate": "2024-11-26T14:11:14Z"
//     }
//   ],
//   "secureDNS": {
//     "delegationSigned": false
//   },
//   "nameservers": [
//     {
//       "objectClassName": "nameserver",
//       "ldhName": "A1-160.AKAM.NET"
//     },
//     {
//       "objectClassName": "nameserver",
//       "ldhName": "A11-66.AKAM.NET"
//     },
//     {
//       "objectClassName": "nameserver",
//       "ldhName": "A13-65.AKAM.NET"
//     },
//     {
//       "objectClassName": "nameserver",
//       "ldhName": "A18-67.AKAM.NET"
//     },
//     {
//       "objectClassName": "nameserver",
//       "ldhName": "NS1.P201.DNS.ORACLECLOUD.NET"
//     },
//     {
//       "objectClassName": "nameserver",
//       "ldhName": "NS2.P201.DNS.ORACLECLOUD.NET"
//     },
//     {
//       "objectClassName": "nameserver",
//       "ldhName": "NS3.P201.DNS.ORACLECLOUD.NET"
//     },
//     {
//       "objectClassName": "nameserver",
//       "ldhName": "NS4.P201.DNS.ORACLECLOUD.NET"
//     }
//   ],
//   "rdapConformance": [
//     "rdap_level_0",
//     "icann_rdap_technical_implementation_guide_0",
//     "icann_rdap_response_profile_0"
//   ],
//   "notices": [
//     {
//       "title": "Terms of Use",
//       "description": [
//         "Service subject to Terms of Use."
//       ],
//       "links": [
//         {
//           "href": "https:\/\/www.verisign.com\/domain-names\/registration-data-access-protocol\/terms-service\/index.xhtml",
//           "type": "text\/html"
//         }
//       ]
//     },
//     {
//       "title": "Status Codes",
//       "description": [
//         "For more information on domain status codes, please visit https:\/\/icann.org\/epp"
//       ],
//       "links": [
//         {
//           "href": "https:\/\/icann.org\/epp",
//           "type": "text\/html"
//         }
//       ]
//     },
//     {
//       "title": "RDDS Inaccuracy Complaint Form",
//       "description": [
//         "URL of the ICANN RDDS Inaccuracy Complaint Form: https:\/\/icann.org\/wicf"
//       ],
//       "links": [
//         {
//           "href": "https:\/\/icann.org\/wicf",
//           "type": "text\/html"
//         }
//       ]
//     }
//   ]
// }

let mut j: i32 = 0;
let mut count_j: i32 = 0;
let mut k: i32 = 0;
let mut count_k: i32 = 0;
let json1 = chilkat::JsonObject::new();
let mut i1: i32 = 0;
let mut count_i1: i32 = 0;
let mut j1: i32 = 0;
let mut count_j1: i32 = 0;

let mut object_class_name = json.string_of("objectClassName").unwrap_or_default();
let mut handle = json.string_of("handle").unwrap_or_default();
let mut ldh_name = json.string_of("ldhName").unwrap_or_default();
let delegation_signed = json.bool_of("secureDNS.delegationSigned");
let mut i = 0;
let mut count_i = json.size_of_array("links");
while i < count_i {
    json.set_i(i);
    let _ = json.string_of("links[i].value").unwrap_or_default();
    let _ = json.string_of("links[i].rel").unwrap_or_default();
    let _ = json.string_of("links[i].href").unwrap_or_default();
    let _ = json.string_of("links[i].type").unwrap_or_default();
    i = i + 1;
}

i = 0;
count_i = json.size_of_array("status");
while i < count_i {
    json.set_i(i);
    let _ = json.string_of("status[i]").unwrap_or_default();
    i = i + 1;
}

i = 0;
count_i = json.size_of_array("entities");
while i < count_i {
    json.set_i(i);
    object_class_name = json.string_of("entities[i].objectClassName").unwrap_or_default();
    handle = json.string_of("entities[i].handle").unwrap_or_default();
    j = 0;
    count_j = json.size_of_array("entities[i].roles");
    while j < count_j {
        json.set_j(j);
        let _ = json.string_of("entities[i].roles[j]").unwrap_or_default();
        j = j + 1;
    }

    j = 0;
    count_j = json.size_of_array("entities[i].publicIds");
    while j < count_j {
        json.set_j(j);
        let _ = json.string_of("entities[i].publicIds[j].type").unwrap_or_default();
        let _ = json.string_of("entities[i].publicIds[j].identifier").unwrap_or_default();
        j = j + 1;
    }

    j = 0;
    count_j = json.size_of_array("entities[i].vcardArray");
    while j < count_j {
        json.set_j(j);
        let _ = json.string_of("entities[i].vcardArray[j]").unwrap_or_default();
        k = 0;
        count_k = json.size_of_array("entities[i].vcardArray[j]");
        while k < count_k {
            json.set_k(k);
            let _ = json.object_of2("entities[i].vcardArray[j][k]", &json1);

            i1 = 0;
            count_i1 = json1.size_of_array("");
            while i1 < count_i1 {
                json1.set_i(i1);
                let _ = json1.string_of("[i]").unwrap_or_default();
                i1 = i1 + 1;
            }

            k = k + 1;
        }

        j = j + 1;
    }

    j = 0;
    count_j = json.size_of_array("entities[i].entities");
    while j < count_j {
        json.set_j(j);
        object_class_name = json.string_of("entities[i].entities[j].objectClassName").unwrap_or_default();
        k = 0;
        count_k = json.size_of_array("entities[i].entities[j].roles");
        while k < count_k {
            json.set_k(k);
            let _ = json.string_of("entities[i].entities[j].roles[k]").unwrap_or_default();
            k = k + 1;
        }

        k = 0;
        count_k = json.size_of_array("entities[i].entities[j].vcardArray");
        while k < count_k {
            json.set_k(k);
            let _ = json.string_of("entities[i].entities[j].vcardArray[k]").unwrap_or_default();
            let _ = json.object_of2("entities[i].entities[j].vcardArray[k]", &json1);

            i1 = 0;
            count_i1 = json1.size_of_array("");
            while i1 < count_i1 {
                json1.set_i(i1);
                j1 = 0;
                count_j1 = json1.size_of_array("[i]");
                while j1 < count_j1 {
                    json1.set_j(j1);
                    let _ = json1.string_of("[i][j]").unwrap_or_default();
                    j1 = j1 + 1;
                }

                i1 = i1 + 1;
            }

            k = k + 1;
        }

        j = j + 1;
    }

    i = i + 1;
}

i = 0;
count_i = json.size_of_array("events");
while i < count_i {
    json.set_i(i);
    let _ = json.string_of("events[i].eventAction").unwrap_or_default();
    let _ = json.string_of("events[i].eventDate").unwrap_or_default();
    i = i + 1;
}

i = 0;
count_i = json.size_of_array("nameservers");
while i < count_i {
    json.set_i(i);
    object_class_name = json.string_of("nameservers[i].objectClassName").unwrap_or_default();
    ldh_name = json.string_of("nameservers[i].ldhName").unwrap_or_default();
    i = i + 1;
}

i = 0;
count_i = json.size_of_array("rdapConformance");
while i < count_i {
    json.set_i(i);
    let _ = json.string_of("rdapConformance[i]").unwrap_or_default();
    i = i + 1;
}

i = 0;
count_i = json.size_of_array("notices");
while i < count_i {
    json.set_i(i);
    let _ = json.string_of("notices[i].title").unwrap_or_default();
    j = 0;
    count_j = json.size_of_array("notices[i].description");
    while j < count_j {
        json.set_j(j);
        let _ = json.string_of("notices[i].description[j]").unwrap_or_default();
        j = j + 1;
    }

    j = 0;
    count_j = json.size_of_array("notices[i].links");
    while j < count_j {
        json.set_j(j);
        let _ = json.string_of("notices[i].links[j].href").unwrap_or_default();
        let _ = json.string_of("notices[i].links[j].type").unwrap_or_default();
        j = j + 1;
    }

    i = i + 1;
}