MakeFav API စာတမ်း
သင့်ကိုယ်ပိုင်ကုဒ်၊ build script များနှင့် CI pipeline များမှ ပြည့်စုံသော favicon package များကို ဖန်တီးပါ။ တောင်းဆိုမှုတစ်ခုတည်းဖြင့် မည်သည့်ပုံကိုမဆို favicon.ico၊ Apple touch icon များ၊ Android နှင့် PWA အိုင်ကွန်များ၊ web manifest နှင့် ကူးထည့်ရန် အသင့် HTML တို့အဖြစ် ပြောင်းပေးသည်။
ဤစာမျက်နှာတွင်
အမြန်စတင်ရန်
MakeFav API သည် ရိုးရှင်းသော HTTPS + JSON REST API ဖြစ်သည်။ Endpoint အားလုံးသည် base URL တစ်ခုအောက်တွင် ရှိသည်။
https://makefav.com/api/v1 - အခမဲ့အကောင့် ဖွင့်ပါ
စာရင်းသွင်းပြီး သင့်အီးမေးလ်လိပ်စာကို အတည်ပြုကာ MakeFav သတင်းလွှာ စာရင်းသွင်းမှုကို ဆက်လက်ဖွင့်ထားပါ – ၎င်းသည် အခမဲ့အစီအစဉ်၏ တစ်ခုတည်းသော เงื่อนไข ဖြစ်သည်။ - API key ဖန်တီးပါ
သင့်အကောင့်ရှိ API keys စာမျက်နှာကို ဖွင့်ပြီး ကိုယ်ပိုင် key တစ်ခု ဖန်တီးပါ။ ၎င်းသည် mf_ ဖြင့် စတင်ပြီး တစ်ကြိမ်သာ ပြသသောကြောင့် လုံခြုံစွာ သိမ်းထားပါ။ API keys စီမံရန် - ပထမဆုံး တောင်းဆိုမှု ပို့ပါ
Generate endpoint သို့ ပုံတစ်ပုံ တင်ပြီး ပြန်လာသော 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.
အထောက်အထားစိစစ်ခြင်း
ကာကွယ်ထားသော endpoint တစ်ခုသို့ တောင်းဆိုမှုတိုင်းတွင် ကိုယ်ပိုင် API key ပါဝင်ရမည်။ သင့်အကောင့်စာမျက်နှာတွင် key များကို မည်သည့်အချိန်မဆို ဖန်တီးခြင်း၊ အမည်ပေးခြင်းနှင့် ရုပ်သိမ်းခြင်း ပြုလုပ်နိုင်သည်။ API keys
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 key တစ်ခုစီသည် တစ်နာရီလျှင် တောင်းဆိုမှု 100 ခု ပြုလုပ်နိုင်သည်။ အထောက်အထားစိစစ်ထားသော တုံ့ပြန်မှုတိုင်းက သင်ရောက်ရှိနေသော အနေအထားကို ပြောပြသည်။
| Header | ဖော်ပြချက် |
|---|---|
X-RateLimit-Limit | လက်ရှိ အချိန်ပိုင်းအတွင်း ခွင့်ပြုထားသော တောင်းဆိုမှု အများဆုံးအရေအတွက်။ |
X-RateLimit-Remaining | လက်ရှိ အချိန်ပိုင်းအတွင်း ကျန်ရှိသော တောင်းဆိုမှုများ။ |
X-RateLimit-Reset | အချိန်ပိုင်း ပြန်လည်စတင်မည့် Unix timestamp (စက္ကန့်၊ 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.
Endpoint များ
| Endpoint | အထောက်အထားစိစစ်ရေး | ဖော်ပြချက် |
|---|---|---|
POST /generate | API key | ပြည့်စုံသော favicon package ဖန်တီးပါ။ |
GET /me | API key | သင့်အကောင့်နှင့် လက်ရှိ rate-limit အခြေအနေ။ |
GET /sizes | မရှိ | ဂျင်နရေတာက ထုတ်ပေးသော အိုင်ကွန်ဖိုင်များနှင့် အရွယ်အစားများ၏ စာရင်း။ |
GET /openapi.json | မရှိ | စက်က ဖတ်နိုင်သော OpenAPI 3.1 သတ်မှတ်ချက်။ |
favicon ပက်ကေ့ချ် ဖန်တီးရန်
/generateမူရင်းပုံတစ်ပုံမှ favicon ပက်ကေ့ချ်အပြည့်အစုံကို ဖန်တီးပေးသည်။ ပုံကို နည်းလမ်းသုံးမျိုးအနက် တစ်မျိုးဖြင့် ပို့နိုင်သည်။
| Content type | ပုံ field | ဖော်ပြချက် |
|---|---|---|
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)။ |
ထောက်ပံ့သော input ဖော်မတ်များ- PNG, JPG, WebP, AVIF, GIF, BMP, SVG နှင့် ICO။ ဖိုင်အရွယ်အစား အများဆုံး- 10 MB။
ပါရာမီတာများ
ပါရာမီတာအားလုံးသည် ရွေးချယ်ခွင့်ရှိသည်။ form field (multipart) အဖြစ် သို့မဟုတ် JSON property အဖြစ် ပို့နိုင်သည်။ မမှန်သော တန်ဖိုးများသည် မူလတန်ဖိုးသို့ ပြန်ကျသွားမည်။
| အမည် | အမျိုးအစား / အကွာအဝေး | မူလတန်ဖိုး | ဖော်ပြချက် |
|---|---|---|---|
app_name | string၊ အများဆုံး စာလုံး 60 | My Website | သင့်ဝဘ်ဆိုက် သို့မဟုတ် အက်ပ်အမည်။ manifest.json နှင့် ဥပမာစာမျက်နှာတွင် အသုံးပြုသည်။ |
short_name | string၊ အများဆုံး စာလုံး 24 | app_name ၏ ပထမ စာလုံး 12 လုံး | Android ပင်မစခရင်များတွင် အိုင်ကွန်အောက်၌ ပြသသော အမည်တို။ |
theme_color | #rrggbb | #ffffff | ဘရောက်ဇာ UI အရောင် (theme-color meta tag နှင့် manifest)။ |
tile_color | #rrggbb | theme_color နှင့် တူညီသည် | Windows Start tile များ၏ နောက်ခံအရောင်။ |
background | transparent | #rrggbb | transparent | ဘရောက်ဇာ၊ Android နှင့် Windows အိုင်ကွန်များ၏ နောက်ခံ။ |
apple_background | #rrggbb | #ffffff | Apple touch icon များနှင့် maskable icon ၏ နောက်ခံ (iOS သည် ဖောက်ထွင်းမြင်ရမှုကို မထောက်ပံ့ပါ)။ background သည် အရောင်ဖြစ်နေလျှင် လျစ်လျူရှုပြီး ထိုအရောင်ကို အသုံးပြုမည်။ |
padding | integer၊ 0–40 (%) | 0 | ပုံပတ်လည်ရှိ နေရာလွတ်၊ အိုင်ကွန်အရွယ်အစား၏ ရာခိုင်နှုန်းအဖြစ်။ |
radius | integer၊ 0–50 (%) | 0 | ထောင့်ဝိုင်းခြင်း။ 50 ဆိုလျှင် စက်ဝိုင်းဖြစ်သည်။ iOS က ကိုယ်တိုင်ဝိုင်းပေးသောကြောင့် Apple အိုင်ကွန်များတွင် မသက်ရောက်ပါ။ |
zoom | integer၊ 50–400 (%) | 100 | အိုင်ကွန်အတွင်းရှိ ပုံ၏ စကေး။ 100 ထက်ကြီးသော တန်ဖိုးများသည် ပုံကို ဖြတ်တောက်မည်။ |
offset_x, offset_y | number၊ -1 မှ 1 | 0 | ပုံကို အလျားလိုက် / ဒေါင်လိုက် ရွှေ့သည်၊ အိုင်ကွန်အရွယ်အစား၏ အပိုင်းအစအဖြစ်။ |
path | string | / | အိုင်ကွန်များ ထားမည့် သင့်ဆာဗာပေါ်ရှိ ဖိုလ်ဒါ။ HTML ကုဒ်အပိုင်းအစ၊ manifest နှင့် browserconfig တို့တွင် အသုံးပြုသည်။ |
display | standalone | fullscreen | minimal-ui | browser | standalone | manifest တွင် ရေးသားမည့် PWA ပြသမှုမုဒ်။ |
pixelated | auto | 1 | 0 | auto | pixel art အတွက် ပြတ်သားသော nearest-neighbour စကေးချဲ့ခြင်း။ auto သည် 64 px သို့မဟုတ် ထိုထက်သေးသော မူရင်းပုံများအတွက် ဖွင့်ပေးသည်။ |
maskable | 1 | 0 | 1 | Android adaptive icon များအတွက် safe-zone padding ပါသော 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 icon များ၊ Android / PWA အိုင်ကွန်များနှင့် Windows tile များ။ |
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 key ပိုင်ရှင် အသုံးပြုသူနှင့် လက်ရှိ rate-limit အခြေအနေကို ပြန်ပေးသည်။ key ကို စစ်ဆေးရန် အသုံးဝင်သည်။ အထောက်အထားစိစစ်ခြင်း လိုအပ်သည်၊ ပါရာမီတာ မလို။
ဥပမာ တောင်းဆိုမှု
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 client ဖန်တီးရန် သုံးနိုင်သည်။
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 body မမှန်ခြင်း။ |
| 401 | unauthorized | API key မရှိပါ သို့မဟုတ် မမှန်ပါ။ |
| 403 | forbidden | key ပိုင်ရှင်၏ အီးမေးလ်ကို အတည်မပြုရသေးပါ၊ သတင်းလွှာ စာရင်းသွင်းမှုကို ပိတ်ထားသည်၊ သို့မဟုတ် အကောင့်ကို ပိတ်ပင်ထားသည်။ |
| 413 | file_too_large | ပုံသည် 10 MB ထက် ကြီးနေသည်။ |
| 415 | unsupported_type | ဖိုင်အမျိုးအစား သို့မဟုတ် တောင်းဆိုမှု content type ကို မထောက်ပံ့ပါ။ |
| 422 | invalid_image | ဖိုင်ကို ပုံအဖြစ် decode မလုပ်နိုင်ပါ၊ သို့မဟုတ် ပုံ URL ကို ဒေါင်းလုဒ်မလုပ်နိုင်ပါ။ |
| 429 | rate_limited | တောင်းဆိုမှု များလွန်းသည်။ X-RateLimit-Reset အထိ စောင့်ပါ။ |
| 500 | server_error | ကျွန်ုပ်တို့ဘက်တွင် တစ်စုံတစ်ခု မှားယွင်းသွားသည်။ နောက်မှ ထပ်ကြိုးစားပါ၊ ဆက်ဖြစ်နေပါက support ကို ဆက်သွယ်ပါ။ |
ထွက်ရှိသော ဖိုင်များ
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 | crop, zoom, padding, ထောင့်ဝိုင်းခြင်း သို့မဟုတ် နောက်ခံ မပါသော SVG input အတွက်သာ | vector favicon များကို ထောက်ပံ့သော ဘရောက်ဇာများအတွက် သင့် SVG ၏ သန့်စင်ထားသော မိတ္တူ။ |
manifest.json, site.webmanifest | android | Android နှင့် ထည့်သွင်းနိုင်သော PWA များအတွက် web app manifest (အတူတူ မိတ္တူ နှစ်ခု)။ |
browserconfig.xml | ms | သင့် tile အရောင်ပါသော Windows tile ဖွဲ့စည်းပုံဖိုင်။ |
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 ဖြင့် encode လုပ်ထားသော ပုံပါသည့် JSON body (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 workflow – JSON ဖော်မတ်၊ jq ဖြင့် decode လုပ်ထားသော ဖိုင်များ-
# .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 အတွက်မဆို ရိုးရိုး shell script – 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> ဒီပလွိုင်းလုပ်ပြီးနောက် ဘရောက်ဇာ cache ကို ရှင်းပါ သို့မဟုတ် ဆိုက်ကို private window တွင် ဖွင့်ပါ – ဘရောက်ဇာများသည် favicon များကို ပြင်းထန်စွာ cache လုပ်ထားတတ်သည်။
ပြောင်းလဲမှုမှတ်တမ်း
v1
- MakeFav REST API ၏ ပထမဆုံး အများသုံး ထုတ်ဝေမှု။
- Endpoints
POST /generate,GET /me,GET /sizesandGET /openapi.json. - ZIP နှင့် JSON တုံ့ပြန်မှု ဖော်မတ်များ၊ multipart, base64 နှင့် URL ပုံ input။
- တစ်နာရီလျှင် တောင်းဆိုမှု 100 ရသော ကိုယ်ပိုင် API key များ။
ဗားရှင်း 1 သည် တည်ငြိမ်သည်- ရွေးချယ်ခွင့်ရှိသော ပါရာမီတာနှင့် field များကိုသာ ထပ်ထည့်မည်။ ဆက်စပ်မှုပျက်စေသော အပြောင်းအလဲများကို ကြိုတင်အသိပေးပြီး ဗားရှင်းအသစ်အဖြစ် ထုတ်ပြန်မည်။
အထောက်အပံ့
မေးခွန်းများ၊ bug အစီရင်ခံစာများ သို့မဟုတ် rate limit ပိုမြင့်လိုပါသလား။ ကူညီပေးရန် ဝမ်းမြောက်ပါသည်။ သင့်မက်ဆေ့ချ်တွင် တောင်းဆိုချိန်နှင့် အမှားကုဒ်ကို ထည့်ပါ – API key ကိုမူ ဘယ်တော့မှ မထည့်ပါနှင့်။