AndBondStyle / niimprint

Python library for Niimbot label printers. Supports D11/B21/B1 via bluetooth or USB.
MIT License
225 stars 32 forks source link

IOS niimbot App Traffic #35

Open tywtyw2002 opened 3 months ago

tywtyw2002 commented 3 months ago

Below are some important traffic related to label printing.

Get Rfid print policy

The app will use the printer ID to query the print policy for non-rfid label.

POST /api/rfid/getRfidPrintStrategy HTTP/1.1
Host: print.niimbot.com
Accept: */*
Authorization: *
Accept-Encoding: gzip, deflate, br
If-None-Match: *
languageCode: zh-cn
Accept-Language: en-CA;q=1, zh-Hans-CA;q=0.9
Content-Length: 36
User-Agent: *
niimbot-user-agent: *
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Cookie: *

bluetoothNumber=BXX-XXXXXXXXX&type=1

Response JSON
{
  "code": 1,
  "data": {
    "rfidStatus": {
      "status": true,
      "enableStartTime": null,
      "enableDeadlineTime": null
    },
    "printConfig": [
      {
        "status": false,
        "enabled": false,
        "id": 1,
        "typeName": "非法纸张打印策略",
        "type": 1,
        "value": 0,
        "name": "0浓度打印"
      },
      {
        "status": false,
        "enabled": false,
        "id": 2,
        "typeName": "非法纸张打印策略",
        "type": 1,
        "value": -1,
        "name": "-1浓度打印"
      },
      {
        "status": true,
        "enabled": true,
        "id": 3,
        "typeName": "非法纸张打印策略",
        "type": 1,
        "value": -2,
        "name": "-2浓度打印"
      },
      {
        "status": false,
        "enabled": false,
        "id": 4,
        "typeName": "非法纸张打印策略",
        "type": 1,
        "value": null,
        "name": "禁止批量打印"
      },
      {
        "status": false,
        "enabled": false,
        "id": 5,
        "typeName": "非法纸张打印策略",
        "type": 1,
        "value": null,
        "name": "禁止打印"
      },
      {
        "status": false,
        "enabled": false,
        "id": 6,
        "typeName": "非法纸张打印策略",
        "type": 1,
        "value": null,
        "name": "不做限制"
      }
    ],
    "bluetoothNumber": "BXX-XXXXXXXXX"
  },
  "message": "成功",
  "status_code": 1
}

Get Rfid info

Use the rfid uuid to query the server log, if materialUsed > allowNum, APP will stop printing.

POST /api/rfid/getRfid HTTP/1.1
Host: print.niimbot.com
Accept: */*
Authorization: *
Accept-Encoding: gzip, deflate, br
If-None-Match: *
languageCode: zh-cn
Accept-Language: en-CA;q=1, zh-Hans-CA;q=0.9
Content-Length: 29
User-Agent: *
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Cookie: *

serialNumber=881d728314870000

Response JSON
{
  "data": [
    {
      "allowNum": 276,
      "fixedAllowNum": 276,
      "rfidStatus": false,
      "serialNumber": "881d728314870000",
      "materialUsed": 282,
      "usedType": 1,
      "carbonColor": "",
      "paperColor": "0.0.0",
      "batchSn": "PC0F629160004839",
      "statusCode": "B2"
    }
  ],
  "code": 1,
  "status_code": 1,
  "message": "成功"
}

Get label info

App will use the barcode info from RFID to query the label details. This is how the app auto detect the printer label size.

