All Projects → fullcontact → fullcontact4j

fullcontact / fullcontact4j

Licence: other
⛔ [DEPRECATED] A Java client for the FullContact API

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to fullcontact4j

XpringKit
XpringKit provides a Swift SDK for interacting with Xpring Protocols (XRP/PayID/ILP). This library is deprecated.
Stars: ✭ 23 (-17.86%)
Mutual labels:  deprecated, archived
cartesian ros control
DEPRECATED: A set of packages to bring Cartesian control functionality to the ROS-control framework.
Stars: ✭ 33 (+17.86%)
Mutual labels:  deprecated, archived
contentstats
DEPRECATED – See how many entries have been created for channels and structures in your Craft CMS website.
Stars: ✭ 29 (+3.57%)
Mutual labels:  deprecated, archived
react-virtual-keyboard
Use jQuery Virtual Keyboard in react.js
Stars: ✭ 44 (+57.14%)
Mutual labels:  deprecated, archived
QR
DEPRECATED The bookmarklet and extensions generate QRCode of the current URL for viewing on mobile devices (Google Chrome/Mozilla Firefox/Opera/Safari)
Stars: ✭ 20 (-28.57%)
Mutual labels:  deprecated, archived
microsoft-teams-faqplusplus-app
DEPRECATED - This repository contains a deprecated version of the FAQ Plus app template. Please see the README file for more details and a link to the new repository
Stars: ✭ 47 (+67.86%)
Mutual labels:  deprecated, archived
passion
An object-oriented LÖVE game engine
Stars: ✭ 35 (+25%)
Mutual labels:  deprecated, archived
Sphero Ios Sdk
🚫 DEPRECATED: Sphero™ is the amazing robotic ball ( sphero.com ) created by Orbotix, this is the repository for the iOS SDK for Sphero™. Visit dev site for more information:
Stars: ✭ 232 (+728.57%)
Mutual labels:  deprecated, archived
DeepDIVA
⛔️ DEPRECATED <Python Framework for Reproducible Deep Learning Experiments>
Stars: ✭ 32 (+14.29%)
Mutual labels:  deprecated, archived
summit2016-RankingPredict
Deprecated, No more maintained - Deprecated, no longer maintained
Stars: ✭ 34 (+21.43%)
Mutual labels:  deprecated, archived
code-gov-style
Deprecated - Style for code.gov including buttons, banners, and cards
Stars: ✭ 12 (-57.14%)
Mutual labels:  deprecated, archived
ionic-3D-card-carousel
DEPRECATED Sample project that shows an experimental 3D card carousel in Ionic.
Stars: ✭ 29 (+3.57%)
Mutual labels:  deprecated, archived
picosdk-python-examples
DEPRECATED - An example Python application and examples for PicoScope® oscilloscope products.
Stars: ✭ 21 (-25%)
Mutual labels:  deprecated, archived
Azure-AppServices-Diagnostics
Azure App Service Diagnostics provides developers ability to write various diagnostics features which helps customers to diagnose and troubleshoot their applications hosted on app services.
Stars: ✭ 42 (+50%)
Mutual labels:  deprecated, archived
Angular2 Adminlte
DEPRECATED An Angular 4 version of the AdminLTE theme
Stars: ✭ 239 (+753.57%)
Mutual labels:  deprecated, archived
Sphero-Win-SDK
🚫 DEPRECATED: Sphero SDK for Win 8.1+ using RFCOMM
Stars: ✭ 36 (+28.57%)
Mutual labels:  deprecated, archived
Sketch Toolbox
DEPRECATED: A plugin manager for Sketch.app
Stars: ✭ 2,159 (+7610.71%)
Mutual labels:  deprecated, archived
Terraintoolsamples
Unity has archived the TerrainToolSamples repository. For future development, please use the Terrain Tools package.
Stars: ✭ 195 (+596.43%)
Mutual labels:  deprecated, archived
jest-badges-readme
Creates a group of coverage badges from Jest into your README
Stars: ✭ 30 (+7.14%)
Mutual labels:  deprecated, archived
tooltip
[DEPRECATED] The tooltip that has all the right moves
Stars: ✭ 133 (+375%)
Mutual labels:  deprecated, archived

