Goal
Learn about the Acquia DAM SDK and how to apply it to real-world applications.
How to use
-
Installation
To install the Acquia DAM SDK in a Javascript or Typescript project, use your preferred package manager's syntax.
NPM:
npm install acquia-dam-sdk
Yarn:
yarn add acquia-dam-sdk
-
Import the package into a file
To use the SDK in a file, you must import the package. Both ESModule and CommonJs syntaxes are supported.
// ESModule Syntax import AcquiaDAM from 'acquia-dam-sdk' // CommonJs Syntax const AcquiaDAM = require('acquia-dam-sdk').default
-
Create an instance of the AcquiaDAM class
Create an instance of the AcquiaDAM class using your access token
See our API FAQ Support article for more information on access tokens
const dam = new AcquiaDAM({ accessToken: 'YOUR TOKEN HERE' })
-
Develop!
From here, it's fully up to you! By using the provided documentation on docs.acquia.com, you'll be able to build any sort of tool for your Acquia DAM. The possibilities are endless!
Features
- Fully Typed Interface: The Acquia DAM SDK provides types for all requests and responses, as well as parameter descriptions. Your code editor should automatically pick up on the documentation and generate tooltips and autocomplete suggestions as you code. This includes types for incoming Webhook events.
- Modular: Functions are grouped into logical components, making it easy to use what you need and ignore what you don t.
- Modern Javascript Syntax: Utilize modern Javascript syntax for clean, readable code. E.g.,
// Use Destructuring syntax to obtain references to multiple components const { assets, searchConnector } = new AcquiaDAM({ accessToken: 'YOUR TOKEN HERE' })
- Flexible and Extendable: Use the ApiClient directly to create custom API calls, or extend the ApiClient to implement automatic retries, error handling, or handling of OAuth token exchanges.
Can I use this SDK in a front-end application?
Yes, but
The authentication options supported by the Acquia DAM API (Personal Access Token and OAuth Authorization Code) are intended to be used by servers making requests on behalf of the user, not by the user themselves in a browser environment. For security reasons, we do not recommend using the SDK in the browser as-is.
However, a proxy server can help with using the SDK on the front-end. Instead of having users send requests directly from their browser to the Acquia DAM API, they will send requests to your proxy server. The browser (providing the appropriate browser-based authentication, such as a session cookie or JWT) will send the request to the proxy, and the proxy will apply the correct authentication for DAM and make the request on behalf of the user. To achieve this with the SDK we provide, you will need to extend the ApiClient class with your own implementation of the buildHeaders, buildUrl, and sendRequest functions. Then, you will pass an instance of your client to the AcquiaDAM class.
Example code (some setup required)
// MyProgram.ts import AcquiaDAM from 'acquia-dam-sdk' import { MyProxyClient } from './MyProxyClient' const myClient = new MyProxyClient() const dam = new AcquiaDAM({ client: myClient })
Contributing
As an open-source project we encourage community collaboration for improvements. Visit the project s Github repository for more information.