DataFlex
DataFlex
Cerved API Advanced Entity Search
See more Cerved Examples
The "Advanced Entity Search" API allows you to find subjects in the Cerved database that meet specific search criteria, specified through the parameters provided as input to the service.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
Variant vJson
Handle hoJson
Variant vResp
Handle hoResp
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sSubject_id
String sSubject_type
String sTax_code
String sAddressStreetDescription
String sAddressCityCode
String sAddressCityIstat_code
String sAddressCityDescription
String sAddressProvinceCode
String sAddressProvinceDescription
String sAddressPostal_code
String sAddressCountryCode
String sAddressCountryDescription
String sCompany_infoLegal_formCode
String sCompany_infoLegal_formDescription
String sCompany_infoLegal_formClass_code
String sCompany_infoActivity_statusCode
String sCompany_infoActivity_statusDescription
String sCompany_infoBusiness_name
String sCompany_infoEconomic_activityAtecoCode
String sCompany_infoEconomic_activityAtecoDescription
String sCompany_infoHead_office
String sCompany_infoLei_code
String sCompany_infoOperational_flag
String sCompany_infoPublic_administrationPa_subject
String sCompany_infoPublic_administrationPa_supplier
String sCompany_infoPublic_administrationPa_owned
String sCompany_infoRea_codeCciaa
Integer iCompany_infoRea_codeRea_number
String sCompany_infoRea_codeRegistration_date
String sCompany_infoVat_number
String sCompany_infoNo_rea_dataForm_code
String sCompany_infoNo_rea_dataForm_description
String sPerson_infoFirst_name
String sPerson_infoLast_name
String sPerson_infoName
String sPerson_infoBirth_date
String sPerson_infoBirth_placeStreetDescription
String sPerson_infoBirth_placeCityCode
String sPerson_infoBirth_placeCityIstat_code
String sPerson_infoBirth_placeCityDescription
String sPerson_infoBirth_placeProvinceCode
String sPerson_infoBirth_placeProvinceDescription
String sPerson_infoBirth_placePostal_code
String sPerson_infoBirth_placeCountryCode
String sPerson_infoBirth_placeCountryDescription
Integer iSubjects_total_number
Integer i
Integer iCount_i
String sTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// Implements the following CURL command:
// curl -X POST \
// https://api.cerved.com/cervedApi/v1/entitySearch/advanced \
// -H 'accept: application/json' \
// -H 'apikey: ********************************' \
// -d '{
// "search_text": "string",
// "activity_status_codes": [
// "A",
// "C",
// "D",
// "F",
// "I",
// "L",
// "N",
// "P",
// "R",
// "S",
// "T"
// ],
// "birth_date": "string",
// "name": "string",
// "subject_types": [
// "PERSON",
// "INDIVIDUAL_COMPANY",
// "COMPANY",
// "FOREIGN",
// "OTHER"
// ],
// "tax_code": "string",
// "vat_number": "string",
// "rea": {
// "cciaa": "string",
// "rea_number": 0
// },
// "city_istat_code": "string",
// "province_code": "string"
// }'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "search_text": "string",
// "activity_status_codes": [
// "A",
// "C",
// "D",
// "F",
// "I",
// "L",
// "N",
// "P",
// "R",
// "S",
// "T"
// ],
// "birth_date": "string",
// "name": "string",
// "subject_types": [
// "PERSON",
// "INDIVIDUAL_COMPANY",
// "COMPANY",
// "FOREIGN",
// "OTHER"
// ],
// "tax_code": "string",
// "vat_number": "string",
// "rea": {
// "cciaa": "string",
// "rea_number": 0
// },
// "city_istat_code": "string",
// "province_code": "string"
// }
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
// IMPORTANT: Only include the lines for the search criteria you wish to include.
Get ComUpdateString Of hoJson "search_text" "string" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[0]" "A" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[1]" "C" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[2]" "D" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[3]" "F" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[4]" "I" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[5]" "L" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[6]" "N" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[7]" "P" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[8]" "R" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[9]" "S" To iSuccess
Get ComUpdateString Of hoJson "activity_status_codes[10]" "T" To iSuccess
Get ComUpdateString Of hoJson "birth_date" "string" To iSuccess
Get ComUpdateString Of hoJson "name" "string" To iSuccess
Get ComUpdateString Of hoJson "subject_types[0]" "PERSON" To iSuccess
Get ComUpdateString Of hoJson "subject_types[1]" "INDIVIDUAL_COMPANY" To iSuccess
Get ComUpdateString Of hoJson "subject_types[2]" "COMPANY" To iSuccess
Get ComUpdateString Of hoJson "subject_types[3]" "FOREIGN" To iSuccess
Get ComUpdateString Of hoJson "subject_types[4]" "OTHER" To iSuccess
Get ComUpdateString Of hoJson "tax_code" "string" To iSuccess
Get ComUpdateString Of hoJson "vat_number" "string" To iSuccess
Get ComUpdateString Of hoJson "rea.cciaa" "string" To iSuccess
Get ComUpdateInt Of hoJson "rea.rea_number" 0 To iSuccess
Get ComUpdateString Of hoJson "city_istat_code" "string" To iSuccess
Get ComUpdateString Of hoJson "province_code" "string" To iSuccess
Send ComSetRequestHeader To hoHttp "accept" "application/json"
Send ComSetRequestHeader To hoHttp "apikey" "********************************"
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
Send CreateComObject of hoResp
End
Get pvComObject of hoJson to vJson
Get pvComObject of hoResp to vResp
Get ComHttpJson Of hoHttp "POST" "https://api.cerved.com/cervedApi/v1/entitySearch/advanced" vJson "application/json" vResp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComStatusCode Of hoResp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComHeader Of hoResp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "subjects": [
// {
// "subject_id": "string",
// "subject_type": "string",
// "tax_code": "string",
// "address": {
// "street": {
// "description": "string"
// },
// "city": {
// "code": "string",
// "istat_code": "string",
// "description": "string"
// },
// "province": {
// "code": "string",
// "description": "string"
// },
// "postal_code": "string",
// "country": {
// "code": "string",
// "description": "string"
// }
// },
// "company_info": {
// "legal_form": {
// "code": "string",
// "description": "string",
// "class_code": "string"
// },
// "activity_status": {
// "code": "string",
// "description": "string"
// },
// "business_name": "string",
// "economic_activity": {
// "ateco": {
// "code": "string",
// "description": "string"
// }
// },
// "head_office": "true",
// "lei_code": "string",
// "operational_flag": "true",
// "public_administration": {
// "pa_subject": "true",
// "pa_supplier": "true",
// "pa_owned": "true"
// },
// "rea_code": {
// "cciaa": "string",
// "rea_number": 0,
// "registration_date": "string"
// },
// "vat_number": "string",
// "no_rea_data": {
// "form_code": "string",
// "form_description": "string"
// }
// },
// "person_info": {
// "first_name": "string",
// "last_name": "string",
// "name": "string",
// "birth_date": "string",
// "birth_place": {
// "street": {
// "description": "string"
// },
// "city": {
// "code": "string",
// "istat_code": "string",
// "description": "string"
// },
// "province": {
// "code": "string",
// "description": "string"
// },
// "postal_code": "string",
// "country": {
// "code": "string",
// "description": "string"
// }
// }
// }
// }
// ],
// "subjects_total_number": 0
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
Get ComIntOf Of hoJResp "subjects_total_number" To iSubjects_total_number
Move 0 To i
Get ComSizeOfArray Of hoJResp "subjects" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "subjects[i].subject_id" To sSubject_id
Get ComStringOf Of hoJResp "subjects[i].subject_type" To sSubject_type
Get ComStringOf Of hoJResp "subjects[i].tax_code" To sTax_code
Get ComStringOf Of hoJResp "subjects[i].address.street.description" To sAddressStreetDescription
Get ComStringOf Of hoJResp "subjects[i].address.city.code" To sAddressCityCode
Get ComStringOf Of hoJResp "subjects[i].address.city.istat_code" To sAddressCityIstat_code
Get ComStringOf Of hoJResp "subjects[i].address.city.description" To sAddressCityDescription
Get ComStringOf Of hoJResp "subjects[i].address.province.code" To sAddressProvinceCode
Get ComStringOf Of hoJResp "subjects[i].address.province.description" To sAddressProvinceDescription
Get ComStringOf Of hoJResp "subjects[i].address.postal_code" To sAddressPostal_code
Get ComStringOf Of hoJResp "subjects[i].address.country.code" To sAddressCountryCode
Get ComStringOf Of hoJResp "subjects[i].address.country.description" To sAddressCountryDescription
Get ComStringOf Of hoJResp "subjects[i].company_info.legal_form.code" To sCompany_infoLegal_formCode
Get ComStringOf Of hoJResp "subjects[i].company_info.legal_form.description" To sCompany_infoLegal_formDescription
Get ComStringOf Of hoJResp "subjects[i].company_info.legal_form.class_code" To sCompany_infoLegal_formClass_code
Get ComStringOf Of hoJResp "subjects[i].company_info.activity_status.code" To sCompany_infoActivity_statusCode
Get ComStringOf Of hoJResp "subjects[i].company_info.activity_status.description" To sCompany_infoActivity_statusDescription
Get ComStringOf Of hoJResp "subjects[i].company_info.business_name" To sCompany_infoBusiness_name
Get ComStringOf Of hoJResp "subjects[i].company_info.economic_activity.ateco.code" To sCompany_infoEconomic_activityAtecoCode
Get ComStringOf Of hoJResp "subjects[i].company_info.economic_activity.ateco.description" To sCompany_infoEconomic_activityAtecoDescription
Get ComStringOf Of hoJResp "subjects[i].company_info.head_office" To sCompany_infoHead_office
Get ComStringOf Of hoJResp "subjects[i].company_info.lei_code" To sCompany_infoLei_code
Get ComStringOf Of hoJResp "subjects[i].company_info.operational_flag" To sCompany_infoOperational_flag
Get ComStringOf Of hoJResp "subjects[i].company_info.public_administration.pa_subject" To sCompany_infoPublic_administrationPa_subject
Get ComStringOf Of hoJResp "subjects[i].company_info.public_administration.pa_supplier" To sCompany_infoPublic_administrationPa_supplier
Get ComStringOf Of hoJResp "subjects[i].company_info.public_administration.pa_owned" To sCompany_infoPublic_administrationPa_owned
Get ComStringOf Of hoJResp "subjects[i].company_info.rea_code.cciaa" To sCompany_infoRea_codeCciaa
Get ComIntOf Of hoJResp "subjects[i].company_info.rea_code.rea_number" To iCompany_infoRea_codeRea_number
Get ComStringOf Of hoJResp "subjects[i].company_info.rea_code.registration_date" To sCompany_infoRea_codeRegistration_date
Get ComStringOf Of hoJResp "subjects[i].company_info.vat_number" To sCompany_infoVat_number
Get ComStringOf Of hoJResp "subjects[i].company_info.no_rea_data.form_code" To sCompany_infoNo_rea_dataForm_code
Get ComStringOf Of hoJResp "subjects[i].company_info.no_rea_data.form_description" To sCompany_infoNo_rea_dataForm_description
Get ComStringOf Of hoJResp "subjects[i].person_info.first_name" To sPerson_infoFirst_name
Get ComStringOf Of hoJResp "subjects[i].person_info.last_name" To sPerson_infoLast_name
Get ComStringOf Of hoJResp "subjects[i].person_info.name" To sPerson_infoName
Get ComStringOf Of hoJResp "subjects[i].person_info.birth_date" To sPerson_infoBirth_date
Get ComStringOf Of hoJResp "subjects[i].person_info.birth_place.street.description" To sPerson_infoBirth_placeStreetDescription
Get ComStringOf Of hoJResp "subjects[i].person_info.birth_place.city.code" To sPerson_infoBirth_placeCityCode
Get ComStringOf Of hoJResp "subjects[i].person_info.birth_place.city.istat_code" To sPerson_infoBirth_placeCityIstat_code
Get ComStringOf Of hoJResp "subjects[i].person_info.birth_place.city.description" To sPerson_infoBirth_placeCityDescription
Get ComStringOf Of hoJResp "subjects[i].person_info.birth_place.province.code" To sPerson_infoBirth_placeProvinceCode
Get ComStringOf Of hoJResp "subjects[i].person_info.birth_place.province.description" To sPerson_infoBirth_placeProvinceDescription
Get ComStringOf Of hoJResp "subjects[i].person_info.birth_place.postal_code" To sPerson_infoBirth_placePostal_code
Get ComStringOf Of hoJResp "subjects[i].person_info.birth_place.country.code" To sPerson_infoBirth_placeCountryCode
Get ComStringOf Of hoJResp "subjects[i].person_info.birth_place.country.description" To sPerson_infoBirth_placeCountryDescription
Move (i + 1) To i
Loop
End_Procedure