logo NexAPI
← 返回 API 列表

API 详情

二维码生成

根据 text 生成二维码返回 PNG。

GET 公开 API 分类:工具 限流 30 / 分钟

完整请求 URL

可直接在浏览器、终端或调试工具中调用

https://api.avrinbai.cn/api/tools/qrcode

接口说明

二维码 PNG

生成 PNG 图片(Content-Type: image/png)。

请求

GET /api/tools/qrcode?text=内容&...

参数

参数 必填 默认 说明
text help help 时返回 JSON 说明;否则为编码内容
e H 容错 L / M / Q / H
p 3 点大小 1–10
m 6 白边 0–20

成功时为 PNG 二进制,非 JSON。

在线调试

通过本站代发请求。GET 时会把 JSON 中的键值作为 Query,非 GET 时作为 JSON Body.

示例代码

// GET https://api.avrinbai.cn/api/tools/qrcode
const payload = {
    "e": "H",
    "m": 6,
    "p": 4,
    "text": "https:\/\/example.com"
};

const url = new URL('https://api.avrinbai.cn/api/tools/qrcode');
url.search = new URLSearchParams(payload).toString();

const headers = {
  "Accept": "application/json",
  "Content-Type": "application/json",

};

const res = await fetch(url.toString(), {
  method: "GET",
  headers,

});

// 兼容返回 JSON / 纯文本 / 二进制
const contentType = res.headers.get("content-type") || "";
if (contentType.includes("application/json")) {
  console.log(await res.json());
} else {
  console.log(await res.text());
}
// GET https://api.avrinbai.cn/api/tools/qrcode
import axios from "axios";

const payload = {
    "e": "H",
    "m": 6,
    "p": 4,
    "text": "https:\/\/example.com"
};

const headers = {
  "Accept": "application/json",

};

const url = "https://api.avrinbai.cn/api/tools/qrcode";

const res = await axios.request({
  url,
  method: "GET",
  headers,
  params: payload,
  // responseType: "arraybuffer", // 若接口返回图片/音视频,可按需开启
});

console.log(res.status, res.data);
# GET https://api.avrinbai.cn/api/tools/qrcode
import requests

payload = {
    "e": "H",
    "m": 6,
    "p": 4,
    "text": "https:\/\/example.com"
}

headers = {
    "Accept": "application/json",
}
# headers["X-API-Key"] = "YOUR_API_KEY"

res = requests.request(
    "GET",
    "https://api.avrinbai.cn/api/tools/qrcode",
    headers=headers,
    params=payload,
    timeout=25,
)

print(res.status_code)
print(res.text)
// GET https://api.avrinbai.cn/api/tools/qrcode
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    payload := map[string]any{
    "e": "H",
    "m": 6,
    "p": 4,
    "text": "https:\/\/example.com"
}

    u, _ := url.Parse("https://api.avrinbai.cn/api/tools/qrcode")
q := u.Query()
q.Set("e", "H")
q.Set("m", "6")
q.Set("p", "4")
q.Set("text", "https:\/\/example.com")
u.RawQuery = q.Encode()
targetURL := u.String()

    var body io.Reader = nil

    req, _ := http.NewRequest("GET", targetURL, body)
    req.Header.Set("Accept", "application/json")
    req.Header.Set("Content-Type", "application/json")
    // req.Header.Set("X-API-Key", "YOUR_API_KEY")

    client := &http.Client{}
    res, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer res.Body.Close()

    raw, _ := io.ReadAll(res.Body)
    fmt.Println(res.StatusCode)
    fmt.Println(string(raw))
}
// GET https://api.avrinbai.cn/api/tools/qrcode
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "net/url"
)

func main() {
    payload := map[string]any{
    "e": "H",
    "m": 6,
    "p": 4,
    "text": "https:\/\/example.com"
}

    u, _ := url.Parse("https://api.avrinbai.cn/api/tools/qrcode")
q := u.Query()
q.Set("payload", "{\"e\":\"H\",\"m\":6,\"p\":4,\"text\":\"https:\/\/example.com\"}")
u.RawQuery = q.Encode()
targetURL := u.String()

    var body io.Reader = nil

    req, _ := http.NewRequest("GET", targetURL, body)
    req.Header.Set("Accept", "application/json")
    req.Header.Set("Content-Type", "application/json")
    // req.Header.Set("X-API-Key", "YOUR_API_KEY")

    client := &http.Client{}
    res, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer res.Body.Close()

    raw, _ := io.ReadAll(res.Body)
    fmt.Println(res.StatusCode)
    fmt.Println(string(raw))
}
// GET https://api.avrinbai.cn/api/tools/qrcode
import okhttp3.*;

