{"id":19062735,"url":"https://github.com/devinmatte/your-first-api","last_synced_at":"2026-04-12T14:55:24.668Z","repository":{"id":87301754,"uuid":"119728261","full_name":"devinmatte/Your-First-API","owner":"devinmatte","description":"A series of basic layouts that allow you to quickly learn how to spin up your own API in various languages","archived":false,"fork":false,"pushed_at":"2019-09-29T22:48:31.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"python_flask","last_synced_at":"2025-06-01T07:55:07.367Z","etag":null,"topics":["api","express","expressjs","flask","java","nodejs","php","python","rest-api","restful-api","slim","slim-framework","spring","tutorial"],"latest_commit_sha":null,"homepage":"https://medium.com/@devinmatte/intro-to-apis-67eb36057739","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devinmatte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2018-01-31T18:45:29.000Z","updated_at":"2020-02-22T16:51:14.000Z","dependencies_parsed_at":"2023-07-12T15:46:07.057Z","dependency_job_id":null,"html_url":"https://github.com/devinmatte/Your-First-API","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devinmatte/Your-First-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinmatte%2FYour-First-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinmatte%2FYour-First-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinmatte%2FYour-First-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinmatte%2FYour-First-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devinmatte","download_url":"https://codeload.github.com/devinmatte/Your-First-API/tar.gz/refs/heads/python_flask","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinmatte%2FYour-First-API/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278717444,"owners_count":26033542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","express","expressjs","flask","java","nodejs","php","python","rest-api","restful-api","slim","slim-framework","spring","tutorial"],"created_at":"2024-11-09T00:27:26.417Z","updated_at":"2025-10-07T03:46:31.738Z","avatar_url":"https://github.com/devinmatte.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Your First API, in Python\n======================\n\nDependencies\n------------\n\n- Python\n- pip\n\nTutorial\n--------\n\nFull tutorial can be found on [devinmatte.me](https://devinmatte.me/tutorial/2018/02/24/intro-to-apis/)\n\n\n### Getting Started\n\nLet's start with simply making a root route that returns \"Hello World!\" to the body of the response.\n\n\u003cul\u003e\n\u003cli\u003eFirst run \u003ccode\u003epip install -r requirements.txt\u003c/code\u003e\u003c/li\u003e\n\u003cul\u003e\n\u003cli\u003eMake sure you're using Python3, you may need to use \u003ccode\u003epip3\u003c/code\u003e instead of \u003ccode\u003epip\u003c/code\u003e on some systems.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cli\u003eEdit \u003ccode\u003e__init__.py\u003c/code\u003e and add the following route, then run \u003ccode\u003eapp.py\u003c/code\u003e to test.\u003c/li\u003e\n\u003c/ul\u003e\n\n```python\n@app.route(\"/\", methods=[\"GET\"])\ndef root():\n    return \"Hello World!\"\n```\n\n### Multiple Request Types\n\nNot every request in an API is **GET** in most cases. Often an API allows for you to make requests to change the underlying data in the system. In order to do this, you're going to want to take advantage of **POST**, **PUT** and **DELETE**. Doing so in each framework is fairly easy to define.\n\n```python\n# GET Request\n@app.route(\"/\", methods=[\"GET\"])\ndef root_get():\n    return \"Hello World!\"\n\n# POST Request\n@app.route(\"/\", methods=[\"POST\"])\ndef root_post():\n    return \"Got a POST request at /\"\n\n# PUT Request\n@app.route(\"/\", methods=[\"PUT\"])\ndef root_put():\n    return \"Got a PUT request at /\"\n\n# DELETE Request\n@app.route(\"/\", methods=[\"DELETE\"])\ndef root_delete():\n    return \"Got a DELETE request at /\"\n```\n\n### Using Status Codes\n\nHTTP requests are made up of two parts, the payload, and the status code. The status code tells whether a request was successful, or failed. It also allows for you handle the results of requests based on the code that it provides. Status codes are generally pretty consistent, so if you're confused what code to return, just reference the [spec](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status).\n\n```python\n# Return a 205\n@app.route(\"/success\", methods=[\"GET\"])\ndef return_success():\n    return \"This will return a 205 Status Code\", 205\n\n# Return a 404\n@app.route(\"/fail\", methods=[\"GET\"])\ndef return_fail():\n    return \"This will return a 404 Status Code\", 404\n```\n\n### Get Data to Return\n\nOften APIs are stateless, meaning that they get the data from somewhere. You aren't going to be storing data in data structures as your long term storage. Because of that you'll often interact with Databases. Each language works really well with a number of frameworks. I will recommend some good ORMs for each language below, but you should do your research to find one that works for your use case.\n\n\u003cb\u003eRecommended ORMs:\u003c/b\u003e\n\u003cul\u003e\n\u003cli\u003e\u003ca href=\"https://www.sqlalchemy.org/\"\u003eSqlAlchemy\u003c/a\u003e (\u003ca href=\"http://flask-sqlalchemy.pocoo.org/\"\u003eFlask SqlAlchemy\u003c/a\u003e)\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://www.djangoproject.com/\"\u003eDjango\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n### Continue Learning\n\nIf you want to learn more about APIs or any of these frameworks, there are plenty of good resources available.\n\n- [Flask](http://flask.pocoo.org/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevinmatte%2Fyour-first-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevinmatte%2Fyour-first-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevinmatte%2Fyour-first-api/lists"}