Sokoweb package
Project description
SokoWeb - Decentralized Open Commerce Network
🌐 Overview
SokoWeb is a distributed commerce platform that enables peer-to-peer product and service listings with powerful search and discovery capabilities. Built on decentralized technology, it allows users to create, manage, and discover listings across the network.
🚀 Quick Start Guide
Install and launch SokoWeb with these simple commands:
pip install sokoweb
# Start in interactive mode
sokoweb-up
# Or start in detached mode
sokoweb-up -d
Configuration
During startup, you'll be prompted to configure:
| Parameter | Default | Description |
|---|---|---|
| NODE_PORT | 8000 | HTTP API port |
| NODE_TCP_PORT | 8500 | TCP communication port |
| ADVERTISE_IP | localhost | Your node's public address |
Important: For full network participation, use a public IP or domain name. Localhost mode works for testing but won't connect to the wider network. Note that tunneling services like Ngrok are not compatible as SokoWeb requires direct UDP and TCP access.
💻 System Requirements
- Python 3.9 or higher
- Docker 27.3.1 or higher
- docker compose 2.29.7 or higher
📚 API Reference
Authentication
Create a New User Account
curl -X POST http://localhost:8000/register \
-H "Content-Type: application/json" \
-d '{
"username": "alice",
"password": "alice123",
"email": "alice@example.com",
"full_name": "Alice Wonderland",
"phone_number": "+254712345678",
"scopes": ["products:write", "products:read", "credits:manage"]
}'
Obtain Access Token
curl -X POST http://localhost:8000/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=alice&password=alice123&scope=products:write products:read credits:manage"
Available Permission Scopes
| Scope | Description |
|---|---|
| products:write | Create and modify product listings |
| products:read | View product listings |
| credits:manage | Purchase and manage account credits |
| categories:write | Suggest new product categories |
| categories:read | View available categories |
Product Management
Create a New Product Listing
curl -X POST http://localhost:8000/products \
-H "Authorization: Bearer <your_token>" \
-H "Content-Type: application/json" \
-d '{
"core": {
"name": "Smartphone",
"category": "Electronics",
"price": 500.00,
"description": "New smartphone",
"seller_phone": "+254712345678",
"shop_name": "Tech Store",
"seller_location": [-1.2921, 36.8219]
},
"extended": {
"storage_duration_days": 1,
"tags": ["samsung S21","5G"],
"metadata": { "color": "black" }
}
}'
Upload Product Images
curl -X POST http://localhost:8000/products/{product_id}/image \
-H "Authorization: Bearer <your_token>" \
-F "image=@/path/to/image.jpg"
Product Retrieval
Get Product by ID
curl http://localhost:8000/products/{product_id} \
-H "Authorization: Bearer <your_token>"
Search by Category or Shop
curl "http://localhost:8000/products?category=Electronics&shop_name=Tech%20Store" \
-H "Authorization: Bearer <your_token>"
Location-Based Search
Find products within a specific radius (in kilometers):
curl "http://localhost:8000/products?latitude=-1.2921&longitude=36.8219&radius_km=10" \
-H "Authorization: Bearer <your_token>"
Combined Search Parameters
Combine multiple search criteria for precise results:
curl "http://localhost:8000/products?category=Electronics&latitude=-1.2921&longitude=36.8219&radius_km=5" \
-H "Authorization: Bearer <your_token>"
Image Retrieval
Get Primary Product Image
curl "http://localhost:8000/products/{product_id}/image" \
-H "Authorization: Bearer <your_token>"
This endpoint returns the raw image data that can be:
- Saved directly to a file using curl's
-ooption - Viewed in tools like Postman that can render binary responses
Download All Product Images
curl "http://localhost:8000/products/{product_id}/images" \
-H "Authorization: Bearer <your_token>" \
--output images_{product_id}.zip
This endpoint returns a ZIP archive containing all images associated with the product. The response is binary data that should be saved to disk and opened with any ZIP-compatible program.
Credits System
Check Account Balance
curl http://localhost:8000/credits/balance \
-H "Authorization: Bearer <your_token>"
Purchase Additional Credits
curl -X POST http://localhost:8000/credits/purchase \
-H "Authorization: Bearer <your_token>" \
-H "Content-Type: application/json" \
-d '{
"amount": 100,
"phone_number": "+254712345678"
}'
Category Management
# Suggest a new product category
curl -X POST http://<your-public-ip>:8000/categories/suggest \
-H "Authorization: Bearer <your_token>" \
-H "Content-Type: application/json" \
-d '{
"category_name": "Smart Home"
}'
# List all available categories
curl http://localhost:8000/categories \
-H "Authorization: Bearer <your_token>"
Note: When deploying to production, replace
localhostwith your server's public IP address or domain name.
🔧 Network Management
Monitor and manage your SokoWeb node:
- View running containers:
docker ps - Shut down your node:
sokoweb-down
👥 Contributing
SokoWeb is an open-source project and welcomes contributions from the community. Feel free to submit issues, feature requests, or pull requests.
📄 License
SokoWeb is released under the MIT License.
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 sokoweb-0.1.48.tar.gz.
File metadata
- Download URL: sokoweb-0.1.48.tar.gz
- Upload date:
- Size: 52.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64fad8f418a977bfab1f09897d9364b95d7bd8ffbd2df257e27642e92b6838a8
|
|
| MD5 |
1167a1521504c012800c5df17faf0e2c
|
|
| BLAKE2b-256 |
7dd2c36c224a7c34c3efb155df80407ecc98a03bdf4390d1ed739ead0f224ca6
|
File details
Details for the file sokoweb-0.1.48-py3-none-any.whl.
File metadata
- Download URL: sokoweb-0.1.48-py3-none-any.whl
- Upload date:
- Size: 58.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
832b009b598d2c7915bac23d438db3b7a71f6b7648f52f4fc4c390d55a221665
|
|
| MD5 |
dee9636d06cfdb774d5ed4846cb71739
|
|
| BLAKE2b-256 |
58b976c2730b8e9f23cae24dcfb8a3c7228d7e210932d3eed72f98b10cd3b75c
|