pythonflasksqlalchemyflask-restless

Creating API responses with flask-restless


Let's say I have two models in SqlAlchemy:

User has a foreign key to UserType

I have properly configured flask-restless to serve these models as API endpoints:

But by default, when I visit either of these endpoints, I get the related data associated with each object in the response:

This will definitely lead to a lot of overhead as the data grows a lot. If I just want to GET the list of UserType that the system supports, all of the associated users will come back. Usually an API would generate a link for related resources:

Has anyone gotten these links out of flask-restless responses?


Solution

  • It looks like this is a known issue that has been active on GitHub for a long time. Not sure if the developer is planning on fixing it or not:

    https://github.com/jfinkels/flask-restless/issues/168#issuecomment-69821642

    I ended up going with flask-restful and building my own endpoints.