Getting Started with the Adobe I/O Events SDK
The Adobe I/O Events SDK is an open-source SDK for interacting with Events. I/O Events provide a powerful way to integrate your applications with Adobe services and solutions. Events are triggered by an Event Provider, like Adobe Creative Cloud Assets, whenever a certain real-world action occurs, such as creating a new asset.
Installation
npm install @adobe/aio-lib-events
Usage
Initialize the SDK
const sdk = require('@adobe/aio-lib-events')
async function sdkTest() {
//initialize sdk
const client = await sdk.init('<organizationId>', '<x-api-key>', '<accessToken>', '<httpOptions>')
}
Call methods using the SDK
Once the SDK has been initialized, you can then call methods provided by the EventsCoreAPI
class to call ADobe I/O Events APIs.
When a method is called, a promise is returned. The promise represents the eventual completion of the command.
In the example below, a catch
method is used to log errors if a command fails.
const sdk = require('@adobe/aio-lib-events')
async function sdkTest() {
// initialize sdk
const client = await sdk.init('<organization id>', 'x-api-key', '<valid auth token>', '<http options>')
// call methods
try {
// get profiles by custom filters
const result = await client.getSomething({})
console.log(result)
} catch (e) {
console.error(e)
}
}
Use the poller for journaling
const sdk = require('@adobe/aio-lib-events')
async function sdkTest() {
// initialize sdk
const client = await sdk.init('<organization id>', 'x-api-key', '<valid auth token>', '<http options>')
// get the journaling observable
const journaling = client.getEventsObservableFromJournal('<journal url>', '<journaling options>')
// call methods
const subscription = journaling.subscribe({
next: (v) => console.log(v), // Action to be taken on event
error: (e) => console.log(e), // Action to be taken on error
complete: () => console.log('Complete') // Action to be taken on complete
})
// To stop receiving events from this subscription based on a timeout
setTimeout(() => this.subscription.unsubscribe(), <timeout in ms>)
}
This returns an RxJS Observable. For more information on how to subscribe to an observable and take action on next, on error, and on complete, please refer to the RxJS documentation.
One observable can have multiple subscribers. Each subscription can be handled differently. For more details on using the poller for journaling, check getEventsObservableFromJournal
in the journaling documentation.
Classes
EventsCoreAPI
The EventsCoreAPI
class provides methods to call your Adobe I/O Events APIs.
Before calling any method initialize the instance by calling the init
method on it with valid values for organizationId
, apiKey
, accessToken
and optional HTTP Options such as timeout
and max number of retries
.
Functions
init(organizationId, apiKey, accessToken, [httpOptions]) ⇒ Promise.<EventsCoreAPI>
A global function that returns a Promise that resolves with a new EventsCoreAPI
object.
organizationId
apiKey
accessToken
adobeio_api
scope, which is required for all the API calls.Configuration Options
EventsCoreAPIOptions
One can configure the following HTTP Options for the SDK. These options will be applied while making the respective API.
EventsJournalOptions
EventsJournalPollingOptions
Next steps
To begin working with EventsCoreAPI
class methods and calling Adobe I/O Events APIs, please select from the following guides: