com.factual.driver
Class Factual

java.lang.Object
  extended by com.factual.driver.Factual

public class Factual
extends Object

Represents the public Factual API. Supports running queries against Factual and inspecting the response. Supports the same levels of authentication supported by Factual's API.

Author:
aaron

Constructor Summary
Factual(String key, String secret)
          Constructor.
 
Method Summary
 List<Crosswalk> crosswalks(String table, CrosswalkQuery query)
          Convenience method to return Crosswalks for the specific query.
 CrosswalkResponse fetch(String tableName, CrosswalkQuery query)
          Query's Factual for the Crosswalk data matching the specified query.
 ReadResponse fetch(String tableName, Query query)
          Runs a read query against the specified Factual table.
 ReadResponse fetch(String tableName, ResolveQuery query)
          Asks Factual to resolve the entity for the attributes specified by query, within the table called tableName.
 Map<String,Object> resolve(ResolveQuery query)
          Asks Factual to resolve the Places entity for the attributes specified by query.
 ReadResponse resolves(ResolveQuery query)
          Asks Factual to resolve the Places entity for the attributes specified by query.
 SchemaResponse schema(String tableName)
           
 void setFactHome(String urlBase)
          Change the base URL at which to contact Factual's API.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Factual

public Factual(String key,
               String secret)
Constructor. Represents your authenticated access to Factual.

Parameters:
key - your oauth key.
secret - your oauth secret.
Method Detail

setFactHome

public void setFactHome(String urlBase)
Change the base URL at which to contact Factual's API. This may be useful if you want to talk to a test or staging server.

Example value: http://staging.api.v3.factual.com/t/

Parameters:
urlBase - the base URL at which to contact Factual's API.

fetch

public ReadResponse fetch(String tableName,
                          Query query)
Runs a read query against the specified Factual table.

Parameters:
tableName - the name of the table you wish to query (e.g., "places")
query - the read query to run against table.
Returns:
the response of running query against Factual.

crosswalks

public List<Crosswalk> crosswalks(String table,
                                  CrosswalkQuery query)
Convenience method to return Crosswalks for the specific query.


fetch

public CrosswalkResponse fetch(String tableName,
                               CrosswalkQuery query)
Query's Factual for the Crosswalk data matching the specified query.

Parameters:
tableName - the name of the table to crosswalk.
query - the Crosswalk query.
Returns:
Factual's response to the Crosswalk query.

resolves

public ReadResponse resolves(ResolveQuery query)
Asks Factual to resolve the Places entity for the attributes specified by query.

Returns the read response from a Factual Resolve request, which includes all records that are potential matches.

Parameters:
query - the Resolve query to run against Factual's Places table.
Returns:
the response from Factual for the Resolve request.

resolve

public Map<String,Object> resolve(ResolveQuery query)
Asks Factual to resolve the Places entity for the attributes specified by query. Returns a record representing the resolved entity if Factual successfully identified the entity with full confidence, or null if the entity was not resolved.

Parameters:
query - a Resolve query with partial attributes for an entity.
Returns:
a record representing the resolved entity if Factual successfully identified the entity with full confidence, or null if the entity was not resolved.

fetch

public ReadResponse fetch(String tableName,
                          ResolveQuery query)
Asks Factual to resolve the entity for the attributes specified by query, within the table called tableName.

Returns the read response from a Factual Resolve request, which includes all records that are potential matches.

Each result record will include a confidence score ("similarity"), and a flag indicating whether Factual decided the entity is the correct resolved match with a high degree of accuracy ("resolved").

There will be 0 or 1 entities returned with "resolved"=true. If there was a full match, it is guaranteed to be the first record in the response.

Parameters:
tableName - the name of the table to resolve within.
query - a Resolve query with partial attributes for an entity.
Returns:
the response from Factual for the Resolve request.

schema

public SchemaResponse schema(String tableName)


Copyright © 2012. All Rights Reserved.