{"id":21262825,"url":"https://github.com/frankykyaw/rust-rest-api","last_synced_at":"2025-03-15T07:43:59.139Z","repository":{"id":167658102,"uuid":"642073695","full_name":"FrankyKyaw/Rust-Rest-API","owner":"FrankyKyaw","description":"Create a database to store laptop info and access them with an API endpoint","archived":false,"fork":false,"pushed_at":"2023-05-25T23:28:26.000Z","size":841,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-21T22:43:05.884Z","etag":null,"topics":["diesel-rs","psql-database","rest-api","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/FrankyKyaw.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,"publiccode":null,"codemeta":null}},"created_at":"2023-05-17T19:02:39.000Z","updated_at":"2023-05-17T19:09:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"eb9cbe75-dc62-48d9-8030-d3b2843b671b","html_url":"https://github.com/FrankyKyaw/Rust-Rest-API","commit_stats":null,"previous_names":["frankykyaw/rust-rest-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrankyKyaw%2FRust-Rest-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrankyKyaw%2FRust-Rest-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrankyKyaw%2FRust-Rest-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrankyKyaw%2FRust-Rest-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FrankyKyaw","download_url":"https://codeload.github.com/FrankyKyaw/Rust-Rest-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243701314,"owners_count":20333616,"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":["diesel-rs","psql-database","rest-api","rust"],"created_at":"2024-11-21T04:59:28.133Z","updated_at":"2025-03-15T07:43:59.132Z","avatar_url":"https://github.com/FrankyKyaw.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust-Rest-API\nThis project is a RESTful API developed using the [Rocket](https://rocket.rs) framework in Rust. It leverages [Diesel](http://diesel.rs) to interact with a database populated with a sample laptop dataset sourced from [Kaggle](https://www.kaggle.com/datasets/arnabchaki/laptop-price-prediction). The API provides full CRUD (Create, Read, Update, Delete) as well as query operations on the data.\n\n## Built With\n- [Rust](https://www.rust-lang.org)\n- [Rocket](https://rocket.rs)\n- [Diesel](http://diesel.rs)\n- [Serde](https://serde.rs/)\n\n\n## Usage\nHere's an example of how to use the API:\n\n### Get a laptop by ID\n```\nGET /laptop/\u003cid\u003e\n```\nRetrieve a laptop by its ID. If the laptop is found, it returns a JSON object of the laptop data, otherwise a `Status::NotFound` error is returned.\n\n### Get the total count of laptops\n```\nGET /count\n```\n\n### Search for laptops\n```\nGET /laptops/search?\u003cparams..\u003e\n```\nSearch for laptops by providing search parameters, such as `brand`, `min_price` and `max_price`.\nAn example API request would be like this:\n```\nlocalhost:8000/laptops/search?brand=Apple\u0026min_price=1000\u0026max_price=2000\n```\nIf the search is successful, it returns a JSON array of laptop objects that match the search parameters. If there's an error, it returns a `Status::InternalServerError` error.\n\n### Create a new laptop\n```\nPOST /laptop\n```\nCreates a new laptop record in the database. It requires a JSON object with `brand`, `model`, `cpu`, `gpu`, `ram_gb`, and `price`. It returns a JSON object of the newly created laptop.\n\n### Update a laptop  \n```\nPATCH /update/\u003cid\u003e\n```\nUpdates a laptop record in the database. It requires the ID of the laptop to update and a JSON object with `brand`, `model`, `cpu`, `gpu`, `ram_gb`, and `price`. If the update is successful, it returns a `Status::NoContent`, otherwise a `Status::InternalServerError` error.\n\n### Delete a laptop\n```\nDELETE /laptop/\u003cid\u003e\n```\nDeletes a laptop record from the database using its ID. If the deletion is successful, it returns a `Status::NoContent`, otherwise a `Status::InternalServerError` error.\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankykyaw%2Frust-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrankykyaw%2Frust-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankykyaw%2Frust-rest-api/lists"}