Google Sheets Integration

Use Butter Ipsum directly in your spreadsheets

✦ ❈ ✦

Setup Instructions

  1. Open your Google Sheet
  2. Go to Extensions > Apps Script
  3. Create a new script file
  4. Copy and paste the code below
  5. Save and return to your spreadsheet

Google Apps Script Code

/**
 * Generate butter-themed placeholder text directly in Google Sheets.
 * 
 * @param {number} count The number of units to generate (1-10)
 * @param {string} mode The generation mode: "paragraph", "sentence", or "word"
 * @return The generated butter-themed text
 * @customfunction
 */
function BUTTERIPSUM(count = 1, mode = "paragraph") {
  // Validate parameters
  if (count < 1 || count > 10) {
    throw new Error("Count must be between 1 and 10");
  }
  
  const validModes = ["paragraph", "sentence", "word"];
  if (!validModes.includes(mode.toLowerCase())) {
    throw new Error("Mode must be one of: paragraph, sentence, word");
  }
  
  // Call the Butter Ipsum API
  const apiUrl = "https://butteripsum.com/api/v1/generate" +
                "?count=" + count +
                "&mode=" + mode.toLowerCase();
  
  try {
    const response = UrlFetchApp.fetch(apiUrl);
    const data = JSON.parse(response.getContentText());
    
    if (data.error) {
      throw new Error(data.message || "Failed to generate text");
    }
    
    return data.text;
  } catch (error) {
    throw new Error("Failed to generate text: " + error.message);
  }
}

Usage Examples

=BUTTERIPSUM(2, "paragraph")  // Generates 2 paragraphs
=BUTTERIPSUM(3, "sentence")   // Generates 3 sentences
=BUTTERIPSUM(5, "word")       // Generates 5 words
Note: The custom function respects the same rate limits as the API.