public class Demo {
  public static void main(String[] args) throws Exception {
    OkHttpClient client = new OkHttpClient();
    String payloadJson = {"e":"H","m":6,"p":4,"text":"https:\/\/example.com"};

    HttpUrl.Builder urlBuilder = HttpUrl.parse("https://api.avrinbai.cn/api/tools/qrcode").newBuilder();
urlBuilder.addQueryParameter("e", "H");
urlBuilder.addQueryParameter("m", "6");
urlBuilder.addQueryParameter("p", "4");
urlBuilder.addQueryParameter("text", "https:\/\/example.com");
String url = urlBuilder.build().toString();
    RequestBody body = null;

    Request request = new Request.Builder()
        .url(url)
        .method("GET", body)
        .addHeader("Accept", "application/json")
        .addHeader("Content-Type", "application/json")
        // .addHeader("X-API-Key", "YOUR_API_KEY")
        .build();

    try (Response response = client.newCall(request).execute()) {
      System.out.println(response.code());
      System.out.println(response.body() != null ? response.body().string() : "");
    }
  }
}
// GET https://api.avrinbai.cn/api/tools/qrcode
import okhttp3.*;

public class Demo {
  public static void main(String[] args) throws Exception {
    OkHttpClient client = new OkHttpClient();
    String payloadJson = {"e":"H","m":6,"p":4,"text":"https:\/\/example.com"};

    HttpUrl.Builder urlBuilder = HttpUrl.parse("https://api.avrinbai.cn/api/tools/qrcode").newBuilder();
urlBuilder.addQueryParameter("payload", payloadJson);
String url = urlBuilder.build().toString();
    RequestBody body = null;

    Request request = new Request.Builder()
        .url(url)
        .method("GET", body)
        .addHeader("Accept", "application/json")
        .addHeader("Content-Type", "application/json")
        // .addHeader("X-API-Key", "YOUR_API_KEY")
        .build();

    try (Response response = client.newCall(request).execute()) {
      System.out.println(response.code());
      System.out.println(response.body() != null ? response.body().string() : "");
    }
  }
}
// GET https://api.avrinbai.cn/api/tools/qrcode
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var payloadJson = {"e":"H","m":6,"p":4,"text":"https:\/\/example.com"};

        using var client = new HttpClient();
        var query = string.Join("&", new[] { "e" + "=" + Uri.EscapeDataString("H"), "m" + "=" + Uri.EscapeDataString("6"), "p" + "=" + Uri.EscapeDataString("4"), "text" + "=" + Uri.EscapeDataString("https:\/\/example.com") });
        var url = "https://api.avrinbai.cn/api/tools/qrcode" + "?" + query;
        using var request = new HttpRequestMessage(new HttpMethod("GET"), url);
        request.Headers.Add("Accept", "application/json");
        // request.Headers.Add("X-API-Key", "YOUR_API_KEY");
        // GET/HEAD 通常不发送 body。

        using var response = await client.SendAsync(request);
        var body = await response.Content.ReadAsStringAsync();
        Console.WriteLine((int)response.StatusCode);
        Console.WriteLine(body);
    }
}
// GET https://api.avrinbai.cn/api/tools/qrcode
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var payloadJson = {"e":"H","m":6,"p":4,"text":"https:\/\/example.com"};

        using var client = new HttpClient();
        var query = "payload=" + Uri.EscapeDataString(payloadJson);
        var url = "https://api.avrinbai.cn/api/tools/qrcode" + "?" + query;
        using var request = new HttpRequestMessage(new HttpMethod("GET"), url);
        request.Headers.Add("Accept", "application/json");
        // request.Headers.Add("X-API-Key", "YOUR_API_KEY");
        // GET/HEAD 通常不发送 body。

        using var response = await client.SendAsync(request);
        var body = await response.Content.ReadAsStringAsync();
        Console.WriteLine((int)response.StatusCode);
        Console.WriteLine(body);
    }
}
<?php
// GET https://api.avrinbai.cn/api/tools/qrcode

$payload = json_decode('{\"e\":\"H\",\"m\":6,\"p\":4,\"text\":\"https:\\/\\/example.com\"}', true) ?: [];

// $apiKey = 'YOUR_API_KEY';

$ch = curl_init();

if (in_array('GET', ['GET', 'HEAD'], true)) {
    $url = 'https://api.avrinbai.cn/api/tools/qrcode' . (count($payload) ? ('?' . http_build_query($payload)) : '');
} else {
    $url = 'https://api.avrinbai.cn/api/tools/qrcode';
}

curl_setopt_array($ch, [
    CURLOPT_URL => $url,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HEADER => true,
    CURLOPT_TIMEOUT => 25,
]);

$headers = [
    'Accept: application/json',
];
// $headers[] = 'X-API-Key: ' . $apiKey;

if (! in_array('GET', ['GET', 'HEAD'], true)) {
    $body = json_encode($payload, JSON_UNESCAPED_UNICODE);
    $headers[] = 'Content-Type: application/json';
    curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$raw = curl_exec($ch);
if ($raw === false) {
    throw new RuntimeException('cURL error: ' . curl_error($ch));
}

$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);

$rawHeaders = substr($raw, 0, $headerSize);
$rawBody = substr($raw, $headerSize);

curl_close($ch);

echo "HTTP {$status}\n";
echo $rawHeaders . "\n";
echo $rawBody;
curl -sS -X GET \
  "https://api.avrinbai.cn/api/tools/qrcode" \
  --get \
  --data-urlencode 'payload={"e":"H","m":6,"p":4,"text":"https:\/\/example.com"}'