FullContact4j [Deprecated]

This is no longer supported. Please use our updated java client. Also checkout our client libraries here.

A Java client for the FullContact API. Supports Java 7+.

For FullContact4j 2.0 and later, we've designed the client from the bottom up with tons of cool new stuff.

See the changelog here.

Coming from version 1? Read this wiki page for a rundown of the big changes, then continue here.

Add to your project

FullContact uses Bintray as a repository.

Maven

<repositories>
  <repository>
    <id>fullcontact</id>
    <url>http://dl.bintray.com/content/fullcontact/fullcontact-oss</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>com.fullcontact</groupId>
    <artifactId>fullcontact4j</artifactId>
    <version>(version here)</version>
  </dependency>
</dependencies>

Gradle

repositories {
    maven {
        url "http://dl.bintray.com/content/fullcontact/fullcontact-oss"
    }
}

dependencies {
    compile group: "com.fullcontact", name: "fullcontact4j", version: "(version here)"
}

Dependencies

OkHttp, which FullContact uses as an HTTP client.

Retrofit, for interacting with the FullContact API.

Jackson, a JSON library, for conversion of API responses.

Working with FullContact4j

FullContact4j 2.0 is designed from the ground up to be as painless to use as possible. FullContact clients are customizable and require just one line of code to set up; requests take only one line to create and one to execute. FullContact4j abstracts away all the headaches associated with HTTP communication with the API, ranging from managing possible response scenarios to keeping your requests below your account's rate limit (queries per second). Make a request object, execute it, and get a response object back.

Quick Overview

Firstly, read the API documentation! FullContact4j provides an object layer to FullContact API communication, but understanding webhooks, response flows, request parameters, and common snags is still important.

Once you’re on board with the API behavior, using FullContact4j is easy. Look up social and demographic data for an email address in just 3 lines of code:

FullContact fullContact = FullContact.withApiKey("your-api-key").build();
PersonRequest personRequest = fullContact.buildPersonRequest().email("[email protected]").build();
PersonResponse personResponse = fullContact.sendRequest(personRequest);

