A Java SDK for interacting with the Balihoo Local Information Platform (BLIP).
- This SDK targets Java 7.
- Using this SDK requires that you already have API keys and are interacting on behalf of a brand that already exists in Balihoo's system. Please contact Balihoo if you require API keys and/or would like to add a new brand to our system.
The SDK is available to install from the Maven central repository.
// Construct a Blip object
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
// Make a method call and return the response
BlipResponse brandResponse = blip.getBrandKeys();
// Status Code (e.g. 200, 204, 404, etc.)
int responseCode = brandResponse.STATUS_CODE;
// Response Content
String myBrands = brandResponse.BODY;
The Blip constructor has an optional "endpoint" parameter to specify the environment URL. The endpoint defaults to Balihoo's production environment but you can optionally pass the dev or stage URL.
// dev: https://blip.dev.balihoo-cloud.com
// stage: https://blip.stage.balihoo-cloud.com
// production: https://blip.balihoo-cloud.com
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>", "https://blip.dev.balihoo-cloud.com");
All methods return a BlipResponse object with two properties:
- STATUS_CODE
- The HTTP response code (e.g. 200, 204, 404) as an integer.
- BODY
- The HTTP response content as a string.
- For calls that return brand or location data this property will contain stringified JSON objects.
Ping the BLIP API.
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
BlipResponse blipResponse = blip.ping();
if (blipResponse.STATUS_CODE == 200)
{
// Success!
}
Get a list of brandKeys that the API user is authorized to access.
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
BlipResponse blipResponse = blip.getBrandKeys();
String myBrandKeys = blipResponse.BODY;
Get a list of data sources available for an individual brand.
- brandKey: The unique identifier for a single brand.
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
BlipResponse blipResponse = blip.getBrandSources("mybrand");
String sources = blipResponse.BODY;
Get a list of data projections available for an individual brand.
- brandKey: The unique identifier for a single brand.
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
BlipResponse blipResponse = blip.getBrandProjections("mybrand");
String projections = blipResponse.BODY;
Get a list of locationKeys for all locations belonging to the specified brand.
- brandKey: The unique identifier for a single brand.
- projection: Optionally filter data in a single projection. Defaults to "universal".
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
BlipResponse blipResponse = blip.getLocationKeys("mybrand");
String locationKeys = blipResponse.BODY;
Get data for an individual location within the specified brand.
- brandKey: The unique identifier for a single brand.
- locationKey: The unique identifier for a single location within the brand.
- projection: Optionally filter data in a single projection. Defaults to "universal".
- includeRefs: Optionally include objects referenced by the location in its data. Defaults to false.
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
BlipResponse blipResponse = blip.getLocation("mybrand", "mylocation");
String locationData = blipResponse.BODY;
Get data for locations in a single brand filtered by the specified BLIP query.
- brandKey: The unique identifier for a single brand.
- query: A stringified JSON query used to filter locations.
- view: Optionally specify the view returned. Defaults to "full".
- pageSize: Optionally specify the number of results to include in each page of results.
- pageNumber: Optionally specify the page index to return.
- sortColumn: Optionally sort results by "name" or "locationKey". Defaults to "locationKey".
- sortDirection: Optionally specify sorting "asc" or "desc". Defaults to "asc".
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
String query = "{\"address.state\":{\"equals\":\"ID\"}}";
BlipResponse blipResponse = blip.queryLocations("mybrand", query);
String matchingLocations = blipResponse.BODY;
Add a new location or update an existing location's data.
- brandKey: The unique identifier for a single brand.
- locationKey: The unique identifier for a single location within the brand.
- source: The name of the data source being used to add/update the location
- locationData: The stringified JSON location document.
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
String locationDocument = "{\"name\":\"Balihoo, Inc.\",\"address\":{\"city\":\"Boise\",\"state\":\"ID\"}}";
BlipResponse blipResponse = blip.putLocation("mybrand", "mylocation", "mysource", locationDocument);
if (blipResponse.STATUS_CODE == 204)
{
// location was successfully added/updated
}
Delete an individual location.
- brandKey: The unique identifier for a single brand.
- locationKey: The unique identifier for a single location within the brand.
- source: The name of the data source being used to delete the location
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
BlipResponse blipResponse = blip.deleteLocation("mybrand", "mylocation", "mysource");
if (blipResponse.STATUS_CODE == 204)
{
// location was successfully deleted
}
Load a single file containing multiple locations.
- brandKey: The unique identifier for a single brand.
- source: The unique identifier for the data source being used to add/update the location.
- filePath: The full path to the bulk location file. See note below on the bulk load file format.
- implicitDelete: Whether or not to delete locations from BLIP if they're missing from the file.
- expectedRecordCount: The number of location records to expect in the file.
- successEmail: An optional email address to notify upon success. Can be a comma-delimited list.
- failEmail: An optional email address to notify upon failure. Can be a comma-delimited list.
- successCallbackUrl: An optional URL to call upon success.
- failCallbackUrl: An optional URL to call upon failure.
Blip blip = new Blip("<Your API Key>", "<Your Secret Key>");
BlipResponse blipResponse = blip.bulkLoad("mybrand", "mysource", "/tmp/myfile.json", true, 50,
"[email protected]", "[email protected],[email protected]",
"http://mycompany.com/api?success=true", "http://mycompany.com/api?error=true");
if (blipResponse.STATUS_CODE == 204)
{
// File load has been successfully initiated.
// Optional success and failure notifications will be made once the load process completes.
}
The file for the bulkLoad process should contain each location's data on a single line and each line delimited by a line-feed character (\n). If a location is omitted from the file and implicitDelete is set to true, the location will be deleted.
{"brandKey":"mybrand","locationKey":"ABC123","document":{...}}\n
{"brandKey":"mybrand","locationKey":"ABC124","document":{...}}\n
{"brandKey":"mybrand","locationKey":"ABC125","document":{...}}\n