{"id":37990182,"url":"https://github.com/scottjason/trivia-api","last_synced_at":"2026-01-16T18:42:53.023Z","repository":{"id":228712536,"uuid":"715453100","full_name":"scottjason/trivia-api","owner":"scottjason","description":"Full Stack Project from Udacity's Full Stack Web Developer Nanodegree","archived":false,"fork":false,"pushed_at":"2023-11-07T07:11:07.000Z","size":173,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-26T00:26:39.088Z","etag":null,"topics":["flask","postgresql","python","react","sqlalchemy"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/scottjason.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":"2023-11-07T07:09:18.000Z","updated_at":"2023-11-07T07:20:35.000Z","dependencies_parsed_at":"2024-03-20T04:51:14.883Z","dependency_job_id":"67e9765f-fe9f-4133-9863-3a0ab2dd3077","html_url":"https://github.com/scottjason/trivia-api","commit_stats":null,"previous_names":["scottjason/trivia-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/scottjason/trivia-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottjason%2Ftrivia-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottjason%2Ftrivia-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottjason%2Ftrivia-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottjason%2Ftrivia-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scottjason","download_url":"https://codeload.github.com/scottjason/trivia-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scottjason%2Ftrivia-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28481168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"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":["flask","postgresql","python","react","sqlalchemy"],"created_at":"2026-01-16T18:42:52.856Z","updated_at":"2026-01-16T18:42:52.994Z","avatar_url":"https://github.com/scottjason.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Trivia Api\n\n## Full Stack Project from Udacity's [Full Stack Web Developer Nanodegree](https://www.udacity.com/course/full-stack-web-developer-nanodegree--nd0044)\n\n## Tech Stack\n- Python\n- Flask\n- SQLAlchemy\n- PostgreSQL\n- React\n\n## Installation\nOpen a new terminal window then navigate to the `backend` directory. Create and source a virtual environment in the `backend` directory like so:\n\n```\npython -m venv venv\nsource venv/bin/activate\n```\n\nThen install the dependencies:\n\n```\npip install -r requirements.txt\n```\n\nStart a postgreSQL server and create a database called `trivia`.\n\n```\ndropdb trivia\ncreatedb trivia\n```\n\nThen run:\n\n`psql trivia \u003c trivia.psql`\n\nNext in a second terminal window, navigate to the frontend directory and run: \n\n```\nnpm install\n```\n\n## Environment Variables\nIn the backend directory, create a `.env` file and copy and paste the below into the file. Then replace the value of DB_USER and DB_PASSWORD with your credentials.\n\n```bash\nDEBUG=True\nFLASK_APP=flaskr\nFLASK_ENV=development\nDB_HOST=127.0.0.1\nDB_PORT=5432\nDB_USER=postgres\nDB_PASSWORD=postgres\nDB_NAME=trivia\nDB_TEST_NAME=trivia_test\n```\n\n## Running the app\nTo start the app, run `npm start` in one terminal window in the frontend directory, then in the another terminal window, while under the backend directory, run `flask run`.\n\nThen visit http://localhost:3000.\n\n## Running the tests\nWith postgreSQL running, create a database called `trivia_test`.\n\n```\ndropdb trivia_test\ncreatedb trivia_test\n```\n\nThen run:\n\n`psql trivia_test \u003c trivia.psql`\n\nTo run the tests, while in the backend directory, run:\n\n```\npython test_flaskr.py\n```\n\n## API\n\n### `GET /categories`\n\n- Fetches a dictionary of categories with key as id and value as the category name.\n- Request Arguments: None\n- Returns: An object with a key, categories, and key / value pairs of id and category name.\n\n#### Example Response:\n```\ncategories: {\n  \"1\": \"Science\",\n  \"2\": \"Art\",\n  \"3\": \"Geography\",\n  \"4\": \"History\",\n  \"5\": \"Entertainment\",\n  \"6\": \"Sports\"\n}\n```\n\n### `GET /questions`\n\n- Fetches a dictionary of questions for the page the user is on, categories, total pages and current category. \n- Request Arguments: None\n- Returns: An object containing an array of objects of questions, categories, total questions and current_category as the other keys. The current_category should be null for this response.\n\n#### Example Response:\n```\n{\n  \"categories\": {\n    \"1\": \"Science\",\n    \"2\": \"Art\",\n    \"3\": \"Geography\",\n    \"4\": \"History\",\n    \"5\": \"Entertainment\",\n    \"6\": \"Sports\"\n  },\n  \"current_category\": null,\n  \"questions\": [\n    {\n      \"answer\": \"Apollo 13\",\n      \"category\": 5,\n      \"difficulty\": 4,\n      \"id\": 2,\n      \"question\": \"What movie earned Tom Hanks his third straight Oscar nomination, in 1996?\"\n    },\n    {\n      \"answer\": \"Tom Cruise\",\n      \"category\": 5,\n      \"difficulty\": 4,\n      \"id\": 4,\n      \"question\": \"What actor did author Anne Rice first denounce, then praise in the role of her beloved Lestat?\"\n    },\n    ...\n  ],\n  \"total_questions\": 20\n}\n```\n\n### `POST /questions`\n- Creates a new trivia question which includes the answer, category and difficulty level.\n- Request Arguments: post body contains `question` and `answer`, both of type string as well as `category` and `difficulty`, both of type int.\n- Returns `{ success: true }`\n\n\n### `DELETE /questions/\u003cquestion_id\u003e`\n- Deletes a question by id.\n- Request Arguments: `question_id` in the path, data type int.\n- Returns `{ success: true }`\n\n### `POST questions/search`\n- Searches for trivia questions that partially match the search term.\n- Request Arguments: post body contains `searchTerm` of type string.\n- Returns: An array of objects containing questions that partially match the search term as well as categories, total questions and current_category, which should be null for this response.\n\n#### Example Response:\n```\n{\n  \"categories\": {\n    \"1\": \"Science\",\n    \"2\": \"Art\",\n    \"3\": \"Geography\",\n    \"4\": \"History\",\n    \"5\": \"Entertainment\",\n    \"6\": \"Sports\"\n  },\n  \"current_category\": null,\n  \"questions\": [\n    {\n      \"answer\": \"Apollo 13\",\n      \"category\": 5,\n      \"difficulty\": 4,\n      \"id\": 2,\n      \"question\": \"What movie earned Tom Hanks his third straight Oscar nomination, in 1996?\"\n    },\n    {\n      \"answer\": \"Tom Cruise\",\n      \"category\": 5,\n      \"difficulty\": 4,\n      \"id\": 4,\n      \"question\": \"What actor did author Anne Rice first denounce, then praise in the role of her beloved Lestat?\"\n    },\n    ...\n  ],\n  \"total_questions\": 20\n}\n```\n\n### `GET categories/\u003ccategory_id\u003e/questions`\n- Fetches questions by category.\n- Request Arguments: the path contains the category id of type int representing the category of questions to return.\n- Returns: An array of objects including questions associated with the category selected as well as categories, total questions and current_category.\n\n#### Example Response:\n```\n{\n  \"categories\": {\n    \"1\": \"Science\",\n    \"2\": \"Art\",\n    \"3\": \"Geography\",\n    \"4\": \"History\",\n    \"5\": \"Entertainment\",\n    \"6\": \"Sports\"\n  },\n  \"current_category\": \"Science\",\n  \"questions\": [\n    {\n      \"answer\": \"Alexander Fleming\",\n      \"category\": 1,\n      \"difficulty\": 3,\n      \"id\": 21,\n      \"question\": \"Who discovered penicillin?\"\n    },\n    {\n      \"answer\": \"Blood\",\n      \"category\": 1,\n      \"difficulty\": 4,\n      \"id\": 22,\n      \"question\": \"Hematology is a branch of medicine involving the study of what?\"\n    },\n    ...\n  ],\n  \"total_questions\": 7\n}\n```\n\n### `POST /quizzes`\n- Fetches a random question from one category or all categories, depending on which the user selects.\n- Request Arguments: post body includes previous_questions, an array of question ids of questions that have already been asked as well as a quiz_category object which contains the category id selected by the user as well as the category type.\n- Returns: an object containing the question and answer both of type string as well as the category id, the id of the question and difficulty level of type int.\n\n#### Example Response:\n```\n{\n  \"answer\": \"Jackson Pollock\",\n  \"category\": 2,\n  \"difficulty\": 2,\n  \"id\": 19,\n  \"question\": \"Which American artist was a pioneer of Abstract Expressionism, and a leading exponent of action painting?\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottjason%2Ftrivia-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscottjason%2Ftrivia-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscottjason%2Ftrivia-api/lists"}