POST /api/template/getCloudTemplateByScanCode HTTP/1.1
Host: print.niimbot.com
Accept: */*
Authorization: *
Accept-Encoding: gzip, deflate, br
If-None-Match: *
languageCode: zh-cn
Accept-Language: en-CA;q=1, zh-Hans-CA;q=0.9
Content-Length: 16
User-Agent: *
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Cookie: *

oneCode=6972842748577

Response 
{
  "data": {
    "id": 80006400,
    "name": "T50*30-230特价(10卷)",
    "names": [
      {
        "languageCode": "zh-cn",
        "languageName": "简体中文",
        "name": "T50*30-230特价(10卷)"
      },
      {
        "languageCode": "zh-cn-t",
        "languageName": "繁体中文",
        "name": "T50*30-230特價(10卷)"
      }
    ],
    "barcode": "6972842748577",
    "backgroundImage": "https://oss-print.niimbot.com/public_resources/labels/DN202211050002-f6c11f25a17256c02a536ee1a0182af2.png",
    "commodityTemplate": false,
    "cableDirection": -1,
    "cableLength": 0,
    "isCable": false,
    "paperType": 1,
    "consumableType": 1,
    "consumableTypeTextId": "app01230",
    "previewImage": "https://oss-print.niimbot.com/public_resources/labels/DN202211050002-f6c11f25a17256c02a536ee1a0182af2.png",
    "rotate": 0,
    "thumbnail": "https://oss-print.niimbot.com/public_resources/labels/DN202211050002-f6c11f25a17256c02a536ee1a0182af2.png",
    "machineIdList": [
      "8",
      "10028",
      "27",
      "2",
      "18",
      "41",
      "10027",
      "31",
      "10025",
      "10017",
      "51",
      "48",
      "10003",
      "1",
      "50",
      "32",
      "10026",
      "10013",
      "12",
      "13",
      "14"
    ],
    "printedProcessList": [],
    "originTemplateId": 0,
    "height": 30,
    "width": 50,
    "margin": [
      0,
      0,
      0,
      0
    ],
    "sticky": false,
    "visibility": {
      "languageCodes": [
        {
          "languageCode": "zh_CN",
          "visible": true
        },
        {
          "languageCode": "zh_TW",
          "visible": true
        },
        {
          "languageCode": "de",
          "visible": false
        },
        {
          "languageCode": "hi",
          "visible": false
        },
        {
          "languageCode": "ru",
          "visible": false
        },
        {
          "languageCode": "Polish",
          "visible": false
        },
        {
          "languageCode": "ko",
          "visible": false
        },
        {
          "languageCode": "pt",
          "visible": false
        },
        {
          "languageCode": "af",
          "visible": false
        },
        {
          "languageCode": "ms",
          "visible": false
        },
        {
          "languageCode": "en",
          "visible": false
        },
        {
          "languageCode": "it",
          "visible": false
        },
        {
          "languageCode": "fr",
          "visible": false
        },
        {
          "languageCode": "es",
          "visible": false
        },
        {
          "languageCode": "ar",
          "visible": false
        },
        {
          "languageCode": "th",
          "visible": false
        },
        {
          "languageCode": "ja",
          "visible": false
        },
        {
          "languageCode": "Czech",
          "visible": false
        },
        {
          "languageCode": "ind",
          "visible": false
        },
        {
          "languageCode": "tr",
          "visible": false
        }
      ]
    },
    "profile": {
      "keyword": "特价(10卷)",
      "barcode": "6972842748577",
      "machineId": "8,10028,27,2,18,41,10027,31,10025,10017,51,48,10003,1,50,32,10026,10013,12,13,14",
      "machineName": "S3,B31,B21,B11,B3S,S6,B21_Pro,B21-L2B,B3S_P,A203,B21S,B203,B1,B3,B21S-C2B,B21-C2B,B21_H,A8,JCB3S,JC-M90,S1",
      "extrain": {
        "userId": null,
        "labelId": "80006400",
        "materialModelSn": "30050",
        "sourceId": "80006400",
        "commodityCategoryId": 40,
        "industryId": 39,
        "goodsCode": null,
        "isPrivate": true,
        "isDelete": false,
        "createTime": "2022-11-05 12:00:40",
        "updateTime": "2024-08-01 20:35:37",
        "barcodeCategoryMap": {
          "barcode": "6972842748577",
          "materialModelSn": "30050"
        },
        "adaptPlatformCode": "CP001Mobile,CP001PC,CP001Pad,CP002Mobile,CP002PC,CP002Pad,CP004Mobile,CP004PC,CP004Pad,CP005Mobile,CP005PC,CP005Pad,CP006Mobile,CP006PC,CP006Pad,CP007Mobile,CP007PC,CP007Pad,CP008Mobile,CP008PC,CP008Pad,CP009Mobile,CP009PC,CP009Pad,CP010Mobile,CP010PC,CP010Pad,CP011Mobile,CP011PC,CP011Pad,CP012Mobile,CP012PC,CP012Pad,CP013Mobile,CP013PC,CP013Pad,CP014Mobile,CP014PC,CP014Pad,CP015Mobile,CP015PC,CP015Pad",
        "adaptPlatformName": "精臣云打印-移动端,精臣云打印-pc端,精臣云打印-平板,臣印-移动端,臣印-pc端,臣印-平板,烟草价签-移动端,烟草价签-pc端,烟草价签-平板,固定资产-移动端,固定资产-pc端,固定资产-平板,进销存-移动端,进销存-pc端,进销存-平板,国网电表-移动端,国网电表-pc端,国网电表-平板,烟草管家-移动端,烟草管家-pc端,烟草管家-平板,可多价签-移动端,可多价签-pc端,可多价签-平板,电网标签打印-移动端,电网标签打印-pc端,电网标签打印-平板,烟草管家-非烟-移动端,烟草管家-非烟-pc端,烟草管家-非烟-平板,标识云打印-移动端,标识云打印-pc端,标识云打印-平板,标识云-移动端,标识云-pc端,标识云-平板,华为FA快应用-移动端,华为FA快应用-pc端,华为FA快应用-平板,华为智慧生活-移动端,华为智慧生活-pc端,华为智慧生活-平板",
        "templateType": 1,
        "templateClass": 0,
        "resourceVersion": null
      }
    },
    "labelNames": [
      {
        "languageCode": "zh-cn",
        "languageName": "简体中文",
        "name": "T50*30-230特价(10卷)"
      },
      {
        "languageCode": "zh-cn-t",
        "languageName": "繁体中文",
        "name": "T50*30-230特價(10卷)"
      }
    ],
    "isEdited": "0",
    "supportedEditors": [
      "GENERAL"
    ]
  },
  "code": 1,
  "status_code": 1,
  "message": "成功"
}

After Print log.

After each print done. The app will send the print log to https://niimbot-pro.cn-hangzhou.log.aliyuncs.com/logstores/print-bison-content/shards/lb. The server will analysis the log then increase materialUsed for rfid uuid.

APP traffic

Screenshot 2024-08-17 at 19 28 39

Log

Screenshot 2024-08-17 at 19 47 22

Other Urls

Printer List

Here is all the available printer make by niimbot https://print.niimbot.com/api/hardware/list

The paperType in each printer section is the info for what type of paper can this printer print. Same id with the rfid consumablesType. Also the consumables.parentProperty.code is the same ID, but with more detailed paper info.

Note app0000XX are the i18n key.