Official Python SDK for the Vega API (Discord giveaways).
Project description
vegabot-py-sdk (Python)
Official Python SDK for the Vega API — Discord giveaways, required-server management, and the membership gate. Included with a Vega whitelabel license.
pip install vegabot-py-sdk
Python 3.9+.
Quick start
import os
from vega import VegaClient
vega = VegaClient(api_key=os.environ["VEGA_API_KEY"])
me = vega.me() # {"guildId": ..., "license": {...}}
active = vega.list_giveaways()
Get your key from the dashboard: Whitelabel → API → Generate key (license owner only). A key is scoped to one Discord server. Keep it server-side. Use the client as a context manager to auto-close:
with VegaClient(api_key=...) as vega:
vega.list_giveaways()
Giveaways
res = vega.create_giveaway(
prize="Nitro",
channel_id="123456789012345678",
duration_seconds=86_400,
winners=1,
description="Good luck!",
requirements=[{"requiredGuildId": "987654321098765432"}],
)
active = vega.list_giveaways()
one = vega.get_giveaway(res["giveawayId"]) # {"giveaway":..., "entryCount":..., "winnerIds":[...]}
vega.end_giveaway(res["giveawayId"])
vega.reroll_giveaway(res["giveawayId"], winners=2)
Required servers
vega.register_server(required_guild_id="987...", name="Main Server", invite_url="https://discord.gg/abc")
servers = vega.list_servers()
vega.delete_server("987...")
Membership gate
result = vega.check_membership(user_id="111...", required_guild_id="987...")
print(result["inServer"], result["hasRole"])
Settings
settings = vega.get_settings()
Reacting to giveaway events
Two options: poll (no public URL) or receive webhooks.
Option A — polling (no public URL needed)
listen polls the event feed and calls your handler for each event, in order. It blocks, so run it in a thread.
import threading
def handle(event):
if event["event"] == "giveaway.ended":
print("winners", event["data"]["winnerIds"])
stop = threading.Event()
threading.Thread(target=vega.listen, args=(handle,), kwargs={"stop": stop}, daemon=True).start()
# ... later: stop.set()
By default only events after listen starts are delivered; pass after=0 to replay everything still in the feed.
You can also poll manually with vega.list_events(after, limit) and track the last id.
Option B — webhooks
Set a delivery URL (dashboard API → Webhooks, or vega.set_webhook(url)). Vega POSTs signed events to it.
Verify the X-Vega-Signature header. construct_event verifies and parses in one call:
from vega import construct_event, VegaSignatureError
# Flask, needs the RAW body
@app.post("/vega/webhook")
def webhook():
try:
event = construct_event(request.get_data(), request.headers.get("X-Vega-Signature"), SECRET)
except VegaSignatureError:
return "", 401
if event["event"] == "giveaway.ended":
print(event["data"]["winnerIds"])
return "", 200
Prefer verifying yourself? Use verify_webhook(raw_body: bytes, header, secret) -> bool.
More examples (Flask, FastAPI, polling) are in the docs.
Errors
Failed calls raise VegaApiError with .status, .code, and .detail.
from vega import VegaApiError
try:
vega.get_giveaway(999999)
except VegaApiError as e:
if e.status == 404:
print("not found")
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vegabot_py_sdk-0.2.0.tar.gz.
File metadata
- Download URL: vegabot_py_sdk-0.2.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
208bbe1a9b95f72187432e142971d696c5bb243c79d506394a1303681794b524
|
|
| MD5 |
8cf6d33f3c68114519edd2fb46af891b
|
|
| BLAKE2b-256 |
88ac6c73d2cb06e55861808439e5f6398fc9dffc83e26dbedac7ceac26a257cb
|
Provenance
The following attestation bundles were made for vegabot_py_sdk-0.2.0.tar.gz:
Publisher:
publish.yml on Vega-Discord-Bot/vega-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vegabot_py_sdk-0.2.0.tar.gz -
Subject digest:
208bbe1a9b95f72187432e142971d696c5bb243c79d506394a1303681794b524 - Sigstore transparency entry: 2066096990
- Sigstore integration time:
-
Permalink:
Vega-Discord-Bot/vega-sdk-py@2358f5a19db32b0dc53b27e635a467d912fc7392 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Vega-Discord-Bot
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2358f5a19db32b0dc53b27e635a467d912fc7392 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file vegabot_py_sdk-0.2.0-py3-none-any.whl.
File metadata
- Download URL: vegabot_py_sdk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60eb46b2f245fe4f1cf8c32649a40af9c89d7fe4f8240e2a51a96baec3507643
|
|
| MD5 |
993bcbcc6bf11182358bd0bc6d82a522
|
|
| BLAKE2b-256 |
342fb186a2e244671eb5038661ff8ffefa5aeccedb9a48977fbe06680820c8c5
|
Provenance
The following attestation bundles were made for vegabot_py_sdk-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Vega-Discord-Bot/vega-sdk-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vegabot_py_sdk-0.2.0-py3-none-any.whl -
Subject digest:
60eb46b2f245fe4f1cf8c32649a40af9c89d7fe4f8240e2a51a96baec3507643 - Sigstore transparency entry: 2066097051
- Sigstore integration time:
-
Permalink:
Vega-Discord-Bot/vega-sdk-py@2358f5a19db32b0dc53b27e635a467d912fc7392 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Vega-Discord-Bot
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2358f5a19db32b0dc53b27e635a467d912fc7392 -
Trigger Event:
workflow_dispatch
-
Statement type: