{"library":"rfg-api","title":"RealFaviconGenerator API Client","description":"The `rfg-api` package provides a Node.js client for the RealFaviconGenerator's non-interactive API, enabling programmatic generation of favicons for various platforms including desktop browsers, iOS, and Android. Currently at version 0.5.3, the library focuses on integrating with the external API to manage favicon creation and asset generation. Release cadence appears to be driven primarily by bug fixes and dependency updates, particularly addressing security vulnerabilities in underlying HTTP clients and archive processors, rather than frequent new feature introductions. Its primary differentiator is its direct integration with the RealFaviconGenerator service, simplifying the complex process of generating a comprehensive set of favicons from a single master image. It largely operates using a callback-based asynchronous pattern.","language":"javascript","status":"maintenance","last_verified":"Sun Apr 19","install":{"commands":["npm install rfg-api"],"cli":null},"imports":["const rfgApi = require('rfg-api').init();","rfgApi.createFavicon(masterPicture, outputPath, design, settings, versioning, apiKey, callback);","const client = require('rfg-api').init();"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const rfgApi = require('rfg-api').init();\nconst path = require('path');\nconst fs = require('fs');\n\nconst API_KEY = process.env.RFG_API_KEY || 'YOUR_REAL_API_KEY_HERE'; // Replace with your actual key\nconst MASTER_PICTURE_PATH = path.join(__dirname, 'master-image.png');\nconst OUTPUT_PATH = path.join(__dirname, 'favicons');\n\n// Ensure a dummy master-image.png exists for the example to run.\n// In a real application, replace this with your actual image path.\nif (!fs.existsSync(MASTER_PICTURE_PATH)) {\n  console.warn(`Warning: '${MASTER_PICTURE_PATH}' not found. Creating a dummy file.`);\n  // For demonstration, create a minimal dummy file if it doesn't exist\n  fs.writeFileSync(MASTER_PICTURE_PATH, Buffer.from('<svg width=\"100\" height=\"100\"></svg>', 'utf8'));\n}\n\nconst faviconConfiguration = {\n  design: {\n    ios: {\n      pictureMargin: 2,\n      backgroundColor: '#ffffff',\n      themeColor: '#ffffff'\n    },\n    android: {\n      backgroundColor: '#ffffff',\n      themeColor: '#ffffff',\n      pictureMargin: 2\n    },\n    desktopBrowser: {}\n  },\n  settings: {\n    compression: 5,\n    scalingAlgorithm: 'Mitchell',\n    errorOnImageTooSmall: false,\n    readmeFile: false,\n    htmlCodeFile: false\n  },\n  versioning: {}\n};\n\nrfgApi.createFavicon(\n  MASTER_PICTURE_PATH,\n  OUTPUT_PATH,\n  faviconConfiguration.design,\n  faviconConfiguration.settings,\n  faviconConfiguration.versioning,\n  API_KEY,\n  (error, response) => {\n    if (error) {\n      console.error('Error generating favicons:', error);\n      return;\n    }\n    console.log('Favicons generated successfully!');\n    console.log('Response:', JSON.stringify(response, null, 2));\n    // The response typically contains a zip URL and HTML markups.\n    // You would typically download the zip from 'response.favicon.url'\n    // and inject 'response.favicon.html_code' into your HTML templates.\n  }\n);\n\nconsole.log('Initiating favicon generation process...');\n","lang":"javascript","description":"Demonstrates how to initialize the `rfg-api` client, provide a placeholder master image path and API key, and call the `createFavicon` method with a callback to handle the asynchronous response for favicon generation.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}