{"id":27219794,"url":"https://github.com/gotz1480/ultra-minimal-fast-rest-api","last_synced_at":"2025-04-10T06:05:20.476Z","repository":{"id":56749108,"uuid":"524488214","full_name":"gotz1480/ultra-minimal-fast-rest-api","owner":"gotz1480","description":"Ultra minimal and fast RESTful API written in C using Unix websockets, POSIX threads and SQLite database. Ideal for mock APIs in dev environment.","archived":false,"fork":false,"pushed_at":"2024-07-19T05:28:24.000Z","size":90,"stargazers_count":14,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T13:13:20.592Z","etag":null,"topics":["c-api","minimal-api","mock-api","mock-apis","mock-server","rest-api","restful-api","sqlite-orm","sqlite3","sqlite3-orm"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gotz1480.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":"2022-08-13T19:19:48.000Z","updated_at":"2024-12-17T14:22:08.000Z","dependencies_parsed_at":"2025-04-04T13:13:23.281Z","dependency_job_id":"0807b65d-4207-4196-96ab-ac45d98cd6f5","html_url":"https://github.com/gotz1480/ultra-minimal-fast-rest-api","commit_stats":null,"previous_names":["gotz1480/ultra-minimal-fast-rest-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fultra-minimal-fast-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fultra-minimal-fast-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fultra-minimal-fast-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gotz1480%2Fultra-minimal-fast-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gotz1480","download_url":"https://codeload.github.com/gotz1480/ultra-minimal-fast-rest-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166938,"owners_count":21058481,"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","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":["c-api","minimal-api","mock-api","mock-apis","mock-server","rest-api","restful-api","sqlite-orm","sqlite3","sqlite3-orm"],"created_at":"2025-04-10T06:03:52.810Z","updated_at":"2025-04-10T06:05:20.427Z","avatar_url":"https://github.com/gotz1480.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ultra-minimal-fast-rest-api\n\nA minimal and fast RESTful API potentially useful for developing mock APIs with basic CRUD (create/read/update/delete) functionality. Written in C using Unix websockets, POSIX threads for multi-threaded server and integrated with SQLite.\n\n## Running on Docker\n\n### Requirements\n\n`docker` \u003cbr\u003e\n`docker compose`\n\n### Running\n\n`./run_container`\n\n## Running locally (Linux)\n\n### Requirements\n\n`libsqlite3-dev` \u003cbr\u003e\n`make` \u003cbr\u003e\n`gcc` \u003cbr\u003e\n\n### Running\n\n`./run_locally`\n\n## Getting started\n\nYou can define your model at the xml file named `models.xml`. A user model is provided as example for a database table:\n\n```\n\u003cmodel name=\"users\"\u003e\n\u003ccol name=\"name\"\u003eTEXT\u003c/col\u003e\n\u003ccol name=\"surname\"\u003eTEXT\u003c/col\u003e\n\u003ccol name=\"age\"\u003eINT\u003c/col\u003e\n\u003ccol name=\"height\"\u003eREAL\u003c/col\u003e\n\u003c/model\u003e\n```\n\nIn the `main.c` file, start the server with `create_server(server_socket, \"\u003cip-adress\u003e\", \u003cport\u003e, \u003cmax_number_of_connections\u003e)`. Default IP address is 0.0.0.0, default port is 9002 and default maximum number of simultaneous connections is 10.\n\n### Tests\n\nA simple Python file located in `tests/tests.py` can be used to test each endpoint.\n\nThe server should be available at `http://localhost:9002`.\n\n## Project structure overview\n\n### settings.h\n\nContains the server settings. Currently, the only setting is ALLOWED_HOSTS, which contains an array of strings corresponding to the accepted client IP addresses.\n\n### models.h\n\nContains the database model. On this example, the model consists of a simple \"user\" table with fields \"name\" and \"surname\". Example of an user entry in JSON format:\n\n```\n{\n    \"id\": 1,\n    \"name\": \"Giga\",\n    \"surname\": \"Chad\",\n    \"age\": 29\n}\n```\n\n### routes.h\n\nContains the method to automatically generate basic CRUD routes. Example:\n\n`GET /` - root with \"Hello world\" message \u003cbr\u003e\n`GET /users` - lists all users in .json format \u003cbr\u003e\n`GET /users/\u003cid\u003e` - list user data by its id \u003cbr\u003e\n`PUT /users/\u003cid\u003e` - update user data by its id \u003cbr\u003e\n`DELETE /users/\u003cid\u003e` delete user by its id \u003cbr\u003e\n`POST /users` - creates a new user \u003cbr\u003e\n\n### database.h\n\nIntegrates the requests from the HTTP methods to the SQLite database and parses JSON data.\n\n### views.h\n\nThe views related to each route and its respective HTTP methods, performing calls to the database.\n\n### server.h\n\nContains functions that implement a multi-threaded server using Unix sockets and POSIX threads.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotz1480%2Fultra-minimal-fast-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgotz1480%2Fultra-minimal-fast-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgotz1480%2Fultra-minimal-fast-rest-api/lists"}