Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Cerved API Advanced Entity SearchThe "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. For more information, see https://apps-developer.cerved.com/
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() ; This example assumes 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 success.i ; 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" ; } json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; IMPORTANT: Only include the lines for the search criteria you wish to include. CkJsonObject::ckUpdateString(json,"search_text","string") CkJsonObject::ckUpdateString(json,"activity_status_codes[0]","A") CkJsonObject::ckUpdateString(json,"activity_status_codes[1]","C") CkJsonObject::ckUpdateString(json,"activity_status_codes[2]","D") CkJsonObject::ckUpdateString(json,"activity_status_codes[3]","F") CkJsonObject::ckUpdateString(json,"activity_status_codes[4]","I") CkJsonObject::ckUpdateString(json,"activity_status_codes[5]","L") CkJsonObject::ckUpdateString(json,"activity_status_codes[6]","N") CkJsonObject::ckUpdateString(json,"activity_status_codes[7]","P") CkJsonObject::ckUpdateString(json,"activity_status_codes[8]","R") CkJsonObject::ckUpdateString(json,"activity_status_codes[9]","S") CkJsonObject::ckUpdateString(json,"activity_status_codes[10]","T") CkJsonObject::ckUpdateString(json,"birth_date","string") CkJsonObject::ckUpdateString(json,"name","string") CkJsonObject::ckUpdateString(json,"subject_types[0]","PERSON") CkJsonObject::ckUpdateString(json,"subject_types[1]","INDIVIDUAL_COMPANY") CkJsonObject::ckUpdateString(json,"subject_types[2]","COMPANY") CkJsonObject::ckUpdateString(json,"subject_types[3]","FOREIGN") CkJsonObject::ckUpdateString(json,"subject_types[4]","OTHER") CkJsonObject::ckUpdateString(json,"tax_code","string") CkJsonObject::ckUpdateString(json,"vat_number","string") CkJsonObject::ckUpdateString(json,"rea.cciaa","string") CkJsonObject::ckUpdateInt(json,"rea.rea_number",0) CkJsonObject::ckUpdateString(json,"city_istat_code","string") CkJsonObject::ckUpdateString(json,"province_code","string") CkHttp::ckSetRequestHeader(http,"accept","application/json") CkHttp::ckSetRequestHeader(http,"apikey","********************************") resp.i = CkHttp::ckPostJson3(http,"https://api.cerved.com/cervedApi/v1/entitySearch/advanced","application/json",json) If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) ProcedureReturn EndIf sbResponseBody.i = CkStringBuilder::ckCreate() If sbResponseBody.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttpResponse::ckGetBodySb(resp,sbResponseBody) jResp.i = CkJsonObject::ckCreate() If jResp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoadSb(jResp,sbResponseBody) CkJsonObject::setCkEmitCompact(jResp, 0) Debug "Response Body:" Debug CkJsonObject::ckEmit(jResp) respStatusCode.i = CkHttpResponse::ckStatusCode(resp) Debug "Response Status Code = " + Str(respStatusCode) If respStatusCode >= 400 Debug "Response Header:" Debug CkHttpResponse::ckHeader(resp) Debug "Failed." CkHttpResponse::ckDispose(resp) CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndIf CkHttpResponse::ckDispose(resp) ; 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 subject_id.s subject_type.s tax_code.s addressStreetDescription.s addressCityCode.s addressCityIstat_code.s addressCityDescription.s addressProvinceCode.s addressProvinceDescription.s addressPostal_code.s addressCountryCode.s addressCountryDescription.s company_infoLegal_formCode.s company_infoLegal_formDescription.s company_infoLegal_formClass_code.s company_infoActivity_statusCode.s company_infoActivity_statusDescription.s company_infoBusiness_name.s company_infoEconomic_activityAtecoCode.s company_infoEconomic_activityAtecoDescription.s company_infoHead_office.s company_infoLei_code.s company_infoOperational_flag.s company_infoPublic_administrationPa_subject.s company_infoPublic_administrationPa_supplier.s company_infoPublic_administrationPa_owned.s company_infoRea_codeCciaa.s company_infoRea_codeRea_number.i company_infoRea_codeRegistration_date.s company_infoVat_number.s company_infoNo_rea_dataForm_code.s company_infoNo_rea_dataForm_description.s person_infoFirst_name.s person_infoLast_name.s person_infoName.s person_infoBirth_date.s person_infoBirth_placeStreetDescription.s person_infoBirth_placeCityCode.s person_infoBirth_placeCityIstat_code.s person_infoBirth_placeCityDescription.s person_infoBirth_placeProvinceCode.s person_infoBirth_placeProvinceDescription.s person_infoBirth_placePostal_code.s person_infoBirth_placeCountryCode.s person_infoBirth_placeCountryDescription.s subjects_total_number.i = CkJsonObject::ckIntOf(jResp,"subjects_total_number") i.i = 0 count_i.i = CkJsonObject::ckSizeOfArray(jResp,"subjects") While i < count_i CkJsonObject::setCkI(jResp, i) subject_id = CkJsonObject::ckStringOf(jResp,"subjects[i].subject_id") subject_type = CkJsonObject::ckStringOf(jResp,"subjects[i].subject_type") tax_code = CkJsonObject::ckStringOf(jResp,"subjects[i].tax_code") addressStreetDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].address.street.description") addressCityCode = CkJsonObject::ckStringOf(jResp,"subjects[i].address.city.code") addressCityIstat_code = CkJsonObject::ckStringOf(jResp,"subjects[i].address.city.istat_code") addressCityDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].address.city.description") addressProvinceCode = CkJsonObject::ckStringOf(jResp,"subjects[i].address.province.code") addressProvinceDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].address.province.description") addressPostal_code = CkJsonObject::ckStringOf(jResp,"subjects[i].address.postal_code") addressCountryCode = CkJsonObject::ckStringOf(jResp,"subjects[i].address.country.code") addressCountryDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].address.country.description") company_infoLegal_formCode = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.legal_form.code") company_infoLegal_formDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.legal_form.description") company_infoLegal_formClass_code = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.legal_form.class_code") company_infoActivity_statusCode = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.activity_status.code") company_infoActivity_statusDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.activity_status.description") company_infoBusiness_name = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.business_name") company_infoEconomic_activityAtecoCode = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.economic_activity.ateco.code") company_infoEconomic_activityAtecoDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.economic_activity.ateco.description") company_infoHead_office = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.head_office") company_infoLei_code = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.lei_code") company_infoOperational_flag = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.operational_flag") company_infoPublic_administrationPa_subject = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.public_administration.pa_subject") company_infoPublic_administrationPa_supplier = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.public_administration.pa_supplier") company_infoPublic_administrationPa_owned = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.public_administration.pa_owned") company_infoRea_codeCciaa = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.rea_code.cciaa") company_infoRea_codeRea_number = CkJsonObject::ckIntOf(jResp,"subjects[i].company_info.rea_code.rea_number") company_infoRea_codeRegistration_date = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.rea_code.registration_date") company_infoVat_number = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.vat_number") company_infoNo_rea_dataForm_code = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.no_rea_data.form_code") company_infoNo_rea_dataForm_description = CkJsonObject::ckStringOf(jResp,"subjects[i].company_info.no_rea_data.form_description") person_infoFirst_name = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.first_name") person_infoLast_name = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.last_name") person_infoName = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.name") person_infoBirth_date = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.birth_date") person_infoBirth_placeStreetDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.birth_place.street.description") person_infoBirth_placeCityCode = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.birth_place.city.code") person_infoBirth_placeCityIstat_code = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.birth_place.city.istat_code") person_infoBirth_placeCityDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.birth_place.city.description") person_infoBirth_placeProvinceCode = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.birth_place.province.code") person_infoBirth_placeProvinceDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.birth_place.province.description") person_infoBirth_placePostal_code = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.birth_place.postal_code") person_infoBirth_placeCountryCode = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.birth_place.country.code") person_infoBirth_placeCountryDescription = CkJsonObject::ckStringOf(jResp,"subjects[i].person_info.birth_place.country.description") i = i + 1 Wend CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.