About the Collections API

Developer Preview
APIs in Developer Preview are subject to change and are not intended for use in production.
Send us your suggestions for improving this API. Your feedback is valuable to us.

 

The Collections API allows you to manage collections in a portfolio. A collection is a way to group similar projects together in your portfolio. Learn more about collections in Wix Portfolio.

With the Collections API, you can:

  • Create, update, and delete collections.
  • Retrieve and query collections.
  • Listen for events when a collection is created, updated, and deleted.

Before you begin

It’s important to note the following points before starting to code:

  • After creating a collection, you can assign a new or existing project to the collection by specifying the collection's ID in the collectionIds parameter of the Create Project or Update Project methods.
  • You can only use this API on sites where a Wix user has installed the Wix Portfolio app.

Use cases

Did this help?

Setup

@wix/portfolio

To use the Collections API, install the @wix/portfolio package using npm or Yarn:

Copy

or

Copy

Then import { collections } from @wix/portfolio:

Copy
Did this help?

Sample Use Cases and Flows

This article presents possible use cases and corresponding sample flows that you can support. This can be a helpful jumping off point as you plan your implementation.

Organize photography projects by theme

You can develop a photo analyzer to categorize related photography projects into collections based on theme.

  1. Call Create Collection to create a collection for projects with a shared theme. Save the returned collection ID for a later step.

  2. Analyze your projects and identify those with a shared theme.

  3. Use the Projects API to add the projects with a shared theme to the collection by assigning the saved collection ID to each project.

  4. Call Get Collection to display the collection.

Keep your data current with collection events

You can use the Collections API to keep up with collection changes by Wix users.

  1. Listen for the Collection Created, Collection Updated, and Collection Deleted events to detect changes made by Wix users.

  2. Based on the event type, adjust your data to reflect the latest collections.

Did this help?

createCollection( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a collection.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Portfolio
Learn more about app permissions.
Method Declaration
Copy
Method Parameters
collectionCollectionRequired

Collection to create.

Returns
Return Type:Promise<Collection>
JavaScript
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?