WSME
raw JSON → 0.12.1 verified Fri May 01 auth: no python
WSME (Web Service Made Easy) simplifies writing REST APIs by using Python type annotations to define web service protocols, supporting JSON and XML. Version 0.12.1 is the latest stable release, with a maintenance cadence.
pip install wsme Common errors
error No module named 'wsmeext' ↓
cause wsmeext subpackage removed in version 0.12; previously housed extensions like pecan.
fix
Use the replacement package eg 'pecan-wsme' or 'wsme' core only.
error ImportError: cannot import name 'WSPromise' from 'wsme' ↓
cause Older version of wsme (<0.11) didn't export WSPromise from the top level.
fix
Upgrade wsme to 0.11 or later: pip install wsme>=0.11
Warnings
breaking WSME 0.12 removed support for Python 2 and dropped the wsmeext.pecan module. Users must migrate to Python 3.8+ and use pecan-wsme instead. ↓
fix Upgrade to Python >=3.8 and replace 'from wsmeext.pecan import ...' with 'from pecan_wsme import ...' (install pecan-wsme).
deprecated Importing types from wsme.api is deprecated; use from wsme import types instead. ↓
fix Change imports to 'from wsme import types'.
gotcha Type annotations must be strings (types.text) not Python builtins (str). Using builtins may cause serialization errors. ↓
fix Always use wsme.types types, e.g., types.text, types.int, etc.
Imports
- WSPromise wrong
from wsme.api import WSPromisecorrectfrom wsme import WSPromise - types wrong
import wsme.typescorrectfrom wsme import types
Quickstart
from wsme import WSPromise, types
class MyService:
@WSPromise(returns=types.text)
def greet(self, name: types.text) -> str:
return f"Hello, {name}!"
if __name__ == '__main__':
# In a real app, you would set up a WSGI server
pass