client

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

com.clearbit
ArtifactId

ArtifactId

client
Last Version

Last Version

0.9
Release Date

Release Date

Type

Type

jar
Description

Description

client
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Source Code Management

Source Code Management

https://github.com/clearbit/clearbit-java

Download client

How to add to project

<!-- https://jarcasting.com/artifacts/com.clearbit/client/ -->
<dependency>
    <groupId>com.clearbit</groupId>
    <artifactId>client</artifactId>
    <version>0.9</version>
</dependency>
// https://jarcasting.com/artifacts/com.clearbit/client/
implementation 'com.clearbit:client:0.9'
// https://jarcasting.com/artifacts/com.clearbit/client/
implementation ("com.clearbit:client:0.9")
'com.clearbit:client:jar:0.9'
<dependency org="com.clearbit" name="client" rev="0.9">
  <artifact name="client" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.clearbit', module='client', version='0.9')
)
libraryDependencies += "com.clearbit" % "client" % "0.9"
[com.clearbit/client "0.9"]

Dependencies

compile (8)

Group / Artifact Type Version
org.projectlombok : lombok Optional jar 1.16.6
com.sun.jersey : jersey-client jar 1.19
com.sun.jersey.contribs : jersey-multipart jar 1.19
com.fasterxml.jackson.core : jackson-core jar 2.5.4
com.fasterxml.jackson.core : jackson-annotations jar 2.5.4
com.fasterxml.jackson.core : jackson-databind jar 2.5.4
com.fasterxml.jackson.datatype : jackson-datatype-joda jar 2.1.5
joda-time : joda-time jar 2.3

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Clearbit

A Java API client to https://clearbit.com.

Installation

The client library can be imported from Maven Central, or users can download source and build locally.

Usage

Authorize requests by setting the API key found on your account's settings page.

import com.clearbit.ApiException;
import com.clearbit.client.api.CombinedApi;
import com.clearbit.client.model.PersonCompany;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public 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("[email protected]");

			// 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:

final String clearbit_key = System.getenv("CLEARBIT_KEY");
WebhookResponseParser parser = new WebhookResponseParser(clearbit_key);
WebhookResponse response = parser.parse(responseBody, xRequestSignatureHeader);

switch (response.getType()) {
  case PERSON:
    Person person = (Person) response.getBody();
    break;
  case COMPANY:
    Company company = (Company) response.getBody();
    break;
  case PERSON_COMPANY:
    PersonCompany personCompany = (PersonCompany) response.getBody();
    break;
  default:
    throw new IllegalStateException("Unexpected type: " + response.getType());
}

Supported APIs

Currently streaming for the following APIs is supported:

Please see the Clearbit docs for more information https://clearbit.com/docs

Implementation Notes

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

mvn release:prepare
mvn release:perform
com.clearbit

Clearbit

Business Intelligence APIs

Versions

Version
0.9
0.8
0.7
0.6
0.5