ساخت QR Code با قابلیت شخصیسازی
با استفاده از این وب سرویس میتوانید انواع QR Code را برای لینک، متن، وایفای، اطلاعات مخاطب، ایمیل، پیامک، موقعیت جغرافیایی و رویدادهای تقویم ایجاد کنید.
مشخصات
| مشخصه | مقدار |
|---|---|
| دستهبندی | ابزار |
| وضعیت | فعال |
| نسخه API | apis-1 |
| فرمت پاسخ | JSON |
| آدرس پایه | https://open.nestapi.ir |
| مسیر | /apis-1/qrcode |
| لینک کامل | https://open.nestapi.ir/apis-1/qrcode |
متدهای HTTP
| متد | مسیر | نوع ورودی |
|---|---|---|
GET | /apis-1/qrcode | Query String |
پارامترها
تمام پارامترهای زیر از طریق Query String ارسال میشوند.
پارامترهای اصلی
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
type | string | خیر | url | نوع محتوای QR Code: url، text، wifi، vcard، email، sms، tel، geo یا calendar |
پارامترهای نوع URL
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
url | string | بله | — | لینک موردنظر برای ساخت QR Code (حداکثر 2048 کاراکتر) |
پارامترهای نوع Text
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
text | string | بله | — | متن موردنظر برای ساخت QR Code (حداکثر 4000 کاراکتر) |
پارامترهای نوع WiFi
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
wifi_ssid | string | بله | — | نام شبکه وایفای |
wifi_password | string | خیر | رشته خالی | رمز عبور شبکه |
wifi_auth | string | خیر | WPA | نوع احراز هویت: WPA، WEP یا nopass |
wifi_hidden | boolean | خیر | false | مخفی بودن شبکه |
پارامترهای نوع vCard
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
vcard_fn | string | بله | — | نام مخاطب |
vcard_n | string | خیر | — | نام خانوادگی و اطلاعات نام |
vcard_tel | string | خیر | — | شماره تلفن |
vcard_email | string | خیر | — | آدرس ایمیل |
vcard_org | string | خیر | — | نام سازمان |
vcard_title | string | خیر | — | عنوان شغلی |
vcard_url | string | خیر | — | آدرس وبسایت |
vcard_adr | string | خیر | — | آدرس مخاطب |
vcard_note | string | خیر | — | یادداشت مخاطب |
پارامترهای نوع Email
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
email_to | string | بله | — | آدرس ایمیل گیرنده |
email_subject | string | خیر | — | موضوع ایمیل |
email_body | string | خیر | — | متن ایمیل |
پارامترهای نوع SMS
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
sms_phone | string | بله | — | شماره تلفن گیرنده |
sms_body | string | خیر | — | متن پیامک |
پارامترهای نوع Telephone
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
tel_phone | string | بله | — | شماره تلفن موردنظر |
پارامترهای نوع Geo
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
geo_lat | number | بله | — | عرض جغرافیایی |
geo_lon | number | بله | — | طول جغرافیایی |
geo_zoom | integer | خیر | — | میزان بزرگنمایی نقشه |
پارامترهای نوع Calendar
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
cal_start | string | بله | — | تاریخ و زمان شروع رویداد (ISO 8601) |
cal_end | string | خیر | — | تاریخ و زمان پایان رویداد |
cal_summary | string | بله | — | عنوان رویداد |
cal_description | string | خیر | — | توضیحات رویداد |
cal_location | string | خیر | — | مکان برگزاری رویداد |
cal_uid | string | خیر | — | شناسه رویداد |
پارامترهای تنظیمات ظاهری
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
width | integer | خیر | 512 | عرض تصویر (64 تا 4096 پیکسل) |
margin | integer | خیر | 4 | حاشیه QR Code (0 تا 100) |
color_dark | string | خیر | #000000 | رنگ نقاط QR Code |
color_light | string | خیر | #ffffff | رنگ پسزمینه QR Code |
ecl | string | خیر | M | سطح تصحیح خطا: L، M، Q یا H |
پارامترهای لوگو
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
logo | string | خیر | — | لینک تصویر یا Base64 Data URI لوگو |
logo_width | integer | خیر | 20٪ عرض تصویر | عرض لوگو (حداکثر 1000) |
logo_height | integer | خیر | 20٪ عرض تصویر | ارتفاع لوگو (حداکثر 1000) |
logo_bg | string | خیر | — | رنگ پسزمینه لوگو |
پارامترهای خروجی و کش
| نام | نوع | الزامی | پیشفرض | توضیحات |
|---|---|---|---|---|
format | string | خیر | png | فرمت خروجی: png، svg، jpeg، jpg یا webp |
quality | integer | خیر | 90 | کیفیت تصویر JPEG و WebP (1 تا 100) |
nocache | boolean | خیر | false | غیرفعال کردن بررسی کش و تولید مجدد فایل |
نکته: مقادیر پیشفرض عرض لوگو و ارتفاع لوگو در کد، بهترتیب از 20 درصد عرض تصویر محاسبه میشوند؛ اندازه نهایی لوگو حداکثر 30 درصد عرض تصویر خواهد بود.
نمونه درخواست
ساخت QR Code برای URL
لینک مستقیم
GET https://open.nestapi.ir/apis-1/qrcode?url=https://nestapi.ir
نمونه کد
- cURL
- PHP
- Python
- JavaScript
curl -X GET "https://open.nestapi.ir/apis-1/qrcode?url=https://nestapi.ir"
<?php
// composer require nestapi/nestapi
require 'vendor/autoload.php';
use NestApi\NestApi;
use NestApi\Exception\ApiException;
use NestApi\Exception\TransportException;
$api = new NestApi();
try {
$response = $api->qrcode(url: 'https://nestapi.ir');
print_r($response->data);
} catch (ApiException $e) {
// Error reported by the API (validation, not found, rate limit, ...)
echo $e->getMessage();
} catch (TransportException $e) {
// Network error or unusable response; not a subclass of ApiException
echo 'Network error: ' . $e->getMessage();
}
# pip install nestapi-py
from nestapi import ApiError, NestApi, TransportError
with NestApi() as api:
try:
response = api.qrcode(url="https://nestapi.ir")
print(response.data)
except ApiError as e:
# Error reported by the API (validation, not found, rate limit, ...)
print(e.error_code, e)
except TransportError as e:
# Network error or unusable response; not a subclass of ApiError
print("Network error:", e)
// npm install @devh3n/nestapi
import { ApiError, NestApi, TransportError } from "@devh3n/nestapi";
const api = new NestApi();
try {
const response = await api.qrcode({ url: "https://nestapi.ir" });
console.log(response.data);
} catch (error) {
if (error instanceof ApiError) {
// Error reported by the API (validation, not found, rate limit, ...)
console.error(error.errorCode, error.message);
} else if (error instanceof TransportError) {
// Network error or unusable response; not a subclass of ApiError
console.error("Network error:", error.message);
}
}
ساخت QR Code برای متن
لینک مستقیم
GET https://open.nestapi.ir/apis-1/qrcode?type=text&text=Hello%20World
نمونه کد
- cURL
- PHP
- Python
- JavaScript
curl -X GET "https://open.nestapi.ir/apis-1/qrcode?type=text&text=Hello%20World"
<?php
// composer require nestapi/nestapi
require 'vendor/autoload.php';
use NestApi\NestApi;
use NestApi\Exception\ApiException;
use NestApi\Exception\TransportException;
$api = new NestApi();
try {
$response = $api->qrcode(type: 'text', text: 'Hello World');
print_r($response->data);
} catch (ApiException $e) {
// Error reported by the API (validation, not found, rate limit, ...)
echo $e->getMessage();
} catch (TransportException $e) {
// Network error or unusable response; not a subclass of ApiException
echo 'Network error: ' . $e->getMessage();
}
# pip install nestapi-py
from nestapi import ApiError, NestApi, TransportError
with NestApi() as api:
try:
response = api.qrcode(type="text", text="Hello World")
print(response.data)
except ApiError as e:
# Error reported by the API (validation, not found, rate limit, ...)
print(e.error_code, e)
except TransportError as e:
# Network error or unusable response; not a subclass of ApiError
print("Network error:", e)
// npm install @devh3n/nestapi
import { ApiError, NestApi, TransportError } from "@devh3n/nestapi";
const api = new NestApi();
try {
const response = await api.qrcode({ type: "text", text: "Hello World" });
console.log(response.data);
} catch (error) {
if (error instanceof ApiError) {
// Error reported by the API (validation, not found, rate limit, ...)
console.error(error.errorCode, error.message);
} else if (error instanceof TransportError) {
// Network error or unusable response; not a subclass of ApiError
console.error("Network error:", error.message);
}
}
ساخت QR Code برای WiFi
لینک مستقیم
GET https://open.nestapi.ir/apis-1/qrcode?type=wifi&wifi_ssid=MyNetwork&wifi_password=12345678&wifi_auth=WPA
نمونه کد
- cURL
- PHP
- Python
- JavaScript
curl -X GET "https://open.nestapi.ir/apis-1/qrcode?type=wifi&wifi_ssid=MyNetwork&wifi_password=12345678&wifi_auth=WPA"
<?php
// composer require nestapi/nestapi
require 'vendor/autoload.php';
use NestApi\NestApi;
use NestApi\Exception\ApiException;
use NestApi\Exception\TransportException;
$api = new NestApi();
try {
$response = $api->qrcode(
type: 'wifi',
wifi_ssid: 'MyNetwork',
wifi_password: '12345678',
wifi_auth: 'WPA',
);
print_r($response->data);
} catch (ApiException $e) {
// Error reported by the API (validation, not found, rate limit, ...)
echo $e->getMessage();
} catch (TransportException $e) {
// Network error or unusable response; not a subclass of ApiException
echo 'Network error: ' . $e->getMessage();
}
# pip install nestapi-py
from nestapi import ApiError, NestApi, TransportError
with NestApi() as api:
try:
response = api.qrcode(
type="wifi",
wifi_ssid="MyNetwork",
wifi_password="12345678",
wifi_auth="WPA",
)
print(response.data)
except ApiError as e:
# Error reported by the API (validation, not found, rate limit, ...)
print(e.error_code, e)
except TransportError as e:
# Network error or unusable response; not a subclass of ApiError
print("Network error:", e)
// npm install @devh3n/nestapi
import { ApiError, NestApi, TransportError } from "@devh3n/nestapi";
const api = new NestApi();
try {
const response = await api.qrcode({
type: "wifi",
wifi_ssid: "MyNetwork",
wifi_password: "12345678",
wifi_auth: "WPA",
});
console.log(response.data);
} catch (error) {
if (error instanceof ApiError) {
// Error reported by the API (validation, not found, rate limit, ...)
console.error(error.errorCode, error.message);
} else if (error instanceof TransportError) {
// Network error or unusable response; not a subclass of ApiError
console.error("Network error:", error.message);
}
}
ساخت QR Code برای مخاطب
لینک مستقیم
GET https://open.nestapi.ir/apis-1/qrcode?type=vcard&vcard_fn=John%20Doe&vcard_tel=09123456789&[email protected]
نمونه کد
- cURL
- PHP
- Python
- JavaScript
curl -X GET "https://open.nestapi.ir/apis-1/qrcode?type=vcard&vcard_fn=John%20Doe&vcard_tel=09123456789&[email protected]"
<?php
// composer require nestapi/nestapi
require 'vendor/autoload.php';
use NestApi\NestApi;
use NestApi\Exception\ApiException;
use NestApi\Exception\TransportException;
$api = new NestApi();
try {
$response = $api->qrcode(
type: 'vcard',
vcard_fn: 'John Doe',
vcard_tel: '09123456789',
);
print_r($response->data);
} catch (ApiException $e) {
// Error reported by the API (validation, not found, rate limit, ...)
echo $e->getMessage();
} catch (TransportException $e) {
// Network error or unusable response; not a subclass of ApiException
echo 'Network error: ' . $e->getMessage();
}
# pip install nestapi-py
from nestapi import ApiError, NestApi, TransportError
with NestApi() as api:
try:
response = api.qrcode(
type="vcard",
vcard_fn="John Doe",
vcard_tel="09123456789",
)
print(response.data)
except ApiError as e:
# Error reported by the API (validation, not found, rate limit, ...)
print(e.error_code, e)
except TransportError as e:
# Network error or unusable response; not a subclass of ApiError
print("Network error:", e)
// npm install @devh3n/nestapi
import { ApiError, NestApi, TransportError } from "@devh3n/nestapi";
const api = new NestApi();
try {
const response = await api.qrcode({
type: "vcard",
vcard_fn: "John Doe",
vcard_tel: "09123456789",
});
console.log(response.data);
} catch (error) {
if (error instanceof ApiError) {
// Error reported by the API (validation, not found, rate limit, ...)
console.error(error.errorCode, error.message);
} else if (error instanceof TransportError) {
// Network error or unusable response; not a subclass of ApiError
console.error("Network error:", error.message);
}
}
ساخت QR Code برای ایمیل
لینک مستقیم
GET https://open.nestapi.ir/apis-1/qrcode?type=email&[email protected]&email_subject=Hello&email_body=Test
نمونه کد
- cURL
- PHP
- Python
- JavaScript
curl -X GET "https://open.nestapi.ir/apis-1/qrcode?type=email&[email protected]&email_subject=Hello&email_body=Test"
<?php
// composer require nestapi/nestapi
require 'vendor/autoload.php';
use NestApi\NestApi;
use NestApi\Exception\ApiException;
use NestApi\Exception\TransportException;
$api = new NestApi();
try {
$response = $api->qrcode(
type: 'email',
email_subject: 'Hello',
email_body: 'Test',
);
print_r($response->data);
} catch (ApiException $e) {
// Error reported by the API (validation, not found, rate limit, ...)
echo $e->getMessage();
} catch (TransportException $e) {
// Network error or unusable response; not a subclass of ApiException
echo 'Network error: ' . $e->getMessage();
}
# pip install nestapi-py
from nestapi import ApiError, NestApi, TransportError
with NestApi() as api:
try:
response = api.qrcode(
type="email",
email_subject="Hello",
email_body="Test",
)
print(response.data)
except ApiError as e:
# Error reported by the API (validation, not found, rate limit, ...)
print(e.error_code, e)
except TransportError as e:
# Network error or unusable response; not a subclass of ApiError
print("Network error:", e)
// npm install @devh3n/nestapi
import { ApiError, NestApi, TransportError } from "@devh3n/nestapi";
const api = new NestApi();
try {
const response = await api.qrcode({
type: "email",
email_subject: "Hello",
email_body: "Test",
});
console.log(response.data);
} catch (error) {
if (error instanceof ApiError) {
// Error reported by the API (validation, not found, rate limit, ...)
console.error(error.errorCode, error.message);
} else if (error instanceof TransportError) {
// Network error or unusable response; not a subclass of ApiError
console.error("Network error:", error.message);
}
}
ساخت QR Code برای موقعیت جغرافیایی
لینک مستقیم
GET https://open.nestapi.ir/apis-1/qrcode?type=geo&geo_lat=35.6892&geo_lon=51.3890&geo_zoom=15
نمونه کد
- cURL
- PHP
- Python
- JavaScript
curl -X GET "https://open.nestapi.ir/apis-1/qrcode?type=geo&geo_lat=35.6892&geo_lon=51.3890&geo_zoom=15"
<?php
// composer require nestapi/nestapi
require 'vendor/autoload.php';
use NestApi\NestApi;
use NestApi\Exception\ApiException;
use NestApi\Exception\TransportException;
$api = new NestApi();
try {
$response = $api->qrcode(
type: 'geo',
geo_lat: '35.6892',
geo_lon: '51.3890',
geo_zoom: '15',
);
print_r($response->data);
} catch (ApiException $e) {
// Error reported by the API (validation, not found, rate limit, ...)
echo $e->getMessage();
} catch (TransportException $e) {
// Network error or unusable response; not a subclass of ApiException
echo 'Network error: ' . $e->getMessage();
}
# pip install nestapi-py
from nestapi import ApiError, NestApi, TransportError
with NestApi() as api:
try:
response = api.qrcode(
type="geo",
geo_lat="35.6892",
geo_lon="51.3890",
geo_zoom="15",
)
print(response.data)
except ApiError as e:
# Error reported by the API (validation, not found, rate limit, ...)
print(e.error_code, e)
except TransportError as e:
# Network error or unusable response; not a subclass of ApiError
print("Network error:", e)
// npm install @devh3n/nestapi
import { ApiError, NestApi, TransportError } from "@devh3n/nestapi";
const api = new NestApi();
try {
const response = await api.qrcode({
type: "geo",
geo_lat: "35.6892",
geo_lon: "51.3890",
geo_zoom: "15",
});
console.log(response.data);
} catch (error) {
if (error instanceof ApiError) {
// Error reported by the API (validation, not found, rate limit, ...)
console.error(error.errorCode, error.message);
} else if (error instanceof TransportError) {
// Network error or unusable response; not a subclass of ApiError
console.error("Network error:", error.message);
}
}
ساخت QR Code با لوگو و رنگ سفارشی
لینک مستقیم
GET https://open.nestapi.ir/apis-1/qrcode?url=https://nestapi.ir&width=1024&color_dark=%23ff6f00&color_light=%23ffffff&logo=https://example.com/logo.png&format=png
نمونه کد
- cURL
- PHP
- Python
- JavaScript
curl -X GET "https://open.nestapi.ir/apis-1/qrcode?url=https://nestapi.ir&width=1024&color_dark=%23ff6f00&color_light=%23ffffff&logo=https://example.com/logo.png&format=png"
<?php
// composer require nestapi/nestapi
require 'vendor/autoload.php';
use NestApi\NestApi;
use NestApi\Exception\ApiException;
use NestApi\Exception\TransportException;
$api = new NestApi();
try {
$response = $api->qrcode(
url: 'https://nestapi.ir',
width: '1024',
color_dark: '#ff6f00',
color_light: '#ffffff',
logo: 'https://example.com/logo.png',
format: 'png',
);
print_r($response->data);
} catch (ApiException $e) {
// Error reported by the API (validation, not found, rate limit, ...)
echo $e->getMessage();
} catch (TransportException $e) {
// Network error or unusable response; not a subclass of ApiException
echo 'Network error: ' . $e->getMessage();
}
# pip install nestapi-py
from nestapi import ApiError, NestApi, TransportError
with NestApi() as api:
try:
response = api.qrcode(
url="https://nestapi.ir",
width="1024",
color_dark="#ff6f00",
color_light="#ffffff",
logo="https://example.com/logo.png",
format="png",
)
print(response.data)
except ApiError as e:
# Error reported by the API (validation, not found, rate limit, ...)
print(e.error_code, e)
except TransportError as e:
# Network error or unusable response; not a subclass of ApiError
print("Network error:", e)
// npm install @devh3n/nestapi
import { ApiError, NestApi, TransportError } from "@devh3n/nestapi";
const api = new NestApi();
try {
const response = await api.qrcode({
url: "https://nestapi.ir",
width: "1024",
color_dark: "#ff6f00",
color_light: "#ffffff",
logo: "https://example.com/logo.png",
format: "png",
});
console.log(response.data);
} catch (error) {
if (error instanceof ApiError) {
// Error reported by the API (validation, not found, rate limit, ...)
console.error(error.errorCode, error.message);
} else if (error instanceof TransportError) {
// Network error or unusable response; not a subclass of ApiError
console.error("Network error:", error.message);
}
}
کدهای خطا
| کد | وضعیت | علت |
|---|---|---|
NOT_FOUND | 404 | مسیر وجود ندارد، یا متد روی آن ثبت نشده |
PARAM_NOT_FOUND | 400 | پارامتر لازم ارسال نشده |
VALIDATION_ERROR | 422 | پارامتر آمده ولی نوع، قالب یا بازهاش نادرست است |
LOGO_FETCH_FAILED | 502 | دریافت لوگو از آدرس خارجی با خطا مواجه شده است |