Skip to main content

Associated Press

The associated-press module lets editors search and import licensed images from the Associated Press Content API through Brightspot's federated search.

Dependencies

Depends on db-http and the AP Content API (media/v/content/search), authenticated with an x-api-key header.

Installation

<!-- Requires Brightspot 5.0 or later. -->
<dependency>
<groupId>com.brightspot.dbhttp</groupId>
<artifactId>associated-press</artifactId>
<version>1.0.0</version>
</dependency>

API reference

com.psddev.ap.AssociatedPressDatabase

Extends HttpDatabase. Every search is restricted to type:(picture), and results are filtered to only images whose AP use code permits licensing under the account's plan. To reduce redundant full-text queries, the database caches AP's continuation token (qt) per editor for two minutes and reuses it when paging through the same search.

com.psddev.ap.AssociatedPressImage

Extends ExternalItem, displayed as AP Image.

FieldTypeDescription
titleStringThe image's title.
apIdStringThe AP Id.
previewUrlStringA preview image URL.
creditLineStringThe AP credit line.
copyrightNoticeStringThe AP copyright notice.
providerStringThe content provider.
captionStringThe image caption.
priceStringThe AP pricing tier for this image.
pricingMessageStringA human-readable pricing message from AP.

Sort order is set through the AssociatedPressImageSort enum: NEWEST (default), OLDEST, or RELEVANCE.

Configuration

The API key is stored on com.psddev.ap.AssociatedPressApiClient (name, apiKey), referenced from AssociatedPressSettings, a Modification<SiteSettings> shown under Site Settings > Integrations > Associated Press. AssociatedPressDatabaseProvider resolves the per-site client and constructs the database. A custom style sheet is only injected into CMS tool pages when a site has AP enabled.

Extending the plugin

The module doesn't ship a content type for imported images. To let editors create one from search results, define a content type and extend ExternalItemConverter<AssociatedPressImage, T> to convert the external item into it on import, downloading the image with AssociatedPressImage#generateStorageItemFromUrl.

Was this page helpful?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.