German Documentation: Hier gelangst du zur deutschen Dokumentation.
The goal of the Plugin SDK is to simplify plugin development by providing a user interface and minimizing direct communication with our server APIs. You don't need to learn our APIs.
The Plugin SDK must be embedded in an iframe. A pixx.io user can log in inside the Plugin SDK and select files. When files are selected in the Plugin SDK, a list of files is sent to your plugin. The list contains a download link and some metadata. Your plugin is then responsible for downloading the files.
Because your plugin handles the file downloads, it must send download progress information back to the Plugin SDK.
The Plugin SDK is available in 2 languages. Use the language requested by your user:
These steps are sufficient for a working integration:
applicationId.onSdkReady.setAllowedFileTypes, setAllowedDownloadFormats, setButtonText, useDirectLinks).downloadFiles or directLinksCreated.setDownloadProgress, setDownloadComplete, or setDownloadFailed).<iframe
id="pixxio-plugin-sdk"
src="https://plugin.pixx.io/static/v2/en/media?applicationId=YOUR_APPLICATION_ID"
style="width: 100%; height: 100%; border: 0"
></iframe>
const iframe = document.getElementById('pixxio-plugin-sdk');
const sdkOrigin = 'https://plugin.pixx.io';
function sendToSdk(method, parameters = []) {
iframe.contentWindow.postMessage(
{
receiver: 'pixxio-plugin-sdk',
method,
parameters
},
sdkOrigin
);
}
window.addEventListener('message', async (event) => {
if (event.origin !== sdkOrigin) {
return;
}
const data = event.data;
if (!data || data.sender !== 'pixxio-plugin-sdk') {
return;
}
switch (data.method) {
case 'onSdkReady':
sendToSdk('setButtonText', ['Apply selection']);
sendToSdk('setAllowedDownloadFormats', [['original', 'jpg', 'png']]);
break;
case 'downloadFiles': {
const [files] = data.parameters ?? [[]];
await downloadFiles(files);
break;
}
case 'directLinksCreated': {
const [files] = data.parameters ?? [[]];
await processDirectLinks(files);
break;
}
case 'onError': {
const [error] = data.parameters ?? [];
console.error('Plugin SDK Error', error);
break;
}
default:
break;
}
});
async function downloadFiles(files) {
try {
for (let i = 0; i < files.length; i++) {
const file = files[i];
await fetch(file.downloadURL);
const progress = Math.round(((i + 1) / files.length) * 100);
sendToSdk('setDownloadProgress', [progress]);
}
sendToSdk('setDownloadComplete');
} catch {
sendToSdk('setDownloadFailed');
}
}
async function processDirectLinks(files) {
console.log('Received direct links', files);
}
onSdkReadydownloadFiles or directLinksCreatedWe use PostMessage for communication.
The Plugin SDK sends and receives various messages as JavaScript objects. The structure is always the same:
interface PluginSdkEvent {
sender: 'pixxio-plugin-sdk';
method: string;
parameters?: unknown[];
}
interface PluginSdkEvent {
receiver: 'pixxio-plugin-sdk';
method: string;
parameters?: unknown[];
}
window.addEventListener('message', (event) => {
if (event.origin !== 'https://plugin.pixx.io') {
return;
}
const data = event.data;
if (data.sender === 'pixxio-plugin-sdk') {
switch (data.method) {
case 'downloadFiles':
// Do stuff
break;
...
}
}
});
iframe.contentWindow.postMessage(
{
receiver: 'pixxio-plugin-sdk',
method: 'login'
},
'https://plugin.pixx.io'
);
downloadFilesThe user selected files that your plugin now needs to download.
| Name | Type | Comment |
|---|---|---|
| files | array | The files to download |
The type of files looks like this:
interface File {
id: number;
downloadURL: string;
fileName: string;
fileSize: number;
originalWidth: number;
originalHeight: number;
previewFileWidth: number;
previewFileHeight: number;
downloadFormat: string; // original | preview | the file extension
subject: string | undefined;
description: string | undefined;
metadata?: { [key: string]: any };
licenseReleases: {
expires: string;
licenseRelease: {
license: {
provider: string;
};
name: string;
};
}[];
}
{
"sender": "pixxio-plugin-sdk",
"method": "downloadFiles",
"parameters": [
{
"id": 1,
"downloadURL": "https://demo.px.media/.../demo.jpg",
"fileName": "demo.jpg",
"fileSize": 223651
},
{
"id": 2,
"downloadURL": "https://demo.px.media/.../demo.jpg",
"fileName": "demo.jpg",
"fileSize": 515546
}
]
}
directLinksCreatedThe user selected files and direct links are provided instead of download URLs.
| Name | Type | Comment |
|---|---|---|
| files | array | The files with direct links |
The type of files looks like this:
interface File {
id: number;
directLink: string;
fileName: string;
fileSize: number;
originalWidth: number;
originalHeight: number;
previewFileWidth: number;
previewFileHeight: number;
directLinkFormat: string; // original | preview | the file extension
subject: string | undefined;
description: string | undefined;
metadata?: { [key: string]: any };
licenseReleases: {
expires: string;
licenseRelease: {
license: {
provider: string;
};
name: string;
};
}[];
}
{
"sender": "pixxio-plugin-sdk",
"method": "directLinksCreated",
"parameters": [
{
"id": 1,
"directLink": "https://demo.px.media/.../demo.jpg",
"fileName": "demo.jpg",
"fileSize": 223651
},
{
"id": 2,
"directLink": "https://demo.px.media/.../demo.jpg",
"fileName": "demo.jpg",
"fileSize": 515546
}
]
}
onSdkReadyThe Plugin SDK is only ready to receive PostMessage events after this event.
Note: Incoming login messages before onSdkReady are ignored.
None
{
"sender": "pixxio-plugin-sdk",
"method": "onSdkReady",
"parameters": []
}
loginSuccessThe user successfully logged in. Handle this event only if your plugin needs to persist credentials for background sync.
| Name | Type | Comment |
|---|---|---|
| mediaspaceDomain | string | The domain of the pixx.io mediaspace |
| refreshToken | string | The refresh-token provided by pixx.io |
{
"sender": "pixxio-plugin-sdk",
"method": "loginSuccess",
"parameters": [
{
"mediaspaceDomain": "demo.px.media",
"refreshToken": "1213456789abc"
}
]
}
logoutSuccessThe user logged out. If your plugin stores user credentials, remove them.
None
{
"sender": "pixxio-plugin-sdk",
"method": "logoutSuccess"
}
onErrorAn SDK error occurred. Your plugin can display an error state or notification.
| Name | Type | Comment |
|---|---|---|
| error | object | The error object |
{
"sender": "pixxio-plugin-sdk",
"method": "onError",
"parameters": [
{
"errorCode": 1234,
"errorMessage": "This is an error"
}
]
}
selectionChangeThe user selected or deselected one or more files. This message is sent whenever the selection changes.
| Name | Type | Comment |
|---|---|---|
| selectedItems | array | The currently selected items |
The type of selectedItems looks like this:
interface SelectedItem {
id: number;
fileName: string;
previewUrl: string;
}
{
"sender": "pixxio-plugin-sdk",
"method": "selectionChange",
"parameters": [
[
{
"id": 1,
"fileName": "demo.jpg",
"previewUrl": "https://demo.px.media/.../preview1.jpg"
},
{
"id": 2,
"fileName": "image.png",
"previewUrl": "https://demo.px.media/.../preview2.jpg"
}
]
]
}
You can also send messages to the Plugin SDK. Messages must have the following structure:
{
receiver: 'pixxio-plugin-sdk';
method: string;
parameters?: unknown[];
}
Example:
iframe.contentWindow.postMessage(
{
receiver: 'pixxio-plugin-sdk',
method: 'login',
parameters: [
{
refreshToken: '123456789abc',
mediaspaceDomain: 'demo.px.media'
}
]
},
'https://plugin.pixx.io'
);
The Plugin SDK currently supports the following events:
setDownloadProgressNotify the Plugin SDK about the current download progress. For large files, we recommend sending an update every 5 seconds.
| Name | Type | Comment |
|---|---|---|
| progress | number | Progress in percent e.g. 50% => 50 |
{
"receiver": "pixxio-plugin-sdk",
"method": "setDownloadProgress",
"parameters": [25]
}
setDownloadCompleteNotify the Plugin SDK that the file downloads are complete.
None
{
"receiver": "pixxio-plugin-sdk",
"method": "setDownloadComplete"
}
setDownloadFailedNotify the Plugin SDK that the file downloads failed.
None
{
"receiver": "pixxio-plugin-sdk",
"method": "setDownloadFailed"
}
loginLog in to the Plugin SDK. This function is only needed if login is separate from file selection.
| Name | Type | Comment |
|---|---|---|
| refreshToken | string | The refresh-token provided by pixx.io |
| mediaspaceDomain | string | The domain of the pixx.io mediaspace |
{
"receiver": "pixxio-plugin-sdk",
"method": "login",
"parameters": [
{
"refreshToken": "123456789abc",
"mediaspaceDomain": "demo.px.media"
}
]
}
logoutLog out the user from the Plugin SDK.
None
{
"receiver": "pixxio-plugin-sdk",
"method": "logout",
"parameters": []
}
setAllowedFileTypesSet a filter on all media views by file extensions. Users cannot remove this filter.
| Name | Type | Comment |
|---|---|---|
| fileExtensions | string[] | A list of file extensions e.g. ['jpg', 'png'] |
{
"receiver": "pixxio-plugin-sdk",
"method": "setAllowedFileTypes",
"parameters": [["jpg", "png"]]
}
setAllowedDownloadFormats
Restrict available download options.
Supported values are original, preview, jpg, png, pdf, tiff, webp.
| Name | Type | Comment |
|---|---|---|
| formats | string[] | A list of file extensions e.g. ['jpg', 'png'] |
{
"receiver": "pixxio-plugin-sdk",
"method": "setAllowedDownloadFormats",
"parameters": [["jpg", "png"]]
}
showErrorDisplay an error as a notification.
| Name | Type | Comment |
|---|---|---|
| error | string | The error message for the user |
{
"receiver": "pixxio-plugin-sdk",
"method": "showError",
"parameters": ["This is an error"]
}
setButtonTextSet the text of the primary button in the footer of the Plugin SDK.
| Name | Type | Comment |
|---|---|---|
| text | string | The text shown on the button |
{
"receiver": "pixxio-plugin-sdk",
"method": "setButtonText",
"parameters": ["Apply selection"]
}
useDirectLinksEnable or disable direct links mode at runtime.
| Name | Type | Comment |
|---|---|---|
| useDirectLinks | boolean | true: direct links, false: regular download |
{
"receiver": "pixxio-plugin-sdk",
"method": "useDirectLinks",
"parameters": [true]
}
resetNavigationReset navigation in the Plugin SDK to the start view.
None
{
"receiver": "pixxio-plugin-sdk",
"method": "resetNavigation"
}
To initially configure the Plugin SDK, you can use a number of query parameters:
standaloneLoginIf login should be performed separately. If this parameter is active, the login page does not automatically navigate to the next page. Instead, it sends the login success via PostMessage.
https://plugin.pixx.io/static/v2/en/login?standaloneLogin=true
darkSwitches the Plugin SDK to dark mode.
https://plugin.pixx.io/static/v2/en/login?dark=true
allowedFileTypesFilters media views by file extensions.
https://plugin.pixx.io/static/v2/en/media?allowedFileTypes=jpg&allowedFileTypes=png&allowedFileTypes=tiff
allowedDownloadFormats
Filters the selection of possible formats for downloading files. Only the formats provided are available for selection. If no value is specified, all formats are available.
Supported values are original, preview, jpg, png, pdf, tiff, and webp.
https://plugin.pixx.io/static/v2/en/media?allowedDownloadFormats=jpg&allowedDownloadFormats=png&allowedDownloadFormats=tiff
applicationId
The applicationId is mandatory and must always be provided.
If you don't have an applicationId yet, you can request one from our support: support@pixx.io
https://plugin.pixx.io/static/v2/en/media?applicationId=sadfjhoahsdfosahf
multiSelectWhether multi-select is possible in the media view or not.
https://plugin.pixx.io/static/v2/en/media?multiSelect=true
hideLinksHides various links within the SDK. Supported values are mediaspace and help.
https://plugin.pixx.io/static/v2/en/media?hideLinks=mediaspace&hideLinks=help
selectButtonTextChanges the text of the selection button.
https://plugin.pixx.io/static/v2/en/media?selectButtonText=Submit
metadataControls which metadata is sent with the download. The values used can be any names of metadata configured in the mediaspace.
Note: Only values from the important metadata (importantMetadata) of the file are transferred.
https://plugin.pixx.io/static/v2/en/media?metadata=Alt-Text&metadata=Custom_Field
useDirectLinksThe directLinksCreated event is triggered instead of the downloadFiles event. As a result, direct links (see directLinksCreated) are then available.
https://plugin.pixx.io/static/v2/en/media?metadata=Alt-Text&useDirectLinks=true
hideSelectionFooterHides the selection footer in the Plugin SDK, which normally shows the number of selected files.
https://plugin.pixx.io/static/v2/en/media?hideSelectionFooter=true
hideAvatarHides the avatar section in the header of the Plugin SDK.
https://plugin.pixx.io/static/v2/en/media?hideAvatar=true
backgroundColorOverrides the SDK background color. Suitable for visual adaptation to the host plugin.
https://plugin.pixx.io/static/v2/en/media?backgroundColor=%23f4f6f8
onSdkReady never arrivesPossible causes:
https://plugin.pixx.io/static/v2/....Fix:
window.addEventListener('message', ...) during app startup.Possible causes:
event.origin check.data.sender === 'pixxio-plugin-sdk' validation.Fix:
https://plugin.pixx.io.event.origin, then data.sender, then data.method.Possible causes:
applicationId in URL.applicationId.Fix:
applicationId as query parameter.applicationId.downloadFilesPossible causes:
Fix:
setDownloadProgress regularly while downloading.setDownloadComplete or setDownloadFailed.Possible causes:
Fix:
allowedFileTypes, allowedDownloadFormats, hideLinks....&allowedFileTypes=jpg&allowedFileTypes=png.The parameter structure was changed from positional arguments to a single configuration object.
[refreshToken, userIdentifier, mediaspace][{ refreshToken: string, mediaspaceDomain: string }]userIdentifier was removed.mediaspace was renamed to mediaspaceDomain.