{"id":44720163,"url":"https://github.com/newmatik/miniprint","last_synced_at":"2026-02-15T15:54:08.968Z","repository":{"id":232965234,"uuid":"785498319","full_name":"newmatik/miniprint","owner":"newmatik","description":"Simple ZPL Print Server for REST API Calls to Zebra Printers","archived":false,"fork":false,"pushed_at":"2026-01-14T11:33:04.000Z","size":99,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T13:39:39.498Z","etag":null,"topics":["barcode","labels","rest","rest-api","zebra","zebra-printer","zpl"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/newmatik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-04-12T02:09:02.000Z","updated_at":"2026-01-14T11:33:06.000Z","dependencies_parsed_at":"2024-04-12T18:15:44.806Z","dependency_job_id":"f9b3648f-a0f1-4118-a1c5-c2979b3d8c42","html_url":"https://github.com/newmatik/miniprint","commit_stats":null,"previous_names":["newmatik/miniprint"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/newmatik/miniprint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmatik%2Fminiprint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmatik%2Fminiprint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmatik%2Fminiprint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmatik%2Fminiprint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/newmatik","download_url":"https://codeload.github.com/newmatik/miniprint/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmatik%2Fminiprint/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29483260,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T15:33:17.885Z","status":"ssl_error","status_checked_at":"2026-02-15T15:32:53.698Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["barcode","labels","rest","rest-api","zebra","zebra-printer","zpl"],"created_at":"2026-02-15T15:54:07.016Z","updated_at":"2026-02-15T15:54:08.960Z","avatar_url":"https://github.com/newmatik.png","language":"Python","readme":"# MiniPrint - Zebra Printer API Server\n\nThis Flask application provides a REST API to interact with Zebra label printers on a network. It supports listing all registered printers, checking their online status, and sending ZPL commands to print labels directly from supplied text.\n\n## Features\n\n- **ERP-backed Printers**: Loads the list of printers from an ERPNext DocType (default: `NPrint Printer`).\n- **List Printers**: Retrieve the current mapping with IP and port as seen by the server.\n- **Check Printer Status**: Check the online/offline status of each printer.\n- **Print Labels**: Send text to a printer to be printed on a label using Zebra Programming Language (ZPL).\n- **Manual Reload**: `POST /printers/reload` to re-fetch the printer list from ERP immediately.\n- **Auto Refresh**: Optional background refresh on an interval via `PRINTERS_REFRESH_SECONDS`.\n\n## Setup\n\n### Prerequisites\n\n- Python 3.6 or higher\n- Flask\n\n### Installation\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/newmatik/miniprint.git\n   cd miniprint\n   ```\n\n2. Set up a virtual environment (optional but recommended):\n   ```bash\n   python -m venv venv\n   source venv/bin/activate  # On Windows use `venv\\Scripts\\activate`\n   ```\n\n3. Install dependencies:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n4. Environment setup:\n   Copy `.env_sample` to `.env` and set the variables. At minimum set `APIKEY`, `ERP_URL`, `ERP_API_KEY`, and `ERP_API_SECRET`.\n\n   ```bash\n   cp .env_sample .env\n   vim .env\n   ```\n   - `ERP_PRINTER_DOCTYPE` (optional, defaults to `NPrint Printer`)\n   - `PRINTERS_REFRESH_SECONDS` (optional; set to `0` to disable, e.g., `3600` for hourly refresh)\n   - Note: If ERP is unreachable or returns no rows, the server falls back to the local mapping defined in `printers.py`.\n\n5. Running the Server:\n   Run the server with the following command:\n   ```bash\n   flask run\n   ```\n   This starts the server on http://0.0.0.0:5500/, making it accessible on all network interfaces on port 5500.\n\n## Usage\n\n- **GET /printers**\n   Requires API key\n   Returns a list of all printers\n\n- **GET /printers/status**\n   Requires API key\n   Returns the status of each printer (online, offline)\n\n- **POST /printers/reload**\n  Requires API key\n  Forces an immediate reload of printers from ERPNext.\n\n- **POST /print**\n   Requires API key\n   Prints the ZPL label to the specified printer\n\n### Example Request\n\nUsing curl to check printer status:\n\n```bash\ncurl -X GET http://localhost:5500/printers/status -H \"apikey: g9d8fh09df8hg09f8siw3erfsd8\"\n```\n\nReload printers from ERP:\n\n```bash\ncurl -X POST http://localhost:5500/printers/reload -H \"apikey: $APIKEY\"\n```\n\nList the current mapping:\n\n```bash\ncurl -X GET http://localhost:5500/printers -H \"apikey: $APIKEY\"\n```\n\n### ERPNext integration\n\n- The server queries ERPNext’s built-in REST API at `/api/resource/\u003cDocType\u003e` using the API key/secret.\n- Expected fields on the DocType (defaults to `NPrint Printer`):\n  - `printer_name`: unique identifier used by clients to select a printer\n  - `server_ip`: IPv4/hostname of the device\n  - `port`: TCP port (default 9100 if not set)\n- Optional: configure an ERPNext Webhook on the DocType to call `POST /printers/reload` after insert/update for near-real-time updates. Keep `PRINTERS_REFRESH_SECONDS` as a fallback.\n\n## Deployment on Ubuntu Server\n\nTo ensure that the Flask application starts automatically at server boot and restarts in case it crashes, we use systemd on Ubuntu.\nConsider deploying with a production-ready WSGI server like Gunicorn.\n\n### Create a Service File\n\nFirst, create a systemd service file for your Flask application. You’ll need root or sudo privileges to write to the service directory.\n\nOpen a terminal and use your preferred text editor to create a service file:\n\n```bash\nsudo nano /etc/systemd/system/miniprint.service\n```\n\nAdd the following configuration to the file, customizing it to suit your application setup:\n\n```bash\n[Unit]\nDescription=Flask Application Service\nAfter=network.target\n\n[Service]\nUser=your_username\nGroup=your_usergroup\nWorkingDirectory=/path/to/your/application\nEnvironment=\"PATH=/path/to/your/venv/bin\"\nExecStart=/path/to/your/venv/bin/python app.py\nRestart=always\n\n[Install]\nWantedBy=multi-user.target\n```\n\n### Enable and Start the Service\n\nAfter saving your service file, you'll need to reload the systemd manager configuration, enable the service to start on boot, and then start the service:\n\n```bash\nsudo systemctl daemon-reload\nsudo systemctl enable miniprint.service\nsudo systemctl start miniprint.service\n```\n\n### Check the Status of Your Service\n\nTo check the status of your service and ensure it's running properly:\n\n```bash\nsudo systemctl status miniprint.service\n```\n\n## Note\nThis application is designed for demonstration and development purposes and may require additional security and error handling features for production use.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewmatik%2Fminiprint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewmatik%2Fminiprint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewmatik%2Fminiprint/lists"}