Sample code for 30+ languages & platforms
Xbase++ 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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oSbResponse
LOCAL nStatusCode
LOCAL oJson
LOCAL cValue
LOCAL cRel
LOCAL cHref
LOCAL cV_type
LOCAL cStrVal
LOCAL j
LOCAL nCount_j
LOCAL cIdentifier
LOCAL k
LOCAL nCount_k
LOCAL oJson1
LOCAL nI1
LOCAL nCount_i1
LOCAL nJ1
LOCAL nCount_j1
LOCAL cEventAction
LOCAL cEventDate
LOCAL cTitle
LOCAL cObjectClassName
LOCAL cHandle
LOCAL cLdhName
LOCAL nDelegationSigned
LOCAL i
LOCAL nCount_i

nSuccess := 0

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

oHttp := CreateObject("Chilkat.Http")

//  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"
oSbResponse := CreateObject("Chilkat.StringBuilder")
nSuccess := oHttp:QuickGetSb("https://rdap.org/domain/oracle.com", oSbResponse)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oSbResponse:destroy()
    RETURN
ENDIF

nStatusCode := oHttp:LastStatus
IF (nStatusCode != 200)
    ? "Error response:"
    ? oSbResponse:GetAsString()
    ? "status code: " + Str(nStatusCode)
    oHttp:destroy()
    oSbResponse:destroy()
    RETURN
ENDIF

//  Load the JSON response and examine..

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

oJson := CreateObject("Chilkat.JsonObject")
oJson:LoadSb(oSbResponse)
oJson:EmitCompact := 0
? oJson:Emit()

//  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"
//          }
//        ]
//      }
//    ]
//  }

oJson1 := CreateObject("Chilkat.JsonObject")

cObjectClassName := oJson:StringOf("objectClassName")
cHandle := oJson:StringOf("handle")
cLdhName := oJson:StringOf("ldhName")
nDelegationSigned := oJson:BoolOf("secureDNS.delegationSigned")
i := 0
nCount_i := oJson:SizeOfArray("links")
DO WHILE i < nCount_i
    oJson:I := i
    cValue := oJson:StringOf("links[i].value")
    cRel := oJson:StringOf("links[i].rel")
    cHref := oJson:StringOf("links[i].href")
    cV_type := oJson:StringOf("links[i].type")
    i := i + 1
ENDDO
i := 0
nCount_i := oJson:SizeOfArray("status")
DO WHILE i < nCount_i
    oJson:I := i
    cStrVal := oJson:StringOf("status[i]")
    i := i + 1
ENDDO
i := 0
nCount_i := oJson:SizeOfArray("entities")
DO WHILE i < nCount_i
    oJson:I := i
    cObjectClassName := oJson:StringOf("entities[i].objectClassName")
    cHandle := oJson:StringOf("entities[i].handle")
    j := 0
    nCount_j := oJson:SizeOfArray("entities[i].roles")
    DO WHILE j < nCount_j
        oJson:J := j
        cStrVal := oJson:StringOf("entities[i].roles[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJson:SizeOfArray("entities[i].publicIds")
    DO WHILE j < nCount_j
        oJson:J := j
        cV_type := oJson:StringOf("entities[i].publicIds[j].type")
        cIdentifier := oJson:StringOf("entities[i].publicIds[j].identifier")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJson:SizeOfArray("entities[i].vcardArray")
    DO WHILE j < nCount_j
        oJson:J := j
        cStrVal := oJson:StringOf("entities[i].vcardArray[j]")
        k := 0
        nCount_k := oJson:SizeOfArray("entities[i].vcardArray[j]")
        DO WHILE k < nCount_k
            oJson:K := k
            oJson:ObjectOf2("entities[i].vcardArray[j][k]", oJson1)

            nI1 := 0
            nCount_i1 := oJson1:SizeOfArray("")
            DO WHILE nI1 < nCount_i1
                oJson1:I := nI1
                cStrVal := oJson1:StringOf("[i]")
                nI1 := nI1 + 1
            ENDDO
            k := k + 1
        ENDDO
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJson:SizeOfArray("entities[i].entities")
    DO WHILE j < nCount_j
        oJson:J := j
        cObjectClassName := oJson:StringOf("entities[i].entities[j].objectClassName")
        k := 0
        nCount_k := oJson:SizeOfArray("entities[i].entities[j].roles")
        DO WHILE k < nCount_k
            oJson:K := k
            cStrVal := oJson:StringOf("entities[i].entities[j].roles[k]")
            k := k + 1
        ENDDO
        k := 0
        nCount_k := oJson:SizeOfArray("entities[i].entities[j].vcardArray")
        DO WHILE k < nCount_k
            oJson:K := k
            cStrVal := oJson:StringOf("entities[i].entities[j].vcardArray[k]")
            oJson:ObjectOf2("entities[i].entities[j].vcardArray[k]", oJson1)

            nI1 := 0
            nCount_i1 := oJson1:SizeOfArray("")
            DO WHILE nI1 < nCount_i1
                oJson1:I := nI1
                nJ1 := 0
                nCount_j1 := oJson1:SizeOfArray("[i]")
                DO WHILE nJ1 < nCount_j1
                    oJson1:J := nJ1
                    cStrVal := oJson1:StringOf("[i][j]")
                    nJ1 := nJ1 + 1
                ENDDO
                nI1 := nI1 + 1
            ENDDO
            k := k + 1
        ENDDO
        j := j + 1
    ENDDO
    i := i + 1
ENDDO
i := 0
nCount_i := oJson:SizeOfArray("events")
DO WHILE i < nCount_i
    oJson:I := i
    cEventAction := oJson:StringOf("events[i].eventAction")
    cEventDate := oJson:StringOf("events[i].eventDate")
    i := i + 1
ENDDO
i := 0
nCount_i := oJson:SizeOfArray("nameservers")
DO WHILE i < nCount_i
    oJson:I := i
    cObjectClassName := oJson:StringOf("nameservers[i].objectClassName")
    cLdhName := oJson:StringOf("nameservers[i].ldhName")
    i := i + 1
ENDDO
i := 0
nCount_i := oJson:SizeOfArray("rdapConformance")
DO WHILE i < nCount_i
    oJson:I := i
    cStrVal := oJson:StringOf("rdapConformance[i]")
    i := i + 1
ENDDO
i := 0
nCount_i := oJson:SizeOfArray("notices")
DO WHILE i < nCount_i
    oJson:I := i
    cTitle := oJson:StringOf("notices[i].title")
    j := 0
    nCount_j := oJson:SizeOfArray("notices[i].description")
    DO WHILE j < nCount_j
        oJson:J := j
        cStrVal := oJson:StringOf("notices[i].description[j]")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJson:SizeOfArray("notices[i].links")
    DO WHILE j < nCount_j
        oJson:J := j
        cHref := oJson:StringOf("notices[i].links[j].href")
        cV_type := oJson:StringOf("notices[i].links[j].type")
        j := j + 1
    ENDDO
    i := i + 1
ENDDO

oHttp:destroy()
oSbResponse:destroy()
oJson:destroy()
oJson1:destroy()