{"id":27448575,"url":"https://github.com/philmccarthy/rails-api","last_synced_at":"2026-04-15T15:33:49.434Z","repository":{"id":53672036,"uuid":"340094921","full_name":"philmccarthy/rails-api","owner":"philmccarthy","description":"A JSON API that serves up REST and business intelligence endpoints.","archived":false,"fork":false,"pushed_at":"2021-03-19T20:35:03.000Z","size":692,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-16T15:37:22.941Z","etag":null,"topics":["json-api","postgresql","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/philmccarthy.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}},"created_at":"2021-02-18T15:35:48.000Z","updated_at":"2021-02-20T20:04:11.000Z","dependencies_parsed_at":"2022-09-10T19:30:10.001Z","dependency_job_id":null,"html_url":"https://github.com/philmccarthy/rails-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/philmccarthy/rails-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philmccarthy%2Frails-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philmccarthy%2Frails-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philmccarthy%2Frails-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philmccarthy%2Frails-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philmccarthy","download_url":"https://codeload.github.com/philmccarthy/rails-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philmccarthy%2Frails-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31847890,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: 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":["json-api","postgresql","rails","ruby"],"created_at":"2025-04-15T07:26:31.287Z","updated_at":"2026-04-15T15:33:49.408Z","avatar_url":"https://github.com/philmccarthy.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n*** Thanks for checking out the Best-README-Template. If you have a suggestion\n*** that would make this better, please fork the repo and create a pull request\n*** or simply open an issue with the tag \"enhancement\".\n*** Thanks again! Now go create something AMAZING! :D\n--\u003e\n\n\n\n\u003c!-- PROJECT SHIELDS --\u003e\n\u003c!--\n*** I'm using markdown \"reference style\" links for readability.\n*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).\n*** See the bottom of this document for the declaration of the reference variables\n*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.\n*** https://www.markdownguide.org/basic-syntax/#reference-style-links\n--\u003e\n[![LinkedIn][linkedin-shield]][linkedin-url]\n\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails open=\"open\"\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#built-with\"\u003eBuilt With\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#prerequisites\"\u003ePrerequisites\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#rest-endpoints\"\u003eReST Endpoints\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#non-rest-endpoints\"\u003eNon-ReST Endpoints\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\n\nThis Rails-backed JSON API was built in 6 days while I was in Mod 3 of [Turing School's](https://turing.io) Backend Engineering program.\n\nAreas of exploration and learning on this project included:\n\n* Expose an API\n* Use serializers to format JSON responses\n* Test API exposure with RSpec and Postman\n* Compose advanced ActiveRecord queries to analyze information stored in PostgreSQL database\n* Write SQL statements without the assistance of an ORM\n* Implement json:api standards\n* Add custom error responses for invalid API requests\n\n\n### Built With\n\n* [Ruby on Rails](https://rubyonrails.org/)\n* [PostgreSQL](https://www.postgresql.org/)\n* [Postman](https://www.postman.com/)\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\n1. Clone this repo\n2. Install gem packages: `bundle`\n3. Setup the database. A pgdump is included in `./db` to seed the database\n\n    `rails db:{create,migrate,seed}`\n4. Run the RSpec test suite: `bundle exec rspec`\n5. Start your local server: `rails s`\n\nA Postman test suite also exists to test the endpoints served via localhost!\n\n- Download the [Postman Collection](https://www.getpostman.com/collections/f05c0b0f67b6dfc23a65) JSON file _(right click the link and 'save as')_\n- In Postman, in the top left corner, click on the 'Import' button, and drag the downloaded JSON file over the interface or use the file selector to locate the file on your operating system. Click 'Import' to continue\n- In the top left corner of the Postman interface, you’ll see a 'Runner' button. Click that and a new Postman window will appear. From here, you can select 'Rails API (by Phil McCarthy)' from the list of 'All Collections'\n\n### Prerequisites\n\n* Ruby 2.5.3\n* Rails 5.2.4\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## ReST Endpoints\n\n### Get All Merchants\n\nOptional Parameters: `?per_page` (defaults to 20 results) and `?page`.\n\n  ```\n  GET /api/v1/merchants?per_page=x\u0026page=x\n  ```\n\n### Get One Merchant\n\n  ````\n  GET /api/v1/merchants/:id\n  ````\n\n### Get a Merchant's Items\n\n  ```\n  GET /api/v1/merchants/:id/items\n  ```\n\n\n### Get All Items\n\nOptional Parameters: `?per_page` (defaults to 20 results) and `?page`.\n\n```\nGET /api/v1/items?per_page=x\u0026page=x\n```\n\n\n### Get One Item\n\n```\nGET /api/v1/items/:id\n```\n\n\n### Get an Item's Merchant\n\n```\nGET /api/v1/items/:id/merchant\n```\n\n\n### Update One Item\n\n```\nPATCH /api/v1/items/:id\n```\n\nItem attributes:\n\n  ```json\n  {\n    \"name\": \"value1\",\n    \"description\": \"value2\",\n    \"unit_price\": 100.99,\n    \"merchant_id\": 14\n  }\n  ```\n\n\n### Create One Item\n\n  ```\n  POST /api/v1/items/\n  ```\n\nCreate item body format:\n\n  ```json\n  {\n    \"name\": \"value1\",\n    \"description\": \"value2\",\n    \"unit_price\": 100.99,\n    \"merchant_id\": 14\n  }\n  ```\n\n### Delete One Item\n\n```\nDELETE /api/v1/items/:id\n```\n\n## Non-ReST Endpoints\n\n### Find All Merchants by Fragment\n\nRequired Parameter: `?name`.\n\n  ```\n  GET /api/v1/merchants/find_all?name=x\n  ```\n\n### Find One Item by Fragment\n\nParameter(s): `?name`, `min_price` and `max_price`.\n\n- At least one parameter is required\n- Name _cannot_ be combined with either/both price parameters\n- Minimum price and maximum price _can_ be used alone or together to query a price range\n\n```\nGET /api/v1/items/find?name=x OR ?min_price=x\u0026max_price=y\n```\n\n### Get Merchants with Most Revenue\n\nRequired Parameter: `?quantity` is required\n\n```\nGET /api/v1/revenue/merchants?quantity=x\n```\n\n### Get Merchants who Sold Most Items\n\nOptional Parameter: `?quantity` is _not_ required for this query. Defaults to 5 results.\n\n```\nGET /api/v1/merchants/most_items?quantity=\n```\n\n### Get Revenue of a Single Merchant\n\n```\nGET /api/v1/revenue/merchants/:id\n```\n\n### Get Items with Most Revenue\n\nOptional Parameter: `?quantity` is _not_ required. Defaults to 10 results.\n\n```\nGET /api/v1/revenue/items?quantity=x\n```\n\n### Get Potential Revenue of Unshipped Invoices\n\nOptional Parameter: `?quantity` is _not_ required. Defaults to 10 results.\n\n```\nGET /api/v1/revenue/unshipped?quantity=x\n```\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nPhil McCarthy — [LinkedIn](https://linkedin.com/in/pjmcc) — [philmccarthy.dev](https://philmccarthy.dev)\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n[linkedin-url]: https://linkedin.com/in/pjmcc\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilmccarthy%2Frails-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilmccarthy%2Frails-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilmccarthy%2Frails-api/lists"}