Skip to main content

Yet another resource mapper.

Project description

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.

Author

Balanced Developers (dev@balancedpayments.com) @bninja @mahmoudimus @mjallday

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

hype-1.1.tar.gz (2.3 kB view details)

Uploaded Source

File details

Details for the file hype-1.1.tar.gz.

File metadata

  • Download URL: hype-1.1.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for hype-1.1.tar.gz
Algorithm Hash digest
SHA256 c01bb22fcb76eace83c15490b9d25b399809fa36dda1e1d7ed2ae897b45a37b0
MD5 2aa4c310ddabe5e0d6f7efad42ab7e6d
BLAKE2b-256 5d2ae61615ff9efc821e9139032ddc313ea9beda3ad22f742e5baed758493ef1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page