Skip to main content

Integration

The standard data interchange format of JSON makes using and integrating a REST API very easy in most modern programming languages.

Using Java

With Java here's how you could get your Discover API calls done

    URL url = new URL("https://api.smarte.pro/v1/discover");
String req = "{\n" +
" \"company_guid\": \"E8932F31620C0D5D\",\n" +
" \"jobTitle\": [\n" +
" \"VP\",\n" +
" \"sales\"\n" +
" ],\n" +
" \"location\": [\n" +
" \"San Francisco\"\n" +
" ],\n" +
" \"within_miles\":\50,\n" +
" \"accuracy\": \"A+\",\n" +
" \"mode\":\"Stats\"\n" +
"}";
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty("content-type", "application/json");
httpURLConnection.setRequestProperty("API_KEY", "3f5b4b24-16ac-4136-9f74-xxxxxxxxxxxx");
httpURLConnection.setDoOutput(true);
OutputStream os = httpURLConnection.getOutputStream();
os.write(req.getBytes());
os.flush();
os.close();
int responseCode = httpURLConnection.getResponseCode();
System.out.println("POST Response Code :: " + responseCode);

if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();

while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
}

While Java doesn't have JSON support out of the box, there's plenty of libraries out there that can help with this. For example, with Java EE or now Jakarta EE you could just use the JsonObject class to build your request.

  JsonObject json =
Json.createObjectBuilder().add("company_guid", "E8932F31620C0D5D").build();

Similarly, the response could also be read:

    StringReader reader = new StringReader(httpResponse.body());
JsonObject responseJson = null;
try (JsonReader jsonReader = Json.createReader(reader)) {
responseJson = jsonReader.readObject();
System.out.println(responseJson.getString("recordStatus"));
}

Using API Platform

Endpoints :

  https://api.smarte.pro/v1/discover

Method : POST

Headers:

  Content-Type: application/json
API_KEY : 3f5b4b24-16ac-4136-9f74-xxxxxxxxxxxx

Request (Body):

  {
"company_guid": "E8932F31620C0D5D",
"jobTitle": [
"VP",
"sales"
],
"location": ["San Francisco"],
"within_miles": 50,
"accuracy": "A+",
"max_contacts": 100,
"pagination_required": true,
"page_size": 10,
"page_number": 1
}

Basic call using curl command

  curl --request POST \
--url https://api.smarte.pro/v1/discover \
--header 'API_KEY: 3f5b4b24-16ac-4136-9f74-xxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"company_guid": "E8932F31620C0D5D",
"jobTitle": [
"VP",
"sales"
],
"location": ["San Francisco"],
"within_miles": 50,
"accuracy": "A+",
"max_contacts": 100,
"pagination_required": true,
"page_size": 10,
"page_number": 1
}'