{"id":22197627,"url":"https://github.com/flysirin/todo_tasks_restful_api","last_synced_at":"2026-05-05T12:33:56.032Z","repository":{"id":223061700,"uuid":"759215290","full_name":"flysirin/todo_tasks_restful_api","owner":"flysirin","description":"This is an example of how to build a RESTful API that performs CRUD operations on a MySQL database using Flask and the extension, Flask-RESTful. The particular application is creating a to-do list.","archived":false,"fork":false,"pushed_at":"2024-03-10T19:19:48.000Z","size":49,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T22:45:02.708Z","etag":null,"topics":["api","flask","mysql","restful-api","server","todo","todolist"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flysirin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-18T00:46:22.000Z","updated_at":"2024-09-09T11:11:09.000Z","dependencies_parsed_at":"2024-02-22T10:45:56.620Z","dependency_job_id":"a61cf398-5601-4ed5-8d09-110233708543","html_url":"https://github.com/flysirin/todo_tasks_restful_api","commit_stats":null,"previous_names":["flysirin/todo_tasks_restfull_api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/flysirin/todo_tasks_restful_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flysirin%2Ftodo_tasks_restful_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flysirin%2Ftodo_tasks_restful_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flysirin%2Ftodo_tasks_restful_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flysirin%2Ftodo_tasks_restful_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flysirin","download_url":"https://codeload.github.com/flysirin/todo_tasks_restful_api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flysirin%2Ftodo_tasks_restful_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32649596,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","flask","mysql","restful-api","server","todo","todolist"],"created_at":"2024-12-02T14:20:18.491Z","updated_at":"2026-05-05T12:33:56.014Z","avatar_url":"https://github.com/flysirin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Todo tasks RESTful API  \nThis is an example of how to build a RESTful API that performs CRUD operations on a MySQL database using Flask and the extension, Flask-RESTful.\nThe particular application is creating a to-do list. Flexible settings for database configurations with Application Factories.\n\n\n# Link to my GitHub\nhttps://github.com/flysirin/todo_tasks_restful_api\n\n## Contents:\n**app.py** - Defines the flask app, and the Flask RESTful api endpoints defined on top of it      \n**models.py** - Defines the data model, implemented with the Flask SQLAlchemy ORM  \n**error_handlers.py** - error handlers when working with the database  \n**config.py** - Configuration file with parameters loaded from **.env**   \n**configmodule.py** - configuration classes for accessing the database and for flexible changes to server settings  \n**create_db.py** - Create database    \n**tests.py** - Testing of API endpoints using Python unittest module     \n\n\n## How to use:\n\nSet up your database and launch it, more details here:  \nhttps://dev.mysql.com/doc/mysql-getting-started/en/\n\nMake sure, that you are using the correct credentials to access the database\n\nChange login, password, host, port and database credential in   **.env**  \n\n**_Attention! Using configurations to set up a database like DevelopmentConfig, ProductionConfig in tests.py\nmay lead to data deletion. Use TestingConfig or create your own setup classes for tests_**  \n\nInstall requirements\n```\npip install -r requirements.txt\n```\n\nCreate database\n```\npython3 create_db.py\n```\nRun server\n```\npython3 app.py\n```\n\nTo access the api from the command line:\n\nGET request (for task with id 1):\n```\ncurl -u login:pass http://localhost:5000/todo/1\n\n```\n\nGET all tasks:  \n```\ncurl -u login:pass http://localhost:5000/todo\n\n```\nPOST request:\n```\ncurl -u login:pass http://localhost:5000/todo -X POST -H \"Content-Type:application/json\" -d '{\"title\":\"New task\",\"description\":\"ToDo something\"}'\n```\n\nPUT request:\n```\ncurl -X PUT -u login:pass -H \"Content-Type: application/json\" -d '{\"title\": \"Updated Title\", \"description\": \"Updated Description\"}' http://localhost:5000/todo/1\n```\n\nDELETE request:\n```\ncurl -X DELETE -u login:pass http://localhost:5000/todo/1\n```  \n\n## Flask-RESTful:\n\nSimplicity and Structure: Flask-RESTful provides a straightforward way to structure RESTful APIs in Flask. It encourages a clear and consistent organization of resources using classes as resources.\nRequest Parsing: The library comes with a built-in request parsing mechanism (reqparse), making it easier to handle and validate incoming JSON data or form data.\nMarshaling: Flask-RESTful includes support for object serialization, helping in transforming complex data types into JSON responses.\nJustification:\n\nChose Flask-RESTful for its simplicity in structuring RESTful APIs and built-in tools like reqparse and marshaling, making it easier to handle and validate incoming requests and format responses consistently.\n\n## Flask-HTTPAuth:   \n\nAuthentication Support: Flask-HTTPAuth simplifies the implementation of authentication mechanisms in Flask applications. It provides decorators for protecting specific routes or resources.\nBasic HTTP Authentication: If your project requires basic HTTP authentication, Flask-HTTPAuth seamlessly integrates with Flask applications.\nCustomizable: It allows for customization, allowing you to implement authentication strategies that suit your project requirements.\nJustification:  \nIntegrated Flask-HTTPAuth to easily implement authentication in our Flask project. It's support for various authentication mechanisms and customization options made it the right choice for securing our API endpoints.  \n\n\n**Flask-RESTful documentation**      \nDefinitely read through the docs before building your own API. Start with the quickstart API\nand then move on to using argument parsing and field marshaling. Be aware that the API reference page\nis currently empty, and that there are other typos in the docs. Also, the `reqparse` functionality is being deprecated\nin favor of the external `marshmallow` package. I found that there weren't enough examples in the docs to figure out how to fit all of the components together\nin one app, but the docs were useful to refer to after looking at other examples. \nhttps://flask-restful.readthedocs.io/en/latest/\n\n\n## Application Factories  \n1) Testing. You can have instances of the application with different settings to test every case.\n\n2) Multiple instances. Imagine you want to run different versions of the same application. Of course you could have \nmultiple instances with different configs set up in your webserver, but if you use factories, you can have multiple\ninstances of the same application running in the same application process which can be handy.\nhttps://flask.palletsprojects.com/en/2.3.x/patterns/appfactories/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflysirin%2Ftodo_tasks_restful_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflysirin%2Ftodo_tasks_restful_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflysirin%2Ftodo_tasks_restful_api/lists"}