React Native
React Native
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 React Native Downloads
import { Http, HttpResponse, JsonObject, StringBuilder } from '@chilkat/react-native'
async function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = new Http();
// 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"
// }
const json = new JsonObject();
// IMPORTANT: Only include the lines for the search criteria you wish to include.
json.updateString('search_text', 'string');
json.updateString('activity_status_codes[0]', 'A');
json.updateString('activity_status_codes[1]', 'C');
json.updateString('activity_status_codes[2]', 'D');
json.updateString('activity_status_codes[3]', 'F');
json.updateString('activity_status_codes[4]', 'I');
json.updateString('activity_status_codes[5]', 'L');
json.updateString('activity_status_codes[6]', 'N');
json.updateString('activity_status_codes[7]', 'P');
json.updateString('activity_status_codes[8]', 'R');
json.updateString('activity_status_codes[9]', 'S');
json.updateString('activity_status_codes[10]', 'T');
json.updateString('birth_date', 'string');
json.updateString('name', 'string');
json.updateString('subject_types[0]', 'PERSON');
json.updateString('subject_types[1]', 'INDIVIDUAL_COMPANY');
json.updateString('subject_types[2]', 'COMPANY');
json.updateString('subject_types[3]', 'FOREIGN');
json.updateString('subject_types[4]', 'OTHER');
json.updateString('tax_code', 'string');
json.updateString('vat_number', 'string');
json.updateString('rea.cciaa', 'string');
json.updateInt('rea.rea_number', 0);
json.updateString('city_istat_code', 'string');
json.updateString('province_code', 'string');
http.setRequestHeader('accept', 'application/json');
http.setRequestHeader('apikey', '********************************');
const resp = new HttpResponse();
try {
await http.httpJsonAsync('POST', 'https://api.cerved.com/cervedApi/v1/entitySearch/advanced', json, 'application/json', resp);
} catch {
console.log(http.lastErrorText);
return;
}
const sbResponseBody = new StringBuilder();
resp.getBodySb(sbResponseBody);
const jResp = new JsonObject();
jResp.loadSb(sbResponseBody);
jResp.emitCompact = false;
console.log('Response Body:');
console.log(jResp.emit());
const respStatusCode = resp.statusCode;
console.log(`Response Status Code = ${respStatusCode}`);
if (respStatusCode >= 400) {
console.log('Response Header:');
console.log(resp.header);
console.log('Failed.');
return;
}
// 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
let subjectId = '';
let subjectType = '';
let taxCode = '';
let addressStreetDescription = '';
let addressCityCode = '';
let addressCityIstatCode = '';
let addressCityDescription = '';
let addressProvinceCode = '';
let addressProvinceDescription = '';
let addressPostalCode = '';
let addressCountryCode = '';
let addressCountryDescription = '';
let companyInfoLegalFormCode = '';
let companyInfoLegalFormDescription = '';
let companyInfoLegalFormClassCode = '';
let companyInfoActivityStatusCode = '';
let companyInfoActivityStatusDescription = '';
let companyInfoBusinessName = '';
let companyInfoEconomicActivityAtecoCode = '';
let companyInfoEconomicActivityAtecoDescription = '';
let companyInfoHeadOffice = '';
let companyInfoLeiCode = '';
let companyInfoOperationalFlag = '';
let companyInfoPublicAdministrationPaSubject = '';
let companyInfoPublicAdministrationPaSupplier = '';
let companyInfoPublicAdministrationPaOwned = '';
let companyInfoReaCodeCciaa = '';
let companyInfoReaCodeReaNumber = 0;
let companyInfoReaCodeRegistrationDate = '';
let companyInfoVatNumber = '';
let companyInfoNoReaDataFormCode = '';
let companyInfoNoReaDataFormDescription = '';
let personInfoFirstName = '';
let personInfoLastName = '';
let personInfoName = '';
let personInfoBirthDate = '';
let personInfoBirthPlaceStreetDescription = '';
let personInfoBirthPlaceCityCode = '';
let personInfoBirthPlaceCityIstatCode = '';
let personInfoBirthPlaceCityDescription = '';
let personInfoBirthPlaceProvinceCode = '';
let personInfoBirthPlaceProvinceDescription = '';
let personInfoBirthPlacePostalCode = '';
let personInfoBirthPlaceCountryCode = '';
let personInfoBirthPlaceCountryDescription = '';
const subjectsTotalNumber = jResp.intOf('subjects_total_number');
let i = 0;
const countI = jResp.sizeOfArray('subjects');
while (i < countI) {
jResp.i = i;
subjectId = jResp.stringOf('subjects[i].subject_id');
subjectType = jResp.stringOf('subjects[i].subject_type');
taxCode = jResp.stringOf('subjects[i].tax_code');
addressStreetDescription = jResp.stringOf('subjects[i].address.street.description');
addressCityCode = jResp.stringOf('subjects[i].address.city.code');
addressCityIstatCode = jResp.stringOf('subjects[i].address.city.istat_code');
addressCityDescription = jResp.stringOf('subjects[i].address.city.description');
addressProvinceCode = jResp.stringOf('subjects[i].address.province.code');
addressProvinceDescription = jResp.stringOf('subjects[i].address.province.description');
addressPostalCode = jResp.stringOf('subjects[i].address.postal_code');
addressCountryCode = jResp.stringOf('subjects[i].address.country.code');
addressCountryDescription = jResp.stringOf('subjects[i].address.country.description');
companyInfoLegalFormCode = jResp.stringOf('subjects[i].company_info.legal_form.code');
companyInfoLegalFormDescription = jResp.stringOf('subjects[i].company_info.legal_form.description');
companyInfoLegalFormClassCode = jResp.stringOf('subjects[i].company_info.legal_form.class_code');
companyInfoActivityStatusCode = jResp.stringOf('subjects[i].company_info.activity_status.code');
companyInfoActivityStatusDescription = jResp.stringOf('subjects[i].company_info.activity_status.description');
companyInfoBusinessName = jResp.stringOf('subjects[i].company_info.business_name');
companyInfoEconomicActivityAtecoCode = jResp.stringOf('subjects[i].company_info.economic_activity.ateco.code');
companyInfoEconomicActivityAtecoDescription = jResp.stringOf('subjects[i].company_info.economic_activity.ateco.description');
companyInfoHeadOffice = jResp.stringOf('subjects[i].company_info.head_office');
companyInfoLeiCode = jResp.stringOf('subjects[i].company_info.lei_code');
companyInfoOperationalFlag = jResp.stringOf('subjects[i].company_info.operational_flag');
companyInfoPublicAdministrationPaSubject = jResp.stringOf('subjects[i].company_info.public_administration.pa_subject');
companyInfoPublicAdministrationPaSupplier = jResp.stringOf('subjects[i].company_info.public_administration.pa_supplier');
companyInfoPublicAdministrationPaOwned = jResp.stringOf('subjects[i].company_info.public_administration.pa_owned');
companyInfoReaCodeCciaa = jResp.stringOf('subjects[i].company_info.rea_code.cciaa');
companyInfoReaCodeReaNumber = jResp.intOf('subjects[i].company_info.rea_code.rea_number');
companyInfoReaCodeRegistrationDate = jResp.stringOf('subjects[i].company_info.rea_code.registration_date');
companyInfoVatNumber = jResp.stringOf('subjects[i].company_info.vat_number');
companyInfoNoReaDataFormCode = jResp.stringOf('subjects[i].company_info.no_rea_data.form_code');
companyInfoNoReaDataFormDescription = jResp.stringOf('subjects[i].company_info.no_rea_data.form_description');
personInfoFirstName = jResp.stringOf('subjects[i].person_info.first_name');
personInfoLastName = jResp.stringOf('subjects[i].person_info.last_name');
personInfoName = jResp.stringOf('subjects[i].person_info.name');
personInfoBirthDate = jResp.stringOf('subjects[i].person_info.birth_date');
personInfoBirthPlaceStreetDescription = jResp.stringOf('subjects[i].person_info.birth_place.street.description');
personInfoBirthPlaceCityCode = jResp.stringOf('subjects[i].person_info.birth_place.city.code');
personInfoBirthPlaceCityIstatCode = jResp.stringOf('subjects[i].person_info.birth_place.city.istat_code');
personInfoBirthPlaceCityDescription = jResp.stringOf('subjects[i].person_info.birth_place.city.description');
personInfoBirthPlaceProvinceCode = jResp.stringOf('subjects[i].person_info.birth_place.province.code');
personInfoBirthPlaceProvinceDescription = jResp.stringOf('subjects[i].person_info.birth_place.province.description');
personInfoBirthPlacePostalCode = jResp.stringOf('subjects[i].person_info.birth_place.postal_code');
personInfoBirthPlaceCountryCode = jResp.stringOf('subjects[i].person_info.birth_place.country.code');
personInfoBirthPlaceCountryDescription = jResp.stringOf('subjects[i].person_info.birth_place.country.description');
i++;
}
}