Skip to main content

Collections

What is an Arttribute Collection?

A collection is a group of artifacts that share a common theme or purpose. Collections can be created by users to organize their artifacts and make them easier to manage. Users can create, update, and delete collections using the Arttribute API. To ensure authenticity and fairness, collections are tagged with Arttribute Licenses.

Key features of a collection include:

FeatureDescription
idUnique identifier of a collection.
creatorIdID of the user who created this collection.
nameName of the collection.
licenseLicense associated with the collection.
whitelistList of addresses that can access the collection.
blacklistList of addresses that cannot access the collection.
createdAtWhen the collection was created (ISO 8601 timestamp).
updatedAtWhen the collection was last updated (ISO 8601 timestamp).

Creating a Collection

Step 1: Prepare the Collection Data

info

The user must provide authorization tokens to create a collection. This process ensures that the user is authenticated and authorized to create collections.

Before creating an collection, gather all necessary information. The data object is described below:

FeatureDescription
nameName of the collection.
license"Open" / "Exclusive" / "Non-Commercial" / "Exclusive Non-Commercial"

Step 2: Make API request

With the collection data ready, you can begin the collection creation process. Below are code snippets illustrating how to structure your API request.

tip

Prompt the user to sign a message with an onchain identity like a web3 wallet. This process authenticates the user and generates an access token that your application can use for subsequent requests.

Making a Node JS request with axios
const axios = require("axios");
let data = {
name: "Digital Painting",
description: "A beautiful digital painting.",
asset: {
data: "data:image/png;base64,...", // Data URL of the image
mimetype: "image/png",
},
};

axios
.request({
method: "post",
maxBodyLength: Infinity,
url: "https://api.arttribute.io/v2/collections",
headers: {
"Content-Type": "application/json",
"x-authentication-address": address, // web3 wallet address
"x-authentication-message": message,
"x-authentication-signature": signature, // signature of the message
},
data: JSON.stringify(data),
})
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});

Step 3: Add artifacts to the collection

To add an artifact to a collection, make a POST request to the /collections/{collectionId}/items endpoint. Below is an example of how to add an artifact to a collection using the Arttribute API. The data object is an array of artifact IDs that you want to add to the collection. This is shown in the example below.

Making a Node JS request with axios
const axios = require("axios");
let data = [{ itemId: "artifactId1" }, { itemId: "artifactId2" }];

axios
.request({
method: "post",
maxBodyLength: Infinity,
url: `https://api.arttribute.io/v2/collections/${collectionId}/items`,
headers: {
"Content-Type": "application/json",
"x-authentication-address": address, // web3 wallet address
"x-authentication-message": message,
"x-authentication-signature": signature, // signature of the message
},
data: JSON.stringify(data),
})
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});

Exploring Additional Functionality

Arttribute provides a range of features beyond creating collections and adding artifacts to them. In this section, we'll walk you through how to:

  • Fetch information about a Collection
  • Update a Collection
  • Delete a Collection
  • Dealing with Items in a Collection

Fetching Collections

Collection by ID

To retrieve a specific collection, make a GET request to the /collection/{id} endpoint. Below is an example of how to fetch a specific collection using the Arttribute API.

Making a Node JS request with axios
const axios = require("axios");

axios
.get(`https://api.arttribute.io/v2/collections/${id}`)
.then((response) => {
console.log(JSON.stringify(response.data)); // returns the collection with the specified ID
})
.catch((error) => {
console.log(error);
});

Collections by Creator

To retrieve all collections created by a specific user, make a GET request to the /users/{creatorId}/collections endpoint. Below is an example of how to fetch all collections created by a specific user using the Arttribute API.

Making a Node JS request with axios
const axios = require("axios");

axios
.get(`https://api.arttribute.io/v2/users/${creatorId}/collections`)
.then((response) => {
console.log(JSON.stringify(response.data)); // returns an array of collections created by the specified user
})
.catch((error) => {
console.log(error);
});

Items in a Collection

To retrieve all items in a specific collection, make a GET request to the /collections/{collectionId}/items endpoint. Below is an example of how to fetch all items in a specific collection using the Arttribute API.

Making a Node JS request with axios
const axios = require("axios");

axios
.get(`https://api.arttribute.io/v2/collections/${collectionId}/items`)
.then((response) => {
console.log(JSON.stringify(response.data)); // returns an array of items in the specified collection
})
.catch((error) => {
console.log(error);
});

Updating Collections

Step 1: Prepare the Collection Data

Before updating an collection, gather all necessary information. The fields available for updating an collection are:

FeatureDescription
nameName of the collection.
license"Open" / "Exclusive" / "Non-Commercial" / "Exclusive Non-Commercial"
whitelistList of string addresses that can access the collection.
blacklistList of string addresses that cannot access the collection.

Step 2: Make API request

With the collection data ready, you can begin the collection update process. Below are code snippets illustrating how to structure your API request.

Making a Node JS request with axios
const axios = require("axios");
let data = {
name: "Digital Painting",
license: "Open",
whitelist: ["0x1234", "0x5678"],
blacklist: ["0x9876"],
};

axios
.request({
method: "patch",
maxBodyLength: Infinity,
url: `https://api.arttribute.io/v2/collections/${id}`,
headers: {
"Content-Type": "application/json",
"x-authentication-address": address, // web3 wallet address
"x-authentication-message": message,
"x-authentication-signature": signature, // signature of the message
},
data: JSON.stringify(data),
})
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});

Deleting Collection data

Removing an Item from a Collection

To remove an item from a collection, make a DELETE request to the /collections/{collectionId}/items/{itemId} endpoint. Below is an example of how to remove an item from a collection using the Arttribute API.

Making a Node JS request with axios
const axios = require("axios");

axios
.request({
method: "delete",
url: `https://api.arttribute.io/v2/collections/${collectionId}/items/${itemId}`,
headers: {
"x-authentication-address": address, // web3 wallet address
"x-authentication-message": message,
"x-authentication-signature": signature, // signature of the message
},
})
.then((response) => {
console.log(JSON.stringify(response));
})
.catch((error) => {
console.log(error);
});

Deleting a Collection

To delete a collection, make a DELETE request to the /collections/{id} endpoint. Below is an example of how to delete a collection using the Arttribute API.

Making a Node JS request with axios
const axios = require("axios");

axios
.request({
method: "delete",
url: `https://api.arttribute.io/v2/collections/${id}`,
headers: {
"x-authentication-address": address, // web3 wallet address
"x-authentication-message": message,
"x-authentication-signature": signature, // signature of the message
},
})
.then((response) => {
console.log(JSON.stringify(response));
})
.catch((error) => {
console.log(error);
});