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 కీల పేజీని తెరిచి వ్యక్తిగత కీని సృష్టించండి. ఇది 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 | స్ట్రింగ్, గరిష్టంగా 60 అక్షరాలు | My Website | మీ వెబ్సైట్ లేదా యాప్ పేరు, manifest.json మరియు ఉదాహరణ పేజీలో ఉపయోగించబడుతుంది. |
short_name | స్ట్రింగ్, గరిష్టంగా 24 అక్షరాలు | app_name యొక్క మొదటి 12 అక్షరాలు | Android హోమ్ స్క్రీన్లలో ఐకాన్ కింద చూపబడే చిన్న పేరు. |
theme_color | #rrggbb | #ffffff | బ్రౌజర్ UI రంగు (theme-color meta ట్యాగ్ మరియు 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 అయితే వృత్తం అవుతుంది. iOS స్వయంగా గుండ్రం చేసే Apple ఐకాన్లకు వర్తించదు. |
zoom | పూర్ణాంకం, 50–400 (%) | 100 | ఐకాన్ లోపల ఇమేజ్ స్కేల్. 100 కంటే ఎక్కువ విలువలు ఇమేజ్ను క్రాప్ చేస్తాయి. |
offset_x, offset_y | సంఖ్య, -1 నుండి 1 | 0 | ఐకాన్ సైజులో భాగంగా, ఇమేజ్ను అడ్డంగా / నిలువుగా జరుపుతుంది. |
path | స్ట్రింగ్ | / | ఐకాన్లు ఉండే మీ సర్వర్లోని ఫోల్డర్. 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 కీ ఎవరిదో ఆ వినియోగదారుని మరియు ప్రస్తుత rate-limit స్థితిని తిరిగి ఇస్తుంది. కీని ధృవీకరించడానికి ఉపయోగకరం. ప్రమాణీకరణ అవసరం; పారామీటర్లు లేవు.
ఉదాహరణ రిక్వెస్ట్
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 లోకి ఇంపోర్ట్ చేయండి, లేదా మీ భాషకు టైప్డ్ క్లయింట్ను జనరేట్ చేయడానికి ఉపయోగించండి.
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 కీని ఎప్పటికీ చేర్చవద్దు.