MakeFav API दस्तऐवजीकरण
तुमच्या स्वतःच्या कोड, बिल्ड स्क्रिप्ट आणि CI पाइपलाइनमधून संपूर्ण फेविकॉन पॅकेज तयार करा. एका रिक्वेस्टमध्ये कोणत्याही इमेजचे favicon.ico, Apple touch icons, Android आणि PWA आयकॉन, वेब मॅनिफेस्ट आणि थेट पेस्ट करता येणाऱ्या HTML मध्ये रूपांतर होते.
या पृष्ठावर
झटपट सुरुवात
MakeFav API ही साधी HTTPS + JSON REST API आहे. सर्व एंडपॉइंट एकाच बेस URL अंतर्गत आहेत:
https://makefav.com/api/v1 - मोफत खाते तयार करा
साइन अप करा, तुमच्या ईमेल पत्त्याची पुष्टी करा आणि MakeFav न्यूजलेटर सबस्क्रिप्शन सक्रिय ठेवा – मोफत प्लॅनची हीच एकमेव अट आहे. - API की तयार करा
तुमच्या खात्यातील API keys पृष्ठ उघडा आणि वैयक्तिक की तयार करा. ती mf_ ने सुरू होते आणि फक्त एकदाच दाखवली जाते, म्हणून ती सुरक्षित ठेवा. API की व्यवस्थापित करा - तुमची पहिली रिक्वेस्ट पाठवा
generate एंडपॉइंटवर इमेज अपलोड करा आणि मिळालेली ZIP फाइल सेव्ह करा:
curl --fail-with-body -sS https://makefav.com/api/v1/generate \
-H "Authorization: Bearer $MAKEFAV_API_KEY" \
-F "[email protected]" \
-F "app_name=My App" \
-F "theme_color=#2f9e68" \
-F "radius=20" \
-o favicons.zip Unzip favicons.zip, upload the files to your website and paste the HTML code from the end of readme-makefav.txt into the <head> of every page.
ऑथेंटिकेशन
संरक्षित एंडपॉइंटवरील प्रत्येक रिक्वेस्टमध्ये वैयक्तिक API की असणे आवश्यक आहे. तुम्ही तुमच्या खाते पृष्ठावर कधीही की तयार करू शकता, त्यांना नाव देऊ शकता आणि रद्द करू शकता: API की
Send the key as a bearer token in the Authorization header, or – if your HTTP client makes that awkward – in the X-API-Key header. Both are equivalent.
Authorization: Bearer mf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# or, alternatively
X-API-Key: mf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Missing or invalid keys return 401 Unauthorized. The GET /sizes and GET /openapi.json endpoints do not require a key.
रेट लिमिट
डीफॉल्टनुसार प्रत्येक API की प्रति तास 100 रिक्वेस्ट करू शकते. प्रत्येक प्रमाणीकृत प्रतिसाद तुम्ही कुठे आहात ते सांगतो:
| हेडर | वर्णन |
|---|---|
X-RateLimit-Limit | सध्याच्या विंडोमध्ये परवानगी असलेल्या रिक्वेस्टची कमाल संख्या. |
X-RateLimit-Remaining | सध्याच्या विंडोमध्ये उरलेल्या रिक्वेस्ट. |
X-RateLimit-Reset | विंडो रीसेट होण्याची Unix टाइमस्टॅम्प (सेकंद, UTC). |
HTTP/1.1 200 OK
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 97
X-RateLimit-Reset: 1767225600 When the limit is exceeded the API responds with HTTP 429 and the error code rate_limited. Wait until the time in X-RateLimit-Reset before retrying – do not retry in a tight loop.
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1767225600
{"error": {"code": "rate_limited", "message": "Rate limit exceeded. Try again after the reset time."}} You can check your current quota at any time with GET /me.
एंडपॉइंट
| एंडपॉइंट | ऑथ | वर्णन |
|---|---|---|
POST /generate | API की | संपूर्ण फेविकॉन पॅकेज तयार करा. |
GET /me | API की | तुमचे खाते आणि सध्याची रेट-लिमिट स्थिती. |
GET /sizes | काहीही नाही | जनरेटर तयार करत असलेल्या सर्व आयकॉन फाइल्स आणि आकारांची यादी. |
GET /openapi.json | काहीही नाही | मशीन-वाचनीय OpenAPI 3.1 स्पेसिफिकेशन. |
favicon पॅकेज तयार करा
/generateएकाच स्रोत प्रतिमेतून संपूर्ण favicon पॅकेज तयार करते. प्रतिमा तीनपैकी एका पद्धतीने पाठवा:
| कंटेंट टाइप | प्रतिमा फील्ड | वर्णन |
|---|---|---|
multipart/form-data | image | फाइल अपलोड. शिफारस केलेले – सर्वात कार्यक्षम पर्याय. |
application/json | image_base64 | Base64-encoded image, either raw base64 or a data URL such as data:image/png;base64,iVBOR…. |
application/json | image_url | प्रतिमेचा सार्वजनिक http किंवा https URL. सर्व्हर ती डाउनलोड करतो (कमाल 10 MB). |
समर्थित इनपुट फॉरमॅट: PNG, JPG, WebP, AVIF, GIF, BMP, SVG आणि ICO. कमाल फाइल आकार: 10 MB.
पॅरामीटर्स
सर्व पॅरामीटर्स ऐच्छिक आहेत. ते फॉर्म फील्ड (multipart) किंवा JSON प्रॉपर्टी म्हणून पाठवा. अवैध मूल्यांच्या जागी डीफॉल्ट वापरला जातो.
| नाव | प्रकार / श्रेणी | डीफॉल्ट | वर्णन |
|---|---|---|---|
app_name | string, कमाल 60 अक्षरे | My Website | तुमच्या वेबसाइट किंवा अॅपचे नाव, manifest.json आणि उदाहरण पेजमध्ये वापरले जाते. |
short_name | string, कमाल 24 अक्षरे | app_name ची पहिली 12 अक्षरे | Android होम स्क्रीनवर आयकॉनखाली दिसणारे छोटे नाव. |
theme_color | #rrggbb | #ffffff | ब्राउझर UI चा रंग (theme-color मेटा टॅग आणि manifest). |
tile_color | #rrggbb | theme_color प्रमाणेच | Windows Start टाइल्सचा पार्श्वभूमी रंग. |
background | transparent | #rrggbb | transparent | ब्राउझर, Android आणि Windows आयकॉनची पार्श्वभूमी. |
apple_background | #rrggbb | #ffffff | Apple touch आयकॉन आणि maskable आयकॉनची पार्श्वभूमी (iOS पारदर्शकतेला समर्थन देत नाही). background हा रंग असल्यास दुर्लक्षित केले जाते – त्याऐवजी तोच रंग वापरला जातो. |
padding | पूर्णांक, 0–40 (%) | 0 | प्रतिमेभोवतीची रिकामी जागा, आयकॉनच्या आकाराच्या टक्केवारीत. |
radius | पूर्णांक, 0–50 (%) | 0 | गोलाकार कोपरे. 50 म्हणजे वर्तुळ. Apple आयकॉनना लागू होत नाही, कारण iOS ते स्वतः गोलाकार करतो. |
zoom | पूर्णांक, 50–400 (%) | 100 | आयकॉनमधील प्रतिमेचे स्केल. 100 पेक्षा जास्त मूल्यांमुळे प्रतिमा क्रॉप होते. |
offset_x, offset_y | संख्या, -1 ते 1 | 0 | प्रतिमा आडवी / उभी हलवते, आयकॉनच्या आकाराच्या अपूर्णांकात. |
path | string | / | तुमच्या सर्व्हरवरील फोल्डर जिथे आयकॉन असतील. HTML स्निपेट, manifest आणि browserconfig मध्ये वापरला जातो. |
display | standalone | fullscreen | minimal-ui | browser | standalone | manifest मध्ये लिहिला जाणारा PWA डिस्प्ले मोड. |
pixelated | auto | 1 | 0 | auto | पिक्सेल आर्टसाठी स्पष्ट nearest-neighbour स्केलिंग. auto हे 64 px किंवा लहान स्रोतांसाठी ते सुरू करते. |
maskable | 1 | 0 | 1 | Android adaptive आयकॉनसाठी सेफ-झोन पॅडिंगसह maskable-icon-512x512.png देखील तयार करा. |
ico_sizes | स्वल्पविरामाने विभक्त यादी: 16, 24, 32, 48, 64, 128, 256 | 16,32,48 | favicon.ico मध्ये समाविष्ट केलेले आकार. |
groups | स्वल्पविरामाने विभक्त यादी: favicon, apple, android, ms | favicon,apple,android,ms | तयार करायचे आयकॉन संच: ब्राउझर favicon, Apple touch आयकॉन, Android / PWA आयकॉन आणि Windows टाइल्स. |
format | zip | json | zip | प्रतिसाद फॉरमॅट – खाली पहा. |
प्रतिसाद
format=zip- Binary ZIP archive with
Content-Type: application/zipandContent-Disposition: attachment. Default. format=json- JSON object with the package
id(32 hex characters), thehtmlsnippet for your <head> and afilesarray; each file hasname,mime,size(bytes) andbase64contents.
उदाहरण विनंती – multipart, ZIP प्रतिसाद
curl --fail-with-body -sS https://makefav.com/api/v1/generate \
-H "Authorization: Bearer $MAKEFAV_API_KEY" \
-F "[email protected]" \
-F "app_name=My App" \
-F "theme_color=#2f9e68" \
-F "radius=20" \
-o favicons.zip HTTP/1.1 200 OK
Content-Type: application/zip
Content-Disposition: attachment
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 99
X-RateLimit-Reset: 1767225600
<binary ZIP data> उदाहरण विनंती – प्रतिमा URL सह JSON, JSON प्रतिसाद
curl --fail-with-body -sS https://makefav.com/api/v1/generate \
-H "Authorization: Bearer $MAKEFAV_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"image_url": "https://example.com/logo.png",
"app_name": "My App",
"theme_color": "#2f9e68",
"radius": 20,
"groups": "favicon,apple,android",
"format": "json"
}' {
"id": "9f86d081884c7d659a2feaa0c55ad015",
"html": "<link rel=\"apple-touch-icon\" sizes=\"57x57\" href=\"/apple-icon-57x57.png\">\n…\n<meta name=\"theme-color\" content=\"#2f9e68\">",
"files": [
{"name": "favicon.ico", "mime": "image/x-icon", "size": 15086, "base64": "AAABAAMAEBAAAAEAIABoBAAANgAAACAg…"},
{"name": "favicon-16x16.png", "mime": "image/png", "size": 612, "base64": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQ…"},
{"name": "manifest.json", "mime": "application/json", "size": 1094, "base64": "ewogICAgIm5hbWUiOiAiTXkgQXBwIiwK…"}
]
}
तुमचे खाते मिळवा
/meAPI की ज्या वापरकर्त्याची आहे त्याची माहिती आणि सध्याची रेट-लिमिट स्थिती परत करते. की तपासण्यासाठी उपयुक्त. ऑथेंटिकेशन आवश्यक; पॅरामीटर्स नाहीत.
उदाहरण विनंती
curl -sS https://makefav.com/api/v1/me \
-H "Authorization: Bearer $MAKEFAV_API_KEY" उदाहरण प्रतिसाद
{
"id": 1,
"email": "[email protected]",
"name": "Jane Doe",
"rate_limit": {"limit": 100, "remaining": 97, "reset": 1767225600}
}
आयकॉन आकारांची यादी
/sizesReturns every icon file the generator can produce, with its pixel size and group. No authentication and no parameters. The group value matches the groups parameter of POST /generate.
उदाहरण विनंती
curl -sS https://makefav.com/api/v1/sizes उदाहरण प्रतिसाद
{
"files": [
{"name": "favicon-16x16.png", "size": 16, "group": "favicon"},
{"name": "favicon-32x32.png", "size": 32, "group": "favicon"},
{"name": "apple-touch-icon.png", "size": 180, "group": "apple"},
{"name": "android-icon-192x192.png", "size": 192, "group": "android"},
{"name": "ms-icon-144x144.png", "size": 144, "group": "ms"}
]
}
OpenAPI स्पेसिफिकेशन
/openapi.jsonया API चे OpenAPI 3.1 वर्णन परत करते. ऑथेंटिकेशन नाही. ते Postman, Insomnia किंवा Swagger UI मध्ये इम्पोर्ट करा, किंवा तुमच्या भाषेसाठी typed क्लायंट तयार करण्यासाठी वापरा.
curl -sS https://makefav.com/api/v1/openapi.json -o makefav-openapi.json त्रुटी
Successful requests return HTTP 200. Every error returns a JSON body with a stable, machine-readable code and a human-readable message. Always branch on the code, not on the message text.
HTTP/1.1 422 Unprocessable Content
Content-Type: application/json
{
"error": {
"code": "invalid_image",
"message": "The uploaded file could not be decoded as an image."
}
} | HTTP स्टेटस | एरर कोड | अर्थ |
|---|---|---|
| 400 | bad_request | विनंती चुकीच्या स्वरूपात आहे, उदाहरणार्थ प्रतिमा पाठवली नाही किंवा JSON बॉडी अवैध आहे. |
| 401 | unauthorized | API की नाही किंवा अवैध आहे. |
| 403 | forbidden | की मालकाचा ईमेल निश्चित केलेला नाही, न्यूजलेटर सदस्यता बंद आहे किंवा खाते बंद केले आहे. |
| 413 | file_too_large | प्रतिमा 10 MB पेक्षा मोठी आहे. |
| 415 | unsupported_type | फाइल प्रकार किंवा विनंतीचा कंटेंट टाइप समर्थित नाही. |
| 422 | invalid_image | फाइल प्रतिमा म्हणून डीकोड करता आली नाही, किंवा प्रतिमा URL डाउनलोड करता आला नाही. |
| 429 | rate_limited | खूप जास्त विनंत्या. X-RateLimit-Reset पर्यंत थांबा. |
| 500 | server_error | आमच्या बाजूने काहीतरी चूक झाली. नंतर पुन्हा प्रयत्न करा; समस्या कायम राहिल्यास सपोर्टशी संपर्क साधा. |
आउटपुट फाइल
With all groups enabled, a package contains the files below. Files from disabled groups are left out.
| फाइल | आकार | गट |
|---|---|---|
favicon.ico | 16, 32, 48 (कॉन्फिगर करण्यायोग्य) | नेहमी |
favicon-16x16.png | 16 × 16 | favicon |
favicon-32x32.png | 32 × 32 | favicon |
favicon-96x96.png | 96 × 96 | favicon |
apple-icon-57x57.png | 57 × 57 | apple |
apple-icon-60x60.png | 60 × 60 | apple |
apple-icon-72x72.png | 72 × 72 | apple |
apple-icon-76x76.png | 76 × 76 | apple |
apple-icon-114x114.png | 114 × 114 | apple |
apple-icon-120x120.png | 120 × 120 | apple |
apple-icon-144x144.png | 144 × 144 | apple |
apple-icon-152x152.png | 152 × 152 | apple |
apple-icon-180x180.png | 180 × 180 | apple |
apple-icon.png | 192 × 192 | apple |
apple-icon-precomposed.png | 192 × 192 | apple |
apple-touch-icon.png | 180 × 180 | apple |
android-icon-36x36.png | 36 × 36 | android |
android-icon-48x48.png | 48 × 48 | android |
android-icon-72x72.png | 72 × 72 | android |
android-icon-96x96.png | 96 × 96 | android |
android-icon-144x144.png | 144 × 144 | android |
android-icon-192x192.png | 192 × 192 | android |
android-icon-512x512.png | 512 × 512 | android |
web-app-manifest-192x192.png | 192 × 192 | android |
web-app-manifest-512x512.png | 512 × 512 | android |
maskable-icon-512x512.png | 512 × 512 | android |
ms-icon-70x70.png | 70 × 70 | ms |
ms-icon-144x144.png | 144 × 144 | ms |
ms-icon-150x150.png | 150 × 150 | ms |
ms-icon-310x310.png | 310 × 310 | ms |
अतिरिक्त फाइल्स
| फाइल | समाविष्ट | वर्णन |
|---|---|---|
favicon.svg | फक्त SVG इनपुटसाठी, क्रॉप, झूम, पॅडिंग, कोपरे किंवा पार्श्वभूमीशिवाय | व्हेक्टर favicon ला समर्थन देणाऱ्या ब्राउझरसाठी तुमच्या SVG ची सॅनिटाइझ केलेली प्रत. |
manifest.json, site.webmanifest | android | Android आणि इन्स्टॉल करता येणाऱ्या PWA साठी वेब अॅप manifest (दोन समान प्रती). |
browserconfig.xml | ms | तुमच्या टाइल रंगासह Windows टाइल कॉन्फिगरेशन. |
readme-makefav.txt | नेहमी | शेवटी तुमच्या <head> साठी HTML कोडसह इन्स्टॉलेशन सूचना. |
कोड उदाहरणे
Each example uploads logo.png with a few options and saves favicons.zip, handling API errors. Set the environment variable MAKEFAV_API_KEY to your API key first.
Multipart अपलोड:
# Multipart upload (recommended). --fail-with-body exits non-zero on HTTP errors
# and still saves the JSON error body, so you can inspect it.
curl --fail-with-body -sS https://makefav.com/api/v1/generate \
-H "Authorization: Bearer $MAKEFAV_API_KEY" \
-F "[email protected]" \
-F "app_name=My App" \
-F "theme_color=#2f9e68" \
-F "radius=20" \
-o favicons.zip \
|| { echo "Request failed:"; cat favicons.zip; rm -f favicons.zip; exit 1; } base64-एन्कोड केलेल्या प्रतिमेसह JSON बॉडी (jq आवश्यक):
# JSON body with a base64-encoded image (built with jq to avoid argument length limits)
base64 < logo.png | tr -d '\n' > logo.b64
jq -n --rawfile img logo.b64 \
'{image_base64: $img, app_name: "My App", theme_color: "#2f9e68", radius: 20}' \
| curl --fail-with-body -sS https://makefav.com/api/v1/generate \
-H "Authorization: Bearer $MAKEFAV_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- \
-o favicons.zip \
|| { echo "Request failed:"; cat favicons.zip; rm -f favicons.zip; exit 1; } <?php
// Requires the curl extension. Run: MAKEFAV_API_KEY=mf_... php favicons.php
$apiKey = getenv('MAKEFAV_API_KEY') ?: exit("Set MAKEFAV_API_KEY first\n");
$ch = curl_init('https://makefav.com/api/v1/generate');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
CURLOPT_POSTFIELDS => [
'image' => new CURLFile('logo.png', 'image/png', 'logo.png'),
'app_name' => 'My App',
'theme_color' => '#2f9e68',
'radius' => '20',
],
]);
$body = curl_exec($ch);
if ($body === false) {
fwrite(STDERR, 'Request failed: ' . curl_error($ch) . PHP_EOL);
exit(1);
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status !== 200) {
$error = json_decode($body, true)['error'] ?? ['code' => 'http_' . $status, 'message' => substr($body, 0, 200)];
fwrite(STDERR, "Error {$status} {$error['code']}: {$error['message']}" . PHP_EOL);
exit(1);
}
file_put_contents('favicons.zip', $body);
echo 'Saved favicons.zip (' . strlen($body) . " bytes)\n"; # pip install requests · Run: MAKEFAV_API_KEY=mf_... python favicons.py
import os
import sys
import requests
API_KEY = os.environ["MAKEFAV_API_KEY"]
try:
with open("logo.png", "rb") as logo:
resp = requests.post(
"https://makefav.com/api/v1/generate",
headers={"Authorization": f"Bearer {API_KEY}"},
files={"image": ("logo.png", logo, "image/png")},
data={"app_name": "My App", "theme_color": "#2f9e68", "radius": 20},
timeout=60,
)
except requests.RequestException as exc:
sys.exit(f"Request failed: {exc}")
if resp.status_code != 200:
try:
err = resp.json()["error"]
sys.exit(f"Error {resp.status_code} {err['code']}: {err['message']}")
except (ValueError, KeyError, TypeError):
sys.exit(f"Error {resp.status_code}: {resp.text[:200]}")
with open("favicons.zip", "wb") as out:
out.write(resp.content)
remaining = resp.headers.get("X-RateLimit-Remaining")
print(f"Saved favicons.zip ({len(resp.content)} bytes), {remaining} requests left this hour") // favicons.mjs — Node.js 18+, no dependencies. Run: MAKEFAV_API_KEY=mf_... node favicons.mjs
import { readFile, writeFile } from 'node:fs/promises';
const form = new FormData();
form.append('image', new Blob([await readFile('logo.png')], { type: 'image/png' }), 'logo.png');
form.append('app_name', 'My App');
form.append('theme_color', '#2f9e68');
form.append('radius', '20');
const res = await fetch('https://makefav.com/api/v1/generate', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.MAKEFAV_API_KEY}` },
body: form,
});
if (!res.ok) {
const body = await res.json().catch(() => null);
console.error(`Error ${res.status} ${body?.error?.code ?? ''}: ${body?.error?.message ?? res.statusText}`);
process.exit(1);
}
await writeFile('favicons.zip', Buffer.from(await res.arrayBuffer()));
console.log(`Saved favicons.zip, ${res.headers.get('x-ratelimit-remaining')} requests left this hour`); <input type="file" id="logo" accept="image/*">
<button type="button" id="go">Generate favicons</button>
<script>
// Never put your API key in browser code. Point ENDPOINT at your own backend route,
// which forwards the multipart body to https://makefav.com/api/v1/generate and adds
// the "Authorization: Bearer mf_..." header on the server.
const ENDPOINT = '/my-backend/favicons';
document.getElementById('go').addEventListener('click', async () => {
const file = document.getElementById('logo').files[0];
if (!file) {
alert('Please choose an image first.');
return;
}
const form = new FormData();
form.append('image', file);
form.append('app_name', 'My App');
form.append('theme_color', '#2f9e68');
form.append('radius', '20');
try {
const res = await fetch(ENDPOINT, { method: 'POST', body: form });
if (!res.ok) {
const body = await res.json().catch(() => null);
throw new Error(body?.error?.message || `HTTP ${res.status}`);
}
const url = URL.createObjectURL(await res.blob());
const a = Object.assign(document.createElement('a'), { href: url, download: 'favicons.zip' });
document.body.append(a);
a.click();
a.remove();
setTimeout(() => URL.revokeObjectURL(url), 1000);
} catch (err) {
alert('Favicon generation failed: ' + err.message);
}
});
</script> // go run favicons.go (MAKEFAV_API_KEY must be set)
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"mime/multipart"
"net/http"
"net/textproto"
"os"
"time"
)
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func run() error {
var body bytes.Buffer
w := multipart.NewWriter(&body)
logo, err := os.ReadFile("logo.png")
if err != nil {
return err
}
h := make(textproto.MIMEHeader)
h.Set("Content-Disposition", `form-data; name="image"; filename="logo.png"`)
h.Set("Content-Type", "image/png")
part, err := w.CreatePart(h)
if err != nil {
return err
}
if _, err := part.Write(logo); err != nil {
return err
}
for k, v := range map[string]string{"app_name": "My App", "theme_color": "#2f9e68", "radius": "20"} {
if err := w.WriteField(k, v); err != nil {
return err
}
}
if err := w.Close(); err != nil {
return err
}
req, err := http.NewRequest(http.MethodPost, "https://makefav.com/api/v1/generate", &body)
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("MAKEFAV_API_KEY"))
req.Header.Set("Content-Type", w.FormDataContentType())
client := &http.Client{Timeout: 60 * time.Second}
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
var apiErr struct {
Error struct {
Code string `json:"code"`
Message string `json:"message"`
} `json:"error"`
}
_ = json.NewDecoder(resp.Body).Decode(&apiErr)
return fmt.Errorf("error %d %s: %s", resp.StatusCode, apiErr.Error.Code, apiErr.Error.Message)
}
zip, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
if err := os.WriteFile("favicons.zip", zip, 0o644); err != nil {
return err
}
fmt.Printf("Saved favicons.zip (%d bytes)\n", len(zip))
return nil
} # ruby favicons.rb (MAKEFAV_API_KEY must be set) — standard library only
require "net/http"
require "json"
require "uri"
uri = URI("https://makefav.com/api/v1/generate")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV.fetch("MAKEFAV_API_KEY")}"
res = File.open("logo.png", "rb") do |logo|
req.set_form(
[
["image", logo, { filename: "logo.png", content_type: "image/png" }],
["app_name", "My App"],
["theme_color", "#2f9e68"],
["radius", "20"]
],
"multipart/form-data"
)
Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 60) { |http| http.request(req) }
end
unless res.is_a?(Net::HTTPSuccess)
err = (JSON.parse(res.body)["error"] rescue nil) || { "code" => res.code, "message" => res.body.to_s[0, 200] }
abort "Error #{res.code} #{err["code"]}: #{err["message"]}"
end
File.binwrite("favicons.zip", res.body)
puts "Saved favicons.zip (#{res.body.bytesize} bytes)" // .NET 6+ console app (Program.cs, top-level statements, implicit usings enabled)
using System.Net.Http.Headers;
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(60) };
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("MAKEFAV_API_KEY"));
using var form = new MultipartFormDataContent();
var image = new ByteArrayContent(await File.ReadAllBytesAsync("logo.png"));
image.Headers.ContentType = new MediaTypeHeaderValue("image/png");
form.Add(image, "image", "logo.png");
form.Add(new StringContent("My App"), "app_name");
form.Add(new StringContent("#2f9e68"), "theme_color");
form.Add(new StringContent("20"), "radius");
using var response = await http.PostAsync("https://makefav.com/api/v1/generate", form);
if (!response.IsSuccessStatusCode)
{
var body = await response.Content.ReadAsStringAsync();
string code = "", message = body;
try
{
var error = JsonDocument.Parse(body).RootElement.GetProperty("error");
code = error.GetProperty("code").GetString() ?? "";
message = error.GetProperty("message").GetString() ?? "";
}
catch (Exception e) when (e is JsonException or KeyNotFoundException or InvalidOperationException) { }
Console.Error.WriteLine($"Error {(int)response.StatusCode} {code}: {message}");
return 1;
}
await File.WriteAllBytesAsync("favicons.zip", await response.Content.ReadAsByteArrayAsync());
Console.WriteLine("Saved favicons.zip");
return 0; // Java 11+, no dependencies. Run: MAKEFAV_API_KEY=mf_... java MakeFav.java
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
public class MakeFav {
public static void main(String[] args) throws IOException, InterruptedException {
String boundary = "----MakeFav" + UUID.randomUUID().toString().replace("-", "");
Map<String, String> fields = new LinkedHashMap<>();
fields.put("app_name", "My App");
fields.put("theme_color", "#2f9e68");
fields.put("radius", "20");
// Build the multipart/form-data body by hand
ByteArrayOutputStream body = new ByteArrayOutputStream();
for (Map.Entry<String, String> field : fields.entrySet()) {
body.write(("--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"" + field.getKey() + "\"\r\n\r\n"
+ field.getValue() + "\r\n").getBytes(StandardCharsets.UTF_8));
}
body.write(("--" + boundary + "\r\n"
+ "Content-Disposition: form-data; name=\"image\"; filename=\"logo.png\"\r\n"
+ "Content-Type: image/png\r\n\r\n").getBytes(StandardCharsets.UTF_8));
body.write(Files.readAllBytes(Path.of("logo.png")));
body.write(("\r\n--" + boundary + "--\r\n").getBytes(StandardCharsets.UTF_8));
HttpRequest request = HttpRequest.newBuilder(URI.create("https://makefav.com/api/v1/generate"))
.timeout(Duration.ofSeconds(60))
.header("Authorization", "Bearer " + System.getenv("MAKEFAV_API_KEY"))
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofByteArray(body.toByteArray()))
.build();
HttpResponse<byte[]> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofByteArray());
if (response.statusCode() != 200) {
// Error body is JSON: {"error":{"code":"...","message":"..."}}
System.err.println("Error " + response.statusCode() + ": "
+ new String(response.body(), StandardCharsets.UTF_8));
System.exit(1);
}
Files.write(Path.of("favicons.zip"), response.body());
System.out.println("Saved favicons.zip (" + response.body().length + " bytes)");
}
} GitHub Actions वर्कफ्लो – JSON फॉरमॅट, फाइल्स jq ने डीकोड केलेल्या:
# .github/workflows/favicons.yml — regenerate favicons whenever the logo changes.
# Add your key as a repository secret named MAKEFAV_API_KEY.
name: Favicons
on:
push:
paths: ['branding/logo.png']
workflow_dispatch:
jobs:
favicons:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate favicon package (JSON format)
env:
MAKEFAV_API_KEY: ${{ secrets.MAKEFAV_API_KEY }}
run: |
set -euo pipefail
curl --fail-with-body -sS https://makefav.com/api/v1/generate \
-H "Authorization: Bearer $MAKEFAV_API_KEY" \
-F "image=@branding/logo.png" \
-F "app_name=My App" \
-F "theme_color=#2f9e68" \
-F "radius=20" \
-F "path=/icons/" \
-F "format=json" \
-o favicons.json || { cat favicons.json; exit 1; }
mkdir -p public/icons
# Decode every file from the JSON response (jq is preinstalled on GitHub runners)
jq -r '.files[] | "\(.name) \(.base64)"' favicons.json |
while read -r name data; do
printf '%s' "$data" | base64 -d > "public/icons/$(basename "$name")"
done
jq -r '.html' favicons.json > public/icons/head-snippet.html
ls -l public/icons
- uses: actions/upload-artifact@v4
with:
name: favicons
path: public/icons कोणत्याही CI साठी साधी शेल स्क्रिप्ट – ZIP फॉरमॅट:
#!/usr/bin/env bash
# scripts/favicons.sh — simpler variant for any CI or build step: fetch the ZIP and unpack it.
set -euo pipefail
: "${MAKEFAV_API_KEY:?Set MAKEFAV_API_KEY}"
curl --fail-with-body -sS https://makefav.com/api/v1/generate \
-H "Authorization: Bearer $MAKEFAV_API_KEY" \
-F "[email protected]" \
-F "app_name=My App" \
-F "theme_color=#2f9e68" \
-F "radius=20" \
-o favicons.zip || { cat favicons.zip; rm -f favicons.zip; exit 1; }
unzip -o -q favicons.zip -d public/
rm favicons.zip
echo "Favicons written to public/" HTML वापर
Upload all files to the folder you set with path, then paste the snippet into the <head> of every page. It is included at the end of readme-makefav.txt in the package and, with format=json, returned in the html field. Example for the options used in the code examples above:
<head>
<meta charset="utf-8">
<title>My App</title>
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="icon" href="/favicon.ico" sizes="any">
<link rel="manifest" href="/manifest.json">
<meta name="msapplication-TileColor" content="#2f9e68">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="msapplication-config" content="/browserconfig.xml">
<meta name="theme-color" content="#2f9e68">
</head> डिप्लॉय केल्यानंतर, तुमचा ब्राउझर कॅशे साफ करा किंवा साइट प्रायव्हेट विंडोमध्ये उघडा – ब्राउझर favicon खूप आक्रमकपणे कॅशे करतात.
चेंजलॉग
v1
- MakeFav REST API चे पहिले सार्वजनिक प्रकाशन.
- Endpoints
POST /generate,GET /me,GET /sizesandGET /openapi.json. - ZIP आणि JSON प्रतिसाद फॉरमॅट, multipart, base64 आणि URL प्रतिमा इनपुट.
- प्रति तास 100 विनंत्यांसह वैयक्तिक API की.
आवृत्ती 1 स्थिर आहे: आम्ही फक्त ऐच्छिक पॅरामीटर्स आणि फील्ड जोडतो. ब्रेकिंग बदल आगाऊ सूचना देऊन नवीन आवृत्ती म्हणून प्रसिद्ध केले जातील.
सपोर्ट
प्रश्न, बग रिपोर्ट किंवा जास्त रेट लिमिट हवी आहे? आम्हाला मदत करायला आनंद होईल. कृपया तुमच्या संदेशात विनंतीची वेळ आणि एरर कोड समाविष्ट करा – तुमची API की कधीही नाही.