licencore-sdk-python
English | فارسی
A tiny Python SDK that checks your licence against a Licencore server. Zero dependencies. Works in any Python app and has built-in Django support.
Install
pip install licencore-sdk-python
Settings
| Name | Required | Default | Description |
|---|---|---|---|
SERVER_URL |
yes | – | Full URL of the licence check endpoint |
ACCESS_KEY |
yes | – | Your access key |
HEADER_KEY |
no | X-Access-Key |
Header name used to send the key |
CHECK_INTERVAL_HOURS |
no | 6 |
How often the server is contacted (hours) |
OFFLINE_GRACE_HOURS |
no | 24 |
If the server is unreachable, keep trusting the last valid answer for this long |
TIMEOUT |
no | 10 |
HTTP timeout in seconds |
Settings are read from environment variables (or Django settings.py).
You may use the LICENCORE_ prefix (e.g. LICENCORE_SERVER_URL) to avoid name clashes.
export SERVER_URL="https://licence.example.com/api/check"
export HEADER_KEY="X-Access-Key"
export ACCESS_KEY="your-key"
Usage
import licencore
if licencore.is_valid():
print("Licence OK")
status = licencore.status()
print(status.status, status.remaining_seconds, status.expires_at)
licencore.require() # raises licencore.LicenceInvalid if not valid
Or pass settings in code:
from licencore import LicenceClient
client = LicenceClient(
server_url="https://licence.example.com/api/check",
access_key="your-key",
check_interval_hours=12,
)
client.require()
How checking works
You don't need a scheduler. The SDK caches the answer and only calls the server
when the cache is older than CHECK_INTERVAL_HOURS (default: every 6 hours,
i.e. about 4 times a day). remaining_seconds is counted down locally between
checks. If the licence is invalid, or the server is down, it retries every
5 minutes, so a renewal is noticed quickly. Call licencore.status(force=True)
to force an immediate check.
Django
# settings.py
MIDDLEWARE = [
# ...
"licencore.django_support.LicenceMiddleware",
]
LICENCORE_SERVER_URL = "https://licence.example.com/api/check"
LICENCORE_ACCESS_KEY = "your-key"
LICENCORE_HEADER_KEY = "X-Access-Key" # optional
LICENCORE_CHECK_INTERVAL_HOURS = 6 # optional
LICENCORE_EXEMPT_PATHS = ["/health/"] # optional, paths that skip the check
When the licence is invalid, every request gets a 403 JSON response.
The status is available as request.licence in your views.
To protect only specific views:
from licencore.django_support import licence_required
@licence_required
def my_view(request):
...
Licence status fields
valid, status, starts_at, expires_at, remaining_seconds,
starts_in_seconds, project_id, server_time, plus offline (answer came
from cache because the server was unreachable) and error.
Credits
Built by CyberHuginn for Fardad Noavar — fardadnoavar.ir
فارسی
یک SDK خیلی ساده پایتون برای چک کردن لایسنس از سرور Licencore. بدون وابستگی (dependency) و با پشتیبانی داخلی از Django.
نصب
pip install licencore-sdk-python
تنظیمات
| نام | اجباری | پیشفرض | توضیح |
|---|---|---|---|
SERVER_URL |
بله | – | آدرس کامل endpoint چک لایسنس |
ACCESS_KEY |
بله | – | کلید دسترسی |
HEADER_KEY |
خیر | X-Access-Key |
نام هدری که کلید داخلش فرستاده میشه |
CHECK_INTERVAL_HOURS |
خیر | 6 |
هر چند ساعت یک بار از سرور چک بشه |
OFFLINE_GRACE_HOURS |
خیر | 24 |
اگه سرور در دسترس نبود، تا این مدت به آخرین جواب معتبر اعتماد کن |
TIMEOUT |
خیر | 10 |
تایماوت درخواست (ثانیه) |
تنظیمات از متغیرهای محیطی (یا settings.py جنگو) خونده میشن.
میتونید پیشوند LICENCORE_ هم بذارید (مثلاً LICENCORE_SERVER_URL) تا با متغیرهای دیگه تداخل نکنه.
export SERVER_URL="https://licence.example.com/api/check"
export HEADER_KEY="X-Access-Key"
export ACCESS_KEY="your-key"
استفاده
import licencore
if licencore.is_valid():
print("لایسنس معتبره")
status = licencore.status()
print(status.status, status.remaining_seconds, status.expires_at)
licencore.require() # اگه معتبر نباشه licencore.LicenceInvalid پرتاب میشه
یا تنظیمات رو مستقیم تو کد بدید:
from licencore import LicenceClient
client = LicenceClient(
server_url="https://licence.example.com/api/check",
access_key="your-key",
check_interval_hours=12,
)
client.require()
چک کردن چطور کار میکنه؟
نیازی به scheduler نیست. SDK جواب رو کش میکنه و فقط وقتی کش از
CHECK_INTERVAL_HOURS قدیمیتر باشه به سرور درخواست میزنه
(پیشفرض: هر ۶ ساعت، یعنی حدود ۴ بار در روز).
remaining_seconds بین دو چک بهصورت محلی کم میشه.
اگه لایسنس نامعتبر باشه یا سرور در دسترس نباشه، هر ۵ دقیقه دوباره تلاش میکنه
تا تمدید لایسنس سریع شناسایی بشه. برای چک فوری از licencore.status(force=True) استفاده کنید.
جنگو (Django)
# settings.py
MIDDLEWARE = [
# ...
"licencore.django_support.LicenceMiddleware",
]
LICENCORE_SERVER_URL = "https://licence.example.com/api/check"
LICENCORE_ACCESS_KEY = "your-key"
LICENCORE_HEADER_KEY = "X-Access-Key" # اختیاری
LICENCORE_CHECK_INTERVAL_HOURS = 6 # اختیاری
LICENCORE_EXEMPT_PATHS = ["/health/"] # اختیاری، مسیرهایی که چک نمیشن
اگه لایسنس نامعتبر باشه، همه درخواستها جواب 403 (JSON) میگیرن.
وضعیت لایسنس تو view ها از request.licence در دسترسه.
برای محافظت از چند view خاص:
from licencore.django_support import licence_required
@licence_required
def my_view(request):
...
فیلدهای وضعیت
valid، status، starts_at، expires_at، remaining_seconds،
starts_in_seconds، project_id، server_time و همچنین offline
(یعنی چون سرور در دسترس نبود از کش جواب داده شده) و error.
توسعهدهنده
ساختهشده توسط CyberHuginn برای شرکت فرداد نوآور — fardadnoavar.ir
License
MIT
Metadata
Release files for licencore-sdk-python 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| licencore_sdk_python-0.1.0.tar.gz | 12.0 kB | Without provenance | Details for licencore_sdk_python-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| licencore_sdk_python-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for licencore_sdk_python-0.1.0-py3-none-any.whl |
Total release size: 22.0 kB
Release files / licencore_sdk_python-0.1.0.tar.gz
| Download URL | licencore_sdk_python-0.1.0.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
489c10081fa9d7ff71ff78f120a43d2d03de0fe6f16b13337c951ae3cb43d26e
|
|
BLAKE2b-256 checksum How to use checksums |
c67a71cf4776ec4beedbe20224fe62f75b97943ff134a9bb2fbb2227ba0ea747
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / licencore_sdk_python-0.1.0-py3-none-any.whl
| Download URL | licencore_sdk_python-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
90b3d5c6934377794ccba3fe2a5ef8bed420a112d29549d0ce0e74080b45e351
|
|
BLAKE2b-256 checksum How to use checksums |
77eff3de02a25c8b05471024e8cf8a4a6937493809c7f4df41b9515f1b569cb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for licencore-sdk-python 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.