Tool for Cults3D: Automating Daily Tracking of Your Cults3D Designs with API into Google Sheets
I often upload my work to Cults3D. However, one thing I find limiting is that the platform doesn’t offer a straightforward way to track daily views and downloads for my designs. This makes it challenging to analyze how my work is performing over time.
To solve this, I used the Cults3D API to export my data into Google Sheets. This setup allows me to organize, analyze, and visualize the data more effectively.
I thought this might be helpful for others facing the same issue, so I’ve put together a guide and some code to share with you!
How It Works
- Fetch data from Cults3D API Use the API key provided by Cults3D to access your design data.
- Export data to Google Sheets Leverage Google Sheets API to push the fetched data into a spreadsheet.
- Analyze and visualize Use Google Sheets to filter data, create charts, and track trends like daily downloads and views.
Why It’s Useful
- Easily track how each design performs over time.
- Visualize trends to identify which designs are the most popular.
- Save time by automating data collection and organization.
Code
function fetchCults3DData() {
const url = "https://cults3d.com/graphql";
const username = ""; //Username
const password = ""; // API Key
const authHeader = "Basic " + Utilities.base64Encode(username + ":" + password);
const query = `
query {
myself {
creationsBatch(limit: 15, sort: BY_PUBLICATION, direction: DESC, offset: 0) {
results {
name
viewsCount
downloadsCount
likesCount
totalSalesAmount(currency: USD) {
cents
}
}
}
}
}
`;
const payload = JSON.stringify({ query: query });
const options = {
method: "post",
contentType: "application/json",
headers: {
Authorization: authHeader,
Accept: "application/json"
},
payload: JSON.stringify({ query: query }),
muteHttpExceptions: true
};
try {
const response = UrlFetchApp.fetch(url, options);
const data = JSON.parse(response.getContentText());
console.log(data)
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const today = new Date().toISOString().split("T")[0];
sheet.appendRow(["Date", "Type", "Name", "Views", "Downloads", "Likes", "Total Sales (USD)"]);
data.data.myself.creationsBatch.results.forEach(creation => {
sheet.appendRow([
today,
"Creation",
creation.name,
creation.viewsCount,
creation.downloadsCount,
creation.likesCount,
(creation.totalSalesAmount.cents / 100).toFixed(2)
]);
});
Logger.log("Data successfully fetched and written to Google Sheets!");
} catch (e) {
Logger.log("Error: " + e.message);
}
}