(Don't have an API key? You can pick one up for free right here.)

withApiKey returns a FullContact client builder. You can specify timeouts, your own OkHttpClient, a user agent, and much more.

Behind the scenes, FullContact4j has done a lot for you:

  • authenticated with FullContact
  • accounted for rate limiting (for person API requests), sending the request if you are below your rate limit (or waiting to send your request until the time is right if you have exceeded your account limit).
  • checked for errors and parsed useful messages/data
  • turned the response JSON into a perfectly normal Java object.

If you prefer asynchronous calls, that requires only one change:

fullContact.sendRequest(personRequest, new FCCallback() {
  public void success(PersonResponse response) {
    System.out.println("got a response back!");
  }

  public void failure(FullContactException exception) {
    System.out.println("got an error :( ");
  }
});

You can see a simple demo of this client in action in the Hello World app example!

Making Requests

First, let’s get our request builder.

fullContact.buildPersonRequest()

All API requests can be made by calling their corresponding build____Request() method. Then, add relevant parameters and build:

fullContact.buildPersonRequest().email(“bart@fullcontact.com”).build();

It’s generally good practice to specify webhooks in your request, in case of a 202 response from Person API or a Card Reader upload for instance. That’s all configurable as well:

fullContact.buildPersonRequest()
  .webhookUrl(“http://www.example-site.com/api/finishedlookup”)
  .webhookBody(true)
  .email(“bart@fullcontact.com”)
  .build();

If the webhook URL is specified, all Person API responses will by default return a 202 response code (see webhooks documentation for more detail). If you need to test webhooks before implementing them in your own technology, you can always use something like requestb.in.

If you clearly mis-configured your request (adding two search parameters to Person API, or not giving a name to the name deducer API, etc), build() will throw an IllegalArgumentException with a message about what you did wrong:

java.lang.IllegalArgumentException: Request must specify exactly one: email or username
  at com.fullcontact.api.libs.fullcontact4j.http.name.NameDeduceRequest$Builder.validate(NameDeduceRequest.java:51)
  …

Now let’s send our request. Since FullContact4j uses a thread pool to execute requests, multiple consumers should be fine to make thread-safe requests from the same client instance. This can be done synchronously or asynchronously.

Synchronously is a little easier:

PersonRequest request = fullContact.buildPersonRequest().email(“bart@fullcontact.com”).build();
PersonResponse response = fullContact.sendRequest(request);

Every request has a corresponding response that it will return when sendRequest is called. This object contains all response data back from FullContact.

Asynchronous requests are similar. sendRequest() just takes one more parameter -- a FCCallback. It has a generic type parameter of the response type (PersonRequest corresponds to PersonResponse, LocationNormalizationRequest to LocationNormalizationResponse, etc). success() is called when a useful response is returned from the APIs:

fullContact.sendRequest(locationEnrichmentRequest, new FCCallback() {
  public void success(LocationEnrichmentResponse response) {
    System.out.println("got a response back!");
  }

  public void failure(FullContactException exception) {
    System.out.println("got an error :( ");
  }
});

You can turn webhook responses into these response objects using fromJson:

public void onCardReaderWebhook(String body) {
  CardReaderFullResponse response = CardReaderFullResponse.fromJson(body);
  System.out.println("Just got a card reader transcribed for " + response.getContact().getName().toString());
}

public void onPersonWebhook(String body) {
  PersonResponse response = WebhookResponse.fromJson(body, PersonResponse.class);
  System.out.println("Just got social profile info for " + response.getContactInfo().getName().toString());
}

As long as a response returns 200 or 202, FullContact4j will turn it into a java object representation holding all the information the regular JSON response would. If it's not in the JSON, it'll be an empty field.

PersonResponse response = client.sendRequest(personRequest);
if(response.getStatus() == 200) { //202 (searching) is possible here, we'll get an empty response!
  for(SocialProfile profile : response.getSocialProfiles()) {
    System.out.println("Check out my " + profile.getTypeId() + " profile: " + profile.getUrl());
  }
}

LocationEnrichmentResponse location = client.sendRequest(locationRequest);
System.out.println("I found a new place in " + location.getContinent() + " with a population of " + location.getPopulation());

When you're done with the client, be sure to call shutDown() on it to clean up any unused state in the client.

Error Handling

If an error is encountered (these correspond to yellow/red non-2xx response codes on the API flow diagrams), a FullContactException is created with useful information about the error, including errorCode and a message from the FullContact APIs about the nature of the error. For synchronous requests, this will cause sendRequest() to throw FullContactException. In asynchronous requests, FCCallback.failure(FullContactException exception) is called instead.

Supported APIs

FullContact4j supports all Person, Company, Email, Name, Location, Card Reader, and Account Statistics endpoints. These can all be accessed from their respective build_____Request() methods in the FullContact client. Some will need required parameters (like CardReaderRequest’s requirement for a front image InputStream) and automatically create a builder with those required parameters set.

Advanced

In the background, FullContact4j is making requests using an OkHttpClient. You can supply your own OkHttpClient.

OkHttpClient client = new OkHttpClient();
client.setReadTimeout(3000, TimeUnit.MILLISECONDS);
FullContact fcClient = FullContact.withApiKey("your-api-key").httpClient(client).build();

The user agent and request executor thread count are also configurable. For person API requests, the client will rate limit the amount of requests sent based on the rate limit for your plan. It will hold a request queue and execute at the maximum every 1/ratelimit seconds with some leeway if you haven’t sent requests in a certain period of time. FullContact4j guarantees no Person API rate limiting exceptions only as long a single client instance is the only user of an API key. However, if multiple instances of the client are being used simultaneously, FullContact4J cannot track your usage with high enough accuracy to guarantee that you will never get a rate limit exception (403). These may still occaisionally occur, and should be accounted for in your code. This rate limiter does NOT account for overages or quota limits. Make sure to check your account stats periodically to avoid overages.

I'm on Java 6!

The last Java 6-compatible FullContact4j release was version 3.3.3.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].