Python SDK for PaySponge
Project description
paysponge
Python SDK for Sponge.
The paysponge package gives Python apps access to Sponge agent wallets,
platform provisioning, transfers, balances, cards, and paid request workflows.
Concepts
Sponge has two client types:
SpongeWalletis the runtime client for one agent. Use it with an agent API key when that agent needs to inspect balances, get wallet addresses, transfer funds, create cards, or make paid requests.SpongePlatformis the control-plane client for your backend. Use it with a master/platform API key when you need to create agents or manage many agents for your product.
An agent is the Sponge identity that owns wallets and permissions. In a
multi-user app, you typically create one Sponge agent per user, bot, workflow,
or worker. Each agent gets its own agent API key. Your backend can use
SpongePlatform to provision those agents, then store the returned agent key
with your own user or worker record. At runtime, use SpongeWallet with that
agent key so actions are scoped to the correct agent.
Install
pip install paysponge
Quick Start
Use an agent API key with SpongeWallet. The wallet client acts on behalf of
one Sponge agent.
from paysponge import SpongeWallet
wallet = SpongeWallet.connect(api_key="sponge_test_xxx")
agent = wallet.get_agent()
addresses = wallet.get_addresses()
balances = wallet.get_balances()
print(agent.id)
print(addresses)
print(balances)
An agent is the Sponge identity that owns the wallets and permissions used by
the SDK. wallet.get_agent() fetches the current agent for the API key and
stores its agent.id on the client, so later calls can use that agent by
default.
You can also read the API key from the environment:
export SPONGE_API_KEY=sponge_test_xxx
from paysponge import SpongeWallet
wallet = SpongeWallet.connect()
print(wallet.get_addresses())
Platform Usage
Use a master/platform API key with SpongePlatform when your backend needs to
create or manage agents. Platform keys are higher-trust credentials and should
stay on your server. They are for provisioning and administration, not for
day-to-day agent actions.
from paysponge import SpongePlatform
platform = SpongePlatform.connect(api_key="sponge_master_xxx")
agent = platform.create_agent(name="Hackathon Agent")
print(agent.id)
Typical platform flow:
- Your backend authenticates with
SpongePlatformusing a master key. - It creates a Sponge agent for a user, bot, or worker.
- It stores the returned agent API key with your own application record.
- Runtime code uses
SpongeWalletwith that agent API key.
Examples
Source examples are available in the repository:
mobwallet/python/paysponge/examples/basic.pymobwallet/python/paysponge/examples/transfer.pymobwallet/python/paysponge/examples/basic_sdk.py
From a clone of the repository:
cd mobwallet/python/paysponge
SPONGE_API_KEY=sponge_test_xxx uv run python examples/basic.py
SPONGE_API_KEY=sponge_test_xxx RECIPIENT_ADDRESS=0x... uv run python examples/transfer.py
Common Methods
wallet.get_agent()
wallet.get_addresses()
wallet.get_balances()
wallet.get_wallets()
wallet.transfer(chain="base", to="0x...", amount="1.00", currency="USDC")
wallet.issue_virtual_card(
amount="25.00",
merchant_name="Example Store",
merchant_url="https://example.com",
)
wallet.get_sponge_card_status()
wallet.paid_fetch(url="https://example.com")
Cards
Card methods live on SpongeWallet, because cards are issued or managed for a
specific Sponge agent:
card = wallet.issue_virtual_card(
amount="25.00",
currency="USD",
merchant_name="Example Store",
merchant_url="https://example.com",
)
status = wallet.get_sponge_card_status(refresh=True)
Available card helpers include:
wallet.store_credit_card(...)wallet.get_stored_credit_card()wallet.get_card(...)wallet.issue_virtual_card(...)wallet.report_card_usage(...)wallet.get_sponge_card_status(...)wallet.onboard_sponge_card(...)wallet.accept_sponge_card_terms(...)wallet.create_sponge_card(...)wallet.get_sponge_card_details()wallet.fund_sponge_card(...)wallet.withdraw_sponge_card(...)wallet.add_link_payment_method(...)wallet.create_link_payment_credential(...)
Links
- Documentation: https://docs.paysponge.com
- Repository: https://github.com/paysponge/sponge
- Issues: https://github.com/paysponge/sponge/issues
Tests
From a clone of the repository:
cd mobwallet/python/paysponge
uv run python -m unittest discover -s tests
Project details
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 paysponge-0.1.3.tar.gz.
File metadata
- Download URL: paysponge-0.1.3.tar.gz
- Upload date:
- Size: 113.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99a2faf9a8c856a438c60621791815e7f6afccc85c271d6678660bfca7b024f6
|
|
| MD5 |
04ef2f47da0e8c0942762a71b1c24c7d
|
|
| BLAKE2b-256 |
f6cc8b0939ca9340bfac5f1de322b9845260dd64e150bb6defbc4c6fb032d1ee
|
Provenance
The following attestation bundles were made for paysponge-0.1.3.tar.gz:
Publisher:
sdk-publish.yml on paysponge/sponge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paysponge-0.1.3.tar.gz -
Subject digest:
99a2faf9a8c856a438c60621791815e7f6afccc85c271d6678660bfca7b024f6 - Sigstore transparency entry: 1554603267
- Sigstore integration time:
-
Permalink:
paysponge/sponge@d3e3ee82617522f5c4087362b0c78e4a806c3460 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/paysponge
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-publish.yml@d3e3ee82617522f5c4087362b0c78e4a806c3460 -
Trigger Event:
push
-
Statement type:
File details
Details for the file paysponge-0.1.3-py3-none-any.whl.
File metadata
- Download URL: paysponge-0.1.3-py3-none-any.whl
- Upload date:
- Size: 284.8 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 |
ee82512d4a52babc6b82246e72d644c38338f8289e9b6057c1c25cbd155fe78a
|
|
| MD5 |
8db897cf8e6c1b8263c713dd7abaa78b
|
|
| BLAKE2b-256 |
b56d368adbadc02895f12fc676c96da5864416e4ddffc154bde4723ce72623d8
|
Provenance
The following attestation bundles were made for paysponge-0.1.3-py3-none-any.whl:
Publisher:
sdk-publish.yml on paysponge/sponge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
paysponge-0.1.3-py3-none-any.whl -
Subject digest:
ee82512d4a52babc6b82246e72d644c38338f8289e9b6057c1c25cbd155fe78a - Sigstore transparency entry: 1554603284
- Sigstore integration time:
-
Permalink:
paysponge/sponge@d3e3ee82617522f5c4087362b0c78e4a806c3460 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/paysponge
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-publish.yml@d3e3ee82617522f5c4087362b0c78e4a806c3460 -
Trigger Event:
push
-
Statement type: