REST API · v1

เอกสารประกอบ MakeFav API

สร้างแพ็กเกจ favicon ครบชุดจากโค้ดของคุณเอง สคริปต์บิลด์ และไปป์ไลน์ CI เพียงหนึ่งคำขอก็แปลงรูปภาพใดก็ได้เป็น favicon.ico, ไอคอน Apple touch, ไอคอน Android และ PWA, web manifest และ HTML พร้อมวาง

ในหน้านี้

เริ่มต้นอย่างรวดเร็ว

MakeFav API เป็น REST API แบบ HTTPS + JSON ที่ใช้งานง่าย ทุก endpoint อยู่ภายใต้ base URL เดียวกัน:

https://makefav.com/api/v1
  1. สร้างบัญชีฟรี
    สมัครสมาชิก ยืนยันที่อยู่อีเมล และคงการสมัครรับจดหมายข่าว MakeFav ไว้ ซึ่งเป็นเงื่อนไขเดียวของแพ็กเกจฟรี
  2. สร้าง API key
    เปิดหน้า API keys ในบัญชีของคุณและสร้างคีย์ส่วนตัว คีย์จะขึ้นต้นด้วย mf_ และแสดงเพียงครั้งเดียว โปรดเก็บไว้อย่างปลอดภัย จัดการ API keys
  3. ส่งคำขอแรกของคุณ
    อัปโหลดรูปภาพไปยัง endpoint 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.

การยืนยันตัวตน

ทุกคำขอไปยัง endpoint ที่ได้รับการป้องกันต้องมี API 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
คีย์เป็นของผู้ใช้ที่ยืนยันอีเมลแล้วและสมัครรับจดหมายข่าวอยู่ (เงื่อนไขของแพ็กเกจฟรี) หากยังไม่ได้ยืนยันอีเมล ปิดการรับจดหมายข่าว หรือบัญชีถูกแบน ทุกคำขอจะส่งคืน 403 Forbidden
โปรดดูแล API key เหมือนรหัสผ่าน เก็บไว้บนเซิร์ฟเวอร์หรือใน CI secrets ห้ามใส่ในโค้ดบนเบราว์เซอร์ แอปมือถือ หรือที่เก็บโค้ดสาธารณะ และให้เพิกถอนคีย์ทันทีหากรั่วไหล

Missing or invalid keys return 401 Unauthorized. The GET /sizes and GET /openapi.json endpoints do not require a key.

ขีดจำกัดอัตราการเรียก

โดยค่าเริ่มต้น API key แต่ละอันเรียกใช้ได้ 100 คำขอต่อชั่วโมง ทุกการตอบกลับที่ยืนยันตัวตนแล้วจะบอกสถานะการใช้งานของคุณ:

ส่วนหัวคำอธิบาย
X-RateLimit-Limitจำนวนคำขอสูงสุดที่อนุญาตในช่วงเวลาปัจจุบัน
X-RateLimit-Remainingจำนวนคำขอที่เหลือในช่วงเวลาปัจจุบัน
X-RateLimit-ResetUnix 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 /generateAPI keyสร้างแพ็กเกจ favicon ครบชุด
GET /meAPI keyบัญชีของคุณและสถานะขีดจำกัดอัตราการเรียกปัจจุบัน
GET /sizesไม่มีรายการไฟล์ไอคอนและขนาดทั้งหมดที่ตัวสร้างผลิตขึ้น
GET /openapi.jsonไม่มีสเปก OpenAPI 3.1 ที่เครื่องอ่านได้

สร้างแพ็กเกจ favicon

POST/generate

สร้างแพ็กเกจ favicon ครบชุดจากรูปภาพต้นฉบับหนึ่งรูป ส่งรูปภาพได้สามวิธี:

ประเภทเนื้อหาฟิลด์รูปภาพคำอธิบาย
multipart/form-dataimageอัปโหลดไฟล์ แนะนำ เป็นตัวเลือกที่มีประสิทธิภาพที่สุด
application/jsonimage_base64Base64-encoded image, either raw base64 or a data URL such as data:image/png;base64,iVBOR….
application/jsonimage_urlURL แบบ http หรือ https สาธารณะของรูปภาพ เซิร์ฟเวอร์จะดาวน์โหลดรูปภาพนั้น (สูงสุด 10 MB)

รูปแบบไฟล์อินพุตที่รองรับ: PNG, JPG, WebP, AVIF, GIF, BMP, SVG และ ICO ขนาดไฟล์สูงสุด: 10 MB

พารามิเตอร์

พารามิเตอร์ทั้งหมดเป็นตัวเลือก ส่งเป็นฟิลด์ฟอร์ม (multipart) หรือคุณสมบัติ JSON ก็ได้ ค่าที่ไม่ถูกต้องจะใช้ค่าเริ่มต้นแทน

ชื่อประเภท / ช่วงค่าค่าเริ่มต้นคำอธิบาย
app_nameสตริง สูงสุด 60 ตัวอักษรMy Websiteชื่อเว็บไซต์หรือแอปของคุณ ใช้ใน manifest.json และหน้าตัวอย่าง
short_nameสตริง สูงสุด 24 ตัวอักษร12 ตัวอักษรแรกของ app_nameชื่อสั้นที่แสดงใต้ไอคอนบนหน้าจอหลักของ Android
theme_color#rrggbb#ffffffสีของ UI เบราว์เซอร์ (แท็ก meta theme-color และ manifest)
tile_color#rrggbbเหมือนกับ theme_colorสีพื้นหลังของไทล์เริ่มต้นของ Windows
backgroundtransparent | #rrggbbtransparentพื้นหลังของไอคอนเบราว์เซอร์ 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 ถึง 10เลื่อนรูปภาพในแนวนอน / แนวตั้ง เป็นเศษส่วนของขนาดไอคอน
pathสตริง/โฟลเดอร์บนเซิร์ฟเวอร์ของคุณที่จะเก็บไอคอน ใช้ในโค้ด HTML, manifest และ browserconfig
displaystandalone | fullscreen | minimal-ui | browserstandaloneโหมดการแสดงผลของ PWA ที่เขียนลงใน manifest
pixelatedauto | 1 | 0autoการปรับขนาดแบบ nearest-neighbour ที่คมชัดสำหรับพิกเซลอาร์ต ค่า auto จะเปิดใช้งานกับต้นฉบับขนาด 64 px หรือเล็กกว่า
maskable1 | 01สร้างไฟล์ maskable-icon-512x512.png พร้อมระยะขอบเขตปลอดภัยสำหรับไอคอนแบบปรับได้ของ Android ด้วย
ico_sizesรายการคั่นด้วยจุลภาค: 16, 24, 32, 48, 64, 128, 25616,32,48ขนาดที่ฝังอยู่ใน favicon.ico
groupsรายการคั่นด้วยจุลภาค: favicon, apple, android, msfavicon,apple,android,msชุดไอคอนที่จะสร้าง: favicon สำหรับเบราว์เซอร์, Apple touch icon, ไอคอน Android / PWA และไทล์ Windows
formatzip | jsonzipรูปแบบการตอบกลับ – ดูด้านล่าง

การตอบกลับ

format=zip
Binary ZIP archive with Content-Type: application/zip and Content-Disposition: attachment. Default.
format=json
JSON object with the package id (32 hex characters), the html snippet for your <head> and a files array; each file has name, mime, size (bytes) and base64 contents.

ตัวอย่างคำขอ – 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>

ตัวอย่างคำขอ – JSON พร้อม URL รูปภาพ, ตอบกลับเป็น 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…"}
  ]
}

ดูข้อมูลบัญชีของคุณ

GET/me

ส่งคืนข้อมูลผู้ใช้เจ้าของ API key และสถานะ 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}
}

แสดงรายการขนาดไอคอน

GET/sizes

Returns 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

GET/openapi.json

ส่งคืนคำอธิบาย OpenAPI 3.1 ของ API นี้ ไม่ต้องยืนยันตัวตน นำเข้าใน Postman, Insomnia หรือ Swagger UI หรือใช้สร้าง client แบบมี type สำหรับภาษาของคุณ

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รหัสข้อผิดพลาดความหมาย
400bad_requestคำขอมีรูปแบบไม่ถูกต้อง เช่น ไม่ได้ส่งรูปภาพ หรือเนื้อหา JSON ไม่ถูกต้อง
401unauthorizedไม่มี API key หรือ API key ไม่ถูกต้อง
403forbiddenอีเมลของเจ้าของคีย์ยังไม่ได้รับการยืนยัน ปิดการสมัครรับจดหมายข่าว หรือบัญชีถูกแบน
413file_too_largeรูปภาพมีขนาดใหญ่กว่า 10 MB
415unsupported_typeไม่รองรับประเภทไฟล์หรือ content type ของคำขอ
422invalid_imageไม่สามารถถอดรหัสไฟล์เป็นรูปภาพได้ หรือดาวน์โหลดรูปภาพจาก URL ไม่ได้
429rate_limitedคำขอมากเกินไป โปรดรอจนถึงเวลา X-RateLimit-Reset
500server_errorเกิดข้อผิดพลาดที่ฝั่งเรา โปรดลองอีกครั้งภายหลัง หากยังเป็นอยู่โปรดติดต่อฝ่ายสนับสนุน

