Simple Python wrapper for the Spiget API
Project description
Python Spiget API Wrapper
A modern Python wrapper for the Spiget API, providing easy access to Spigot resources, authors, and categories.
Installation
pip install pyspiget
Quick Start
from spiget import Spiget
# Initialize the client
api = Spiget(user_agent="MyApp/1.0.0")
# Get a resource
resource = api.get_resource(1234)
print(f"Resource name: {resource.name}")
# Search for resources
resources = api.search_resources("worldedit")
for resource in resources:
print(f"Found: {resource.name}")
API Reference
Main Classes
Spiget
The main class for interacting with the Spiget API.
api = Spiget(user_agent="MyApp/1.0.0")
WebhookHandler
Handles webhook-related operations for the Spiget API.
webhook_handler = WebhookHandler(api.session)
Data Models
All models inherit from BaseModel
which provides basic dictionary to object conversion.
Resource
Represents a Spigot resource (plugin, mod, etc.)
Properties:
id
: Resource IDname
: Resource nametag
: Resource tagcontributors
: List of contributorslikes
: Number of likesfile
: ResourceFile objecttested_versions
: List of tested Minecraft versionslinks
: Dictionary of related linksrating
: ResourceRating objectrelease_date
: Release datetimeupdate_date
: Last update datetimedownloads
: Number of downloadsexternal
: Whether the resource is externalicon
: Icon objectpremium
: Whether the resource is premiumprice
: Resource price (if premium)currency
: Price currencydescription
: Resource descriptiondocumentation
: Resource documentationsource_code_link
: Link to source codedonation_link
: Link to donation page
ResourceFile
Represents a resource's downloadable file.
Properties:
type
: File typesize
: File sizesize_unit
: Size uniturl
: Download URLexternal_url
: External download URL
ResourceVersion
Represents a specific version of a resource.
Properties:
id
: Version IDuuid
: Version UUIDname
: Version namerelease_date
: Release datetimedownloads
: Number of downloadsrating
: ResourceRating object
ResourceUpdate
Represents an update post for a resource.
Properties:
id
: Update IDresource
: Resource IDtitle
: Update titledescription
: Update descriptiondate
: Update datetimelikes
: Number of likes
ResourceReview
Represents a review for a resource.
Properties:
author
: Author objectrating
: ResourceRating objectmessage
: Review messageresponse_message
: Author's responseversion
: Version revieweddate
: Review datetime
Author
Represents a resource author.
Properties:
id
: Author IDname
: Author nameicon
: Icon object
Category
Represents a resource category.
Properties:
id
: Category IDname
: Category name
Methods
Resource Methods
# Get multiple resources
resources = api.get_resources(size=10, page=1, sort=None, fields=None)
# Get a single resource
resource = api.get_resource(resource_id=1234)
# Get resource versions
versions = api.get_resource_versions(resource_id=1234, size=10, page=1)
# Get specific version
version = api.get_resource_version(resource_id=1234, version_id="1.0.0")
# Get latest version
latest = api.get_resource_latest_version(resource_id=1234)
# Get resource updates
updates = api.get_resource_updates(resource_id=1234, size=10, page=1)
# Get resource reviews
reviews = api.get_resource_reviews(resource_id=1234, size=10, page=1)
# Get resource author
author = api.get_resource_author(resource_id=1234)
Author Methods
# Get multiple authors
authors = api.get_authors(size=10, page=1)
# Get single author
author = api.get_author(author_id=1234)
# Get author's resources
resources = api.get_author_resources(author_id=1234, size=10, page=1)
Category Methods
# Get all categories
categories = api.get_categories(size=10, page=1)
# Get single category
category = api.get_category(category_id=1234)
# Get category resources
resources = api.get_category_resources(category_id=1234, size=10, page=1)
Search Methods
# Search resources
resources = api.search_resources(query="worldedit", field=None, size=10, page=1)
# Search authors
authors = api.search_authors(query="sk89q", field=None, size=10, page=1)
Webhook Methods
# Get available webhook events
events = webhook_handler.get_webhook_events()
# Register a webhook
webhook = webhook_handler.register_webhook(
url="https://example.com/webhook",
events=["resource-update", "new-resource"]
)
# Get webhook status
status = webhook_handler.get_webhook_status(webhook_id="abc123")
# Delete webhook
webhook_handler.delete_webhook(webhook_id="abc123", secret="webhook_secret")
Error Handling
The wrapper includes a custom SpigetError
exception that is raised when API requests fail:
from spiget import Spiget, SpigetError
api = Spiget()
try:
resource = api.get_resource(99999999)
except SpigetError as e:
print(f"API error: {e}")
Credits
This wrapper is built for the Spiget API created by the SpiGetOrg team.
License
MIT License - see LICENSE file for details
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
File details
Details for the file pyspiget-0.1.0.tar.gz
.
File metadata
- Download URL: pyspiget-0.1.0.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2cc73a4f2a19dcd46a0b3415d9b0df49957b794f73c3b2e2768b541e4502adf |
|
MD5 | 32e1fd5921ebc230e06f644dac6277d2 |
|
BLAKE2b-256 | f9be6b618798c5fe0774e297b0a03323e1b56db1f9f529daf724d86aa4a2b66a |
Provenance
The following attestation bundles were made for pyspiget-0.1.0.tar.gz
:
Publisher:
publish.yml
on Mark7888/pyspiget
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyspiget-0.1.0.tar.gz
- Subject digest:
c2cc73a4f2a19dcd46a0b3415d9b0df49957b794f73c3b2e2768b541e4502adf
- Sigstore transparency entry: 151039507
- Sigstore integration time:
- Predicate type:
File details
Details for the file pyspiget-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pyspiget-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c65c6d2e467db57398c21c525d6542c856108dfc052a117c58d2e7c48a0c08ea |
|
MD5 | 000be23e4ef00405a9a073896438c99c |
|
BLAKE2b-256 | ece7a36927f1227d503663c6b771f75721622853c7cb36f071086a8c3e647307 |
Provenance
The following attestation bundles were made for pyspiget-0.1.0-py3-none-any.whl
:
Publisher:
publish.yml
on Mark7888/pyspiget
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
pyspiget-0.1.0-py3-none-any.whl
- Subject digest:
c65c6d2e467db57398c21c525d6542c856108dfc052a117c58d2e7c48a0c08ea
- Sigstore transparency entry: 151039508
- Sigstore integration time:
- Predicate type: