A Python library for flexible resource mapping and API development. Hype provides a powerful way to define, traverse, and transform resources with support for multiple output formats including JSON, WAC-JSON, and URL-encoded forms.
Features
Resource mapping and traversal with cycle detection
Multiple output format support (JSON, WAC-JSON, API-JSON, URL-encoded)
Field-based resource definition with type validation
Automatic URL generation and linking between resources
Pagination support with cursor-based navigation
Flexible resource transformation pipeline
Thread-safe global context management
Installation
pip install hype
Requirements
Python 2.7
Usage
Here’s a quick example of defining and transforming a resource:
from hype import Resource, fields
class User(Resource):
name = fields.String()
email = fields.String()
profile = fields.Link(endpoint='profile.show')
# Transform to JSON
from hype.mime import application_json
def url_for(ref):
return f'/api/{ref.name}/{ref.params["id"]}'
user = User(name='John Doe', email='john@example.com')
json_output = application_json.serialize(user, url_for=url_for)
Documentation
Full documentation is available at https://github.com/balanced/hype/
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the ISC License - see the LICENSE file for details.
Metadata
Release files for hype 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hype-1.1.tar.gz | 2.3 kB | Details |
Release files / hype-1.1.tar.gz
| Download URL | hype-1.1.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c01bb22fcb76eace83c15490b9d25b399809fa36dda1e1d7ed2ae897b45a37b0
|
|
BLAKE2b-256 checksum How to use checksums |
5d2ae61615ff9efc821e9139032ddc313ea9beda3ad22f742e5baed758493ef1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.8.3 requests/2.27.1 setuptools/41.2.0 requests-toolbelt/1.0.0 tqdm/4.64.1 CPython/2.7.18
|