Name: clearbit-java
Owner: HubSpot
Description: A Java API client to https://clearbit.com
Forked from: clearbit/clearbit-java
Created: 2017-01-23 23:25:13.0
Updated: 2018-03-19 19:05:07.0
Pushed: 2018-03-19 19:05:06.0
Size: 51
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A Java API client to https://clearbit.com.
The client library can be imported from Maven Central, or users can download source and build locally.
Authorize requests by setting the API key found on your account's settings page.
rt com.clearbit.ApiException;
rt com.clearbit.client.api.CombinedApi;
rt com.clearbit.client.model.PersonCompany;
rt com.fasterxml.jackson.core.JsonProcessingException;
rt com.fasterxml.jackson.databind.ObjectMapper;
ic class ClearbitExample {
public static void main(String[] args) {
final String clearbit_key = System.getenv("CLEARBIT_KEY");
CombinedApi api = new CombinedApi();
api.getApiClient().setUsername(clearbit_key);
try {
ObjectMapper mapper = new ObjectMapper();
PersonCompany personCompany = api.streamingLookup("harlow@clearbit.com");
// access attrs form response
System.out.println(personCompany.getPerson().getEmail());
// print full JSON payload
String jsonBody = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(personCompany);
System.out.println(jsonBody);
} catch (JsonProcessingException e) {
e.printStackTrace();
} catch (ApiException e) {
e.printStackTrace();
}
}
This API is blocking by default - it holds a streaming connection open (this can take 3~5 seconds if we haven't seen the email before). We recommend using the webhook API for higher throughput.
To parse the response received from a webhook call, use the WebhookResponseParser:
l String clearbit_key = System.getenv("CLEARBIT_KEY");
ookResponseParser parser = new WebhookResponseParser(clearbit_key);
ookResponse response = parser.parse(responseBody, xRequestSignatureHeader);
ch (response.getType()) {
se PERSON:
Person person = (Person) response.getBody();
break;
se COMPANY:
Company company = (Company) response.getBody();
break;
se PERSON_COMPANY:
PersonCompany personCompany = (PersonCompany) response.getBody();
break;
fault:
throw new IllegalStateException("Unexpected type: " + response.getType());
Currently streaming for the following APIs is supported:
Lombok is used in the model classes to efficiently represent the models without boilerplate for getters, setters, toStrings, etc. The code is delomboked during compilation so that the final output does not include any dependency on Lombok.
Download and install the Lombok plugin: https://projectlombok.org/setup/eclipse
release:prepare
release:perform