---
title: "flask-marshmallow | pypx"
description: "Flask + marshmallow for beautiful APIs"
canonical_url: "https://pypx.app/packages/flask-marshmallow"
meta:
  "og:description": "Flask + marshmallow for beautiful APIs"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_flask-marshmallow%2Cversion_1.5.0%2Csummary_~Rmxhc2sgKyBtYXJzaG1hbGxvdyBmb3IgYmVhdXRpZnVsIEFQSXM%2Clicense_MIT%2Cp_Ii9wYWNrYWdlcy9mbGFzay1tYXJzaG1hbGxvdyI%2Cs_YN_tt0j-8hrXaxTx.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "flask-marshmallow 1.5.0"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_flask-marshmallow%2Cversion_1.5.0%2Csummary_~Rmxhc2sgKyBtYXJzaG1hbGxvdyBmb3IgYmVhdXRpZnVsIEFQSXM%2Clicense_MIT%2Cp_Ii9wYWNrYWdlcy9mbGFzay1tYXJzaG1hbGxvdyI%2Cs_YN_tt0j-8hrXaxTx.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **flask-marshmallow**

v1.5.0

Flask + marshmallow for beautiful APIs

12 KB Python 3.10+ py3-none-anyMIT2 deps

[**Diff **](https://pypx.app/packages/flask-marshmallow/diff)

`$ uv add flask-marshmallow`

\*

##### Flask-Marshmallow

[![Latest version](https://badgen.net/pypi/v/flask-marshmallow)](https://pypi.org/project/flask-marshmallow/) [![Build status](https://github.com/marshmallow-code/flask-marshmallow/actions/workflows/build-release.yml/badge.svg)](https://github.com/marshmallow-code/flask-marshmallow/actions/workflows/build-release.yml) [![Documentation](https://readthedocs.org/projects/flask-marshmallow/badge/)](https://flask-marshmallow.readthedocs.io/) [![marshmallow 3|4 compatible](https://badgen.net/badge/marshmallow/3,4?list=1)](https://marshmallow.readthedocs.io/en/latest/upgrading.html)

# Flask + marshmallow for beautiful APIs

Flask-Marshmallow is a thin integration layer for `Flask`\_ (a Python web framework) and `marshmallow`\_ (an object serialization/deserialization library) that adds additional features to marshmallow, including URL and Hyperlinks fields for HATEOAS-ready APIs. It also (optionally) integrates with [Flask-SQLAlchemy](http://flask-sqlalchemy.pocoo.org/).

## Get it now

```
pip install flask-marshmallow
```

Create your app.

```python
from flask import Flask
from flask_marshmallow import Marshmallow

app = Flask(__name__)
ma = Marshmallow(app)
```

Write your models.

```python
from your_orm import Model, Column, Integer, String, DateTime


class User(Model):
    email = Column(String)
    password = Column(String)
    date_created = Column(DateTime, auto_now_add=True)
```

Define your output format with marshmallow.

```python
class UserSchema(ma.Schema):
    email = ma.Email()
    date_created = ma.DateTime()

    # Smart hyperlinking
    _links = ma.Hyperlinks(
        {
            "self": ma.URLFor("user_detail", values=dict(id="<id>")),
            "collection": ma.URLFor("users"),
        }
    )


user_schema = UserSchema()
users_schema = UserSchema(many=True)
```

Output the data in your views.

```python
@app.route("/api/users/")
def users():
    all_users = User.all()
    return users_schema.dump(all_users)


@app.route("/api/users/<id>")
def user_detail(id):
    user = User.get(id)
    return user_schema.dump(user)


# {
#     "email": "fred@queen.com",
#     "date_created": "Fri, 25 Apr 2014 06:02:56 -0000",
#     "_links": {
#         "self": "/api/users/42",
#         "collection": "/api/users/"
#     }
# }
```

# http://flask-marshmallow.readthedocs.io/

# Learn More

To learn more about marshmallow, check out its [docs](http://marshmallow.readthedocs.io/en/latest/).

# Project Links

- Docs: https://flask-marshmallow.readthedocs.io/
- Changelog: http://flask-marshmallow.readthedocs.io/en/latest/changelog.html
- PyPI: https://pypi.org/project/flask-marshmallow/
- Issues: https://github.com/marshmallow-code/flask-marshmallow/issues

# License

MIT licensed. See the bundled [LICENSE](https://github.com/marshmallow-code/flask-marshmallow/blob/master/LICENSE) file for more details.

## **Details **

<dl>

<dt>Version</dt>
<dd>1.5.0</dd>

<dt>License</dt>
<dd>MIT</dd>

<dt>Python</dt>
<dd>&gt;=3.10</dd>

</dl>

## **Links**

- [Funding](https://opencollective.com/marshmallow)
- [Issues](https://github.com/marshmallow-code/flask-marshmallow/issues)
- [View on PyPI](https://pypi.org/project/flask-marshmallow/)

## **Release Cadence **

**2**

releases in the past year

avg 175 days between releases

## **Maintainers **

- Steven Loria · [oss@stevenloria.com](mailto:oss@stevenloria.com)
- Stephen Rosen · [sirosen0@gmail.com](mailto:sirosen0@gmail.com)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/flask-marshmallow#webpage","@type":"WebPage","description":"Flask + marshmallow for beautiful APIs","name":"flask-marshmallow","url":"https://pypx.app/packages/flask-marshmallow","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/flask-marshmallow"]}]},{"@id":"https://pypx.app/packages/flask-marshmallow#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"Flask + marshmallow for beautiful APIs","license":"MIT","name":"flask-marshmallow","softwareVersion":"1.5.0"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