ไฟล์เอาต์พุต

With all groups enabled, a package contains the files below. Files from disabled groups are left out.

ไฟล์ขนาดกลุ่ม
favicon.ico16, 32, 48 (กำหนดค่าได้)เสมอ
favicon-16x16.png16 × 16favicon
favicon-32x32.png32 × 32favicon
favicon-96x96.png96 × 96favicon
apple-icon-57x57.png57 × 57apple
apple-icon-60x60.png60 × 60apple
apple-icon-72x72.png72 × 72apple
apple-icon-76x76.png76 × 76apple
apple-icon-114x114.png114 × 114apple
apple-icon-120x120.png120 × 120apple
apple-icon-144x144.png144 × 144apple
apple-icon-152x152.png152 × 152apple
apple-icon-180x180.png180 × 180apple
apple-icon.png192 × 192apple
apple-icon-precomposed.png192 × 192apple
apple-touch-icon.png180 × 180apple
android-icon-36x36.png36 × 36android
android-icon-48x48.png48 × 48android
android-icon-72x72.png72 × 72android
android-icon-96x96.png96 × 96android
android-icon-144x144.png144 × 144android
android-icon-192x192.png192 × 192android
android-icon-512x512.png512 × 512android
web-app-manifest-192x192.png192 × 192android
web-app-manifest-512x512.png512 × 512android
maskable-icon-512x512.png512 × 512android
ms-icon-70x70.png70 × 70ms
ms-icon-144x144.png144 × 144ms
ms-icon-150x150.png150 × 150ms
ms-icon-310x310.png310 × 310ms

ไฟล์เพิ่มเติม

ไฟล์รวมอยู่ด้วยคำอธิบาย
favicon.svgเฉพาะอินพุต SVG ที่ไม่มีการครอป ซูม ระยะขอบ มุม หรือพื้นหลังสำเนา SVG ของคุณที่ผ่านการทำความสะอาดแล้ว สำหรับเบราว์เซอร์ที่รองรับ favicon แบบเวกเตอร์
manifest.json, site.webmanifestandroidWeb app manifest สำหรับ Android และ PWA ที่ติดตั้งได้ (สำเนาเหมือนกันสองชุด)
browserconfig.xmlmsไฟล์กำหนดค่าไทล์ Windows พร้อมสีไทล์ของคุณ
readme-makefav.txtเสมอวิธีติดตั้งพร้อมโค้ด HTML สำหรับ <head> ของคุณอยู่ท้ายสุด

ตัวอย่างโค้ด

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; }

JSON body พร้อมรูปภาพที่เข้ารหัส base64 (ต้องใช้ 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; }

การใช้งาน 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 /sizes and GET /openapi.json.
  • รูปแบบการตอบกลับ ZIP และ JSON รองรับอินพุตรูปภาพแบบ multipart, base64 และ URL
  • API key ส่วนตัว จำกัด 100 คำขอต่อชั่วโมง

เวอร์ชัน 1 มีความเสถียร: เราจะเพิ่มเฉพาะพารามิเตอร์และฟิลด์ที่เป็นทางเลือกเท่านั้น การเปลี่ยนแปลงที่ไม่รองรับของเดิมจะออกเป็นเวอร์ชันใหม่พร้อมแจ้งล่วงหน้า

ช่วยเหลือ

มีคำถาม พบข้อบกพร่อง หรือต้องการ rate limit ที่สูงขึ้น? ยินดีให้ความช่วยเหลือ โปรดระบุเวลาของคำขอและรหัสข้อผิดพลาดในข้อความ และห้ามส่ง API key ของคุณเด็ดขาด