PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkHttp.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
success.i = 0
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; 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"
sbResponse.i = CkStringBuilder::ckCreate()
If sbResponse.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkHttp::ckQuickGetSb(http,"https://rdap.org/domain/oracle.com",sbResponse)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponse)
ProcedureReturn
EndIf
statusCode.i = CkHttp::ckLastStatus(http)
If statusCode <> 200
Debug "Error response:"
Debug CkStringBuilder::ckGetAsString(sbResponse)
Debug "status code: " + Str(statusCode)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponse)
ProcedureReturn
EndIf
; Load the JSON response and examine..
; Use this online tool to generate parsing code from sample JSON:
; Generate Parsing Code from JSON
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(json,sbResponse)
CkJsonObject::setCkEmitCompact(json, 0)
Debug CkJsonObject::ckEmit(json)
; 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"
; }
; ]
; }
; ]
; }
value.s
rel.s
href.s
v_type.s
strVal.s
j.i
count_j.i
identifier.s
k.i
count_k.i
json1.i = CkJsonObject::ckCreate()
If json1.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
i1.i
count_i1.i
j1.i
count_j1.i
eventAction.s
eventDate.s
title.s
objectClassName.s = CkJsonObject::ckStringOf(json,"objectClassName")
handle.s = CkJsonObject::ckStringOf(json,"handle")
ldhName.s = CkJsonObject::ckStringOf(json,"ldhName")
DelegationSigned.i = CkJsonObject::ckBoolOf(json,"secureDNS.delegationSigned")
i.i = 0
count_i.i = CkJsonObject::ckSizeOfArray(json,"links")
While i < count_i
CkJsonObject::setCkI(json, i)
value = CkJsonObject::ckStringOf(json,"links[i].value")
rel = CkJsonObject::ckStringOf(json,"links[i].rel")
href = CkJsonObject::ckStringOf(json,"links[i].href")
v_type = CkJsonObject::ckStringOf(json,"links[i].type")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(json,"status")
While i < count_i
CkJsonObject::setCkI(json, i)
strVal = CkJsonObject::ckStringOf(json,"status[i]")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(json,"entities")
While i < count_i
CkJsonObject::setCkI(json, i)
objectClassName = CkJsonObject::ckStringOf(json,"entities[i].objectClassName")
handle = CkJsonObject::ckStringOf(json,"entities[i].handle")
j = 0
count_j = CkJsonObject::ckSizeOfArray(json,"entities[i].roles")
While j < count_j
CkJsonObject::setCkJ(json, j)
strVal = CkJsonObject::ckStringOf(json,"entities[i].roles[j]")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(json,"entities[i].publicIds")
While j < count_j
CkJsonObject::setCkJ(json, j)
v_type = CkJsonObject::ckStringOf(json,"entities[i].publicIds[j].type")
identifier = CkJsonObject::ckStringOf(json,"entities[i].publicIds[j].identifier")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(json,"entities[i].vcardArray")
While j < count_j
CkJsonObject::setCkJ(json, j)
strVal = CkJsonObject::ckStringOf(json,"entities[i].vcardArray[j]")
k = 0
count_k = CkJsonObject::ckSizeOfArray(json,"entities[i].vcardArray[j]")
While k < count_k
CkJsonObject::setCkK(json, k)
CkJsonObject::ckObjectOf2(json,"entities[i].vcardArray[j][k]",json1)
i1 = 0
count_i1 = CkJsonObject::ckSizeOfArray(json1,"")
While i1 < count_i1
CkJsonObject::setCkI(json1, i1)
strVal = CkJsonObject::ckStringOf(json1,"[i]")
i1 = i1 + 1
Wend
k = k + 1
Wend
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(json,"entities[i].entities")
While j < count_j
CkJsonObject::setCkJ(json, j)
objectClassName = CkJsonObject::ckStringOf(json,"entities[i].entities[j].objectClassName")
k = 0
count_k = CkJsonObject::ckSizeOfArray(json,"entities[i].entities[j].roles")
While k < count_k
CkJsonObject::setCkK(json, k)
strVal = CkJsonObject::ckStringOf(json,"entities[i].entities[j].roles[k]")
k = k + 1
Wend
k = 0
count_k = CkJsonObject::ckSizeOfArray(json,"entities[i].entities[j].vcardArray")
While k < count_k
CkJsonObject::setCkK(json, k)
strVal = CkJsonObject::ckStringOf(json,"entities[i].entities[j].vcardArray[k]")
CkJsonObject::ckObjectOf2(json,"entities[i].entities[j].vcardArray[k]",json1)
i1 = 0
count_i1 = CkJsonObject::ckSizeOfArray(json1,"")
While i1 < count_i1
CkJsonObject::setCkI(json1, i1)
j1 = 0
count_j1 = CkJsonObject::ckSizeOfArray(json1,"[i]")
While j1 < count_j1
CkJsonObject::setCkJ(json1, j1)
strVal = CkJsonObject::ckStringOf(json1,"[i][j]")
j1 = j1 + 1
Wend
i1 = i1 + 1
Wend
k = k + 1
Wend
j = j + 1
Wend
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(json,"events")
While i < count_i
CkJsonObject::setCkI(json, i)
eventAction = CkJsonObject::ckStringOf(json,"events[i].eventAction")
eventDate = CkJsonObject::ckStringOf(json,"events[i].eventDate")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(json,"nameservers")
While i < count_i
CkJsonObject::setCkI(json, i)
objectClassName = CkJsonObject::ckStringOf(json,"nameservers[i].objectClassName")
ldhName = CkJsonObject::ckStringOf(json,"nameservers[i].ldhName")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(json,"rdapConformance")
While i < count_i
CkJsonObject::setCkI(json, i)
strVal = CkJsonObject::ckStringOf(json,"rdapConformance[i]")
i = i + 1
Wend
i = 0
count_i = CkJsonObject::ckSizeOfArray(json,"notices")
While i < count_i
CkJsonObject::setCkI(json, i)
title = CkJsonObject::ckStringOf(json,"notices[i].title")
j = 0
count_j = CkJsonObject::ckSizeOfArray(json,"notices[i].description")
While j < count_j
CkJsonObject::setCkJ(json, j)
strVal = CkJsonObject::ckStringOf(json,"notices[i].description[j]")
j = j + 1
Wend
j = 0
count_j = CkJsonObject::ckSizeOfArray(json,"notices[i].links")
While j < count_j
CkJsonObject::setCkJ(json, j)
href = CkJsonObject::ckStringOf(json,"notices[i].links[j].href")
v_type = CkJsonObject::ckStringOf(json,"notices[i].links[j].type")
j = j + 1
Wend
i = i + 1
Wend
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbResponse)
CkJsonObject::ckDispose(json)
CkJsonObject::ckDispose(json1)
ProcedureReturn
EndProcedure