getObjectRecordsInAccountInCommunity
/api/v2/communities/{communityId}/accounts/{accountId}/objectrecords
All authorized users can retrieve public object records in an account for a community in eHive. A request to the /api/v2/communities/{communityId}/accounts/{accountId}/objectrecords
resource will return an Object Records Collection
JSON object.
Try the getObjectRecordsInAccountInCommunity Method
You can enter real values into the form below and test them against our live API. The response you see is a genuine JSON response from the API.
Name | Data Type | Parameter Type | Value | Required | Description |
---|---|---|---|---|---|
communityId | Integer | Path | 32-bit signed two's complement | YES | The id for the community you wish to filter by. |
accountId | Integer | Path | 32-bit signed two's complement | YES | The id for the account you wish to filter by. |
query | String | Query | Max. 100 characters | NO | The query parameter will contain the search term you wish to use to refine your search results. |
hasImages | Boolean | Query | true/false | NO | A query parameters that allows you to retrieve only Object Records that contain images. |
sort | String | Query | name, primary_creator_maker, date_made, place_made, account_name, named_collection, object_number, object_type, cat_type, classification, condition_keyword, controlling_institution, department, location, edition, latest_valuation, legal_status, other_number, record_status, portfolio_title, series_title, taxonomic_classification | NO | This query parameter allows you to sort your search results by a certain field on the Object Record. |
direction | String | Query | asc/desc | NO | This query parameter allows you to dictated the order of the sort either ascending or descending. |
offset | Integer | Query | 32-bit signed two's complement | NO | The offset query parameters allows you to paginate your search results. |
limit | Integer | Query | 32-bit signed two's complement | NO | The limit query parameters allows you to limit the number of search results per request. |
Code Examples
Included below are some code snippets from our code samples projects. The examples show the main elements needed to use our API client libraries.
Java
Prerequisites
- Download the Java API client library.
- Create a new Java class file.
- Add the Java API client library JAR to your classpath.
- Create a blank file that is accessible from wherever you are running this example. The file is used to store your API authentication token, so it must be readable and writable. You can name the file anything you like as long as it is valid in Java.
Start Coding
- Instantiate an EHiveApi object. The EHiveApi object contains all of the methods available in the API.
The API requires authentication credentials
so you will need to configure your EHiveApi object with valid credentials. There are a number of ways to instantiate the EHiveApi object but for
this example you will simply pass all of the parameters you need into the EHiveApi object's constructor:
private static String clientId = "...462"; private static String clientSecret = "...98a9"; private static String trackingId = "...eaca"; private static String pathToOauthPropertiesFile = "oauth.properties"; ... EHiveApi eHiveApi = new EHiveApi(clientId, clientSecret, trackingId, pathToOauthPropertiesFile);
- Invoke the getObjectRecordsInAccountInCommunity() method and assign the return value to an ObjectRecordsCollection domain
object as follows:
ObjectRecordsCollection objectRecordsCollection = eHiveApi.getObjectRecordsInAccountInCommunity(1001, 3406, "red", false, "name", "asc", 0, 12);
- Access the ObjectRecord information using the ObjectRecord domain object's getter method.
Long recordId = objectRecord.getObjectRecordId(); System.out.println(recordId);
View the full example below.
import com.ehive.api.EHiveApi; import com.ehive.api.domain.objects.Attribute; import com.ehive.api.domain.objects.Attribute.AttributeIdentifier; import com.ehive.api.domain.objects.Field; import com.ehive.api.domain.objects.FieldRow; import com.ehive.api.domain.objects.FieldSet; import com.ehive.api.domain.objects.Media; import com.ehive.api.domain.objects.MediaRow; import com.ehive.api.domain.objects.MediaSet; import com.ehive.api.domain.objects.ObjectRecord; import com.ehive.api.domain.objects.ObjectRecordsCollection; import com.ehive.api.exceptions.EHiveApiException; import com.ehive.api.exceptions.EHiveFatalServerException; import com.ehive.api.exceptions.EHiveForbiddenException; import com.ehive.api.exceptions.EHiveNotFoundException; import com.ehive.api.exceptions.EHiveUnauthorizedException; public class GetObjectRecordsInAccountInCommunity { private static String clientId = "...462"; private static String clientSecret = "...98a9"; private static String trackingId = "...eaca"; private static String pathToOauthPropertiesFile = "oauth.properties"; private static Integer accountId = 3406; private static Integer communityId = 1001; private static String query = "red"; private static Boolean hasImages = false; private static String sort = "name"; private static String direction = "asc"; private static Integer offset = 0; private static Integer limit = 12; public static void main(String[] args) throws EHiveApiException, EHiveFatalServerException, EHiveNotFoundException, EHiveUnauthorizedException, EHiveForbiddenException { // Instantiate the EHiveApi object EHiveApi eHiveApi = new EHiveApi(clientId, clientSecret, trackingId, pathToOauthPropertiesFile); // Invoke an API method ObjectRecordsCollection objectRecordsCollection = eHiveApi.getObjectRecordsInAccountInCommunity(communityId, accountId, query, hasImages, sort, direction, offset, limit); // Print some output using the returned object records collection printObjectRecordInfo(objectRecordsCollection); } private static void printObjectRecordInfo(ObjectRecordsCollection objectRecordsCollection) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("Search results found: " + objectRecordsCollection.getTotalObjects() + "\n\n"); stringBuilder.append("----------------------------------------------------------------------------\n\n"); for (ObjectRecord objectRecord : objectRecordsCollection.getObjectRecords()) { stringBuilder.append("Record ID: " + objectRecord.getObjectRecordId().toString() + "\n\n"); for (FieldSet fieldSet : objectRecord.getFieldSets()) { stringBuilder.append("FIELD SET: " + fieldSet.getIdentifier() + "\n"); for (FieldRow fieldRow : fieldSet.getFieldRows()) { for (Field field : fieldRow.getFields()) { for (Attribute attribute : field.getAttributes()) { if (AttributeIdentifier.getIdentifier(attribute.getKey()) == AttributeIdentifier.LABEL) { stringBuilder.append(attribute.getValue() + ":"); } else if (AttributeIdentifier.getIdentifier(attribute.getKey()) == AttributeIdentifier.VALUE) { stringBuilder.append("\t " + attribute.getValue() + "\n\n"); } } } } stringBuilder.append("\n\n"); } for (MediaSet mediaSet : objectRecord.getMediaSets()) { stringBuilder.append(mediaSet.getIdentifier().toUpperCase() + " URL: \n"); for (MediaRow mediaRow : mediaSet.getMediaRows()) { for (Media media : mediaRow.getMedia()) { for (Attribute attribute : media.getAttributes()) { if (AttributeIdentifier.getIdentifier(attribute.getKey()) == AttributeIdentifier.URL) { stringBuilder.append(attribute.getValue() + "\n"); } } } } } stringBuilder.append("----------------------------------------------------------------------------\n\n"); } System.out.println(stringBuilder.toString()); } }
PHP
Prerequisites
- Download the PHP API client library.
- Create a new php script file.
- Add EHiveApi.php from the PHP API client library to your include path.
- Locate the oauth.tok file in the transport/oauth directory of the PHP API client library and ensure that it has both read and write permission enabled.
Start Coding
- Instantiate an EHiveApi object. The EHiveApi class contains all of the functions available to you in the API.
- Configure your EHiveApi object with valid authentication credentials. There are a number of ways to instantiate the EHiveApi object but for this example you will simply pass all of the parameter you need into the EHiveApi object's constructor:
private static $clientId = "...5935"; private static $clientSecret = "...4c4b"; private static $trackingId = "...7861"; ... $eHiveApi = new EHiveApi(GetObjectRecordsInAccountInCommunityDemo::$clientId, GetObjectRecordsInAccountInCommunityDemo::$clientSecret, GetObjectRecordsInAccountInCommunityDemo::$trackingId);
- Invoke the getObjectRecordsInAccountInCommunity() method and assign the return value to a variable as follows:
$objectRecordsCollection = $eHiveApi->getObjectRecordsInAccountInCommunity(1001, 3406, "red", false, "name", "asc", 0, 12);
- Access the information on the ObjectRecord object.
echo $objectRecord->objectRecordId;
View the full example below.
require_once '../../lib/ehive_api_client-php-1.0.0/EHiveApi.php'; class GetObjectRecordsInAccountInCommunityDemo { private static $clientId = "...5935"; private static $clientSecret = "...4c4b"; private static $trackingId = "...7861"; private static $accountId = 3406; private static $communityId = 1001; private static $query = "red"; private static $hasImages = false; private static $sort = "name"; private static $direction = "asc"; private static $offset = 0; private static $limit = 12; public function printObjectRecordsInAccountInCommunityInfo() { // Instantiate the EHiveApi object $eHiveApi = new EHiveApi(GetObjectRecordsInAccountInCommunityDemo::$clientId, GetObjectRecordsInAccountInCommunityDemo::$clientSecret, GetObjectRecordsInAccountInCommunityDemo::$trackingId); // Invoke an API method $objectRecordsCollection = $eHiveApi->getObjectRecordsInAccountInCommunity(GetObjectRecordsInAccountInCommunityDemo::$communityId, GetObjectRecordsInAccountInCommunityDemo::$accountId, GetObjectRecordsInAccountInCommunityDemo::$query, GetObjectRecordsInAccountInCommunityDemo::$hasImages, GetObjectRecordsInAccountInCommunityDemo::$sort, GetObjectRecordsInAccountInCommunityDemo::$direction, GetObjectRecordsInAccountInCommunityDemo::$offset, GetObjectRecordsInAccountInCommunityDemo::$limit); // Print some output using the returned records collection object echo "\n\nSearch results found: {$objectRecordsCollection->totalObjects} \n\n"; echo "----------------------------------------------------------------------------\n\n"; foreach ($objectRecordsCollection->objectRecords as $key => $objectRecord) { echo "Record ID: {$objectRecord->objectRecordId}\n"; foreach ($objectRecord->fieldSets as $key => $fieldSet) { echo "FIELD SET: {$fieldSet->identifier}\n"; foreach ($fieldSet->fieldRows as $key => $fieldRow) { foreach ($fieldRow->fields as $key => $field) { foreach ($field->attributes as $key => $attribute) { if ($attribute->key == 'label') { echo "{$attribute->value}:"; } else if ($attribute->key == 'value') { echo "\t {$attribute->value}\n\n"; } } } } echo "\n\n"; } foreach ($objectRecord->mediaSets as $key => $mediaSet) { echo strtoupper($mediaSet->identifier) . " URL: \n"; foreach ($mediaSet->mediaRows as $key => $mediaRow) { foreach ($mediaRow->media as $key => $media) { foreach ($media->attributes as $key => $attribute) { if ($attribute->key == 'url') { echo "\t {$attribute->value}\n"; } } } } } echo "----------------------------------------------------------------------------\n\n"; } } } $getObjectRecordsInAccountInCommunityDemo = new GetObjectRecordsInAccountInCommunityDemo(); $getObjectRecordsInAccountInCommunityDemo->printObjectRecordsInAccountInCommunityInfo();