{"id":16490638,"url":"https://github.com/odaridavid/politico-api","last_synced_at":"2025-03-01T06:23:04.512Z","repository":{"id":111293432,"uuid":"168980437","full_name":"odaridavid/POLITICO-API","owner":"odaridavid","description":"Api  built with Python Flask Web Framework and Postgres backend for voting system","archived":false,"fork":false,"pushed_at":"2019-03-05T17:20:16.000Z","size":296,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-01-11T20:34:10.377Z","etag":null,"topics":["andela","andela-bootcamp","api","endpoints","flask","heroku","herokuapp","politico","python","python3","rest-api","restful-api","tdd","web-framework"],"latest_commit_sha":null,"homepage":"","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/odaridavid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2019-02-03T18:49:55.000Z","updated_at":"2023-02-24T19:01:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"f1e02e8f-1c3a-4cb5-a2d5-b96fcebec32b","html_url":"https://github.com/odaridavid/POLITICO-API","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odaridavid%2FPOLITICO-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odaridavid%2FPOLITICO-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odaridavid%2FPOLITICO-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/odaridavid%2FPOLITICO-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/odaridavid","download_url":"https://codeload.github.com/odaridavid/POLITICO-API/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241325707,"owners_count":19944419,"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":["andela","andela-bootcamp","api","endpoints","flask","heroku","herokuapp","politico","python","python3","rest-api","restful-api","tdd","web-framework"],"created_at":"2024-10-11T13:48:34.434Z","updated_at":"2025-03-01T06:23:04.484Z","avatar_url":"https://github.com/odaridavid.png","language":"Python","readme":"# POLITICO-API\n**POLITICO API** Is a pure Flask REST API app that serves endpoints for political parties,government offices,\npetitioning,voting and user login and sign up to be consumed by front end frameworks.\n\n!['PythonVersion''](https://img.shields.io/badge/python-3.6.7-yellow.svg)\n!['License'](https://img.shields.io/badge/License-MIT-green.svg)\n!['Travis'](https://travis-ci.org/Davidodari/POLITICO-API.svg?branch=develop)\n[![Coverage Status](https://coveralls.io/repos/github/Davidodari/POLITICO-API/badge.svg?branch=develop)](https://coveralls.io/github/Davidodari/POLITICO-API?branch=develop)\n[![Maintainability](https://api.codeclimate.com/v1/badges/4151dd7acdb2ddb19f1f/maintainability)](https://codeclimate.com/github/Davidodari/POLITICO-API/maintainability)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/33734615352249b6823b104b386a6ea7)](https://www.codacy.com/app/Davidodari/POLITICO-API?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=Davidodari/POLITICO-API\u0026amp;utm_campaign=Badge_Grade)\n[![Known Vulnerabilities](https://snyk.io/test/github/Davidodari/POLITICO-API/badge.svg)](https://snyk.io/test/github/Davidodari/POLITICO-API)\n### Endpoints  \n\n####  Url Prefix - /api/v1/\n\n\u003cdetails\u003e\n\n \u003csummary\u003e Version 1\u003c/summary\u003e\n \n|   ENDPOINT  | METHOD | STATUS |\n|:---:|:---:|:---:|\n| /offices                 |  GET     |  Gets List of offices |\n| /offices                 |  POST    |  Adds an office to List of offices  |\n| /parties                 |  GET     |  Gets List of Parties  |\n| /parties                 |  POST    |  Adds a party to list of parties  |\n| /parties/\u003cparty_id\u003e      |  GET     |  Gets a specific party  |\n| /parties/\u003cparty_id\u003e/name |  PATCH   |  Updates Name value of a party  |\n| /parties/\u003coffice_id\u003e/name|  PATCH   |  Updates Office value of a office  |\n| /parties/\u003cparty_id\u003e      |  DELETE  |  Deletes Specified Party |\n| /offices/\u003coffice_id\u003e     |  DELETE  |  Deletes Specified Office  |\n| /offices/\u003coffices_id\u003e    |  GET     |  Gets a specific office |\n| /users                   |  POST    |  Adds User to List Of Users  |\n\n\u003c/details\u003e\n\n####  Url Prefix - /api/v2/\n\n\u003cdetails\u003e\n\n \u003csummary\u003e Version 2\u003c/summary\u003e\n\n|   ENDPOINT  | METHOD | STATUS |\n|:---:|:---:|:---:|\n| /offices                 |  GET     |  Gets List of offices |\n| /offices                 |  POST    |  Adds an office to List of offices  |\n| /parties                 |  GET     |  Gets List of Parties  |\n| /parties                 |  POST    |  Adds a party to list of parties  |\n| /parties/\u003cparty_id\u003e      |  GET     |  Gets a specific party  |\n| /parties/\u003cparty_id\u003e/name |  PATCH   |  Updates Name value of a party  |\n| /parties/\u003coffice_id\u003e/name|  PATCH   |  Updates Office value of a office  |\n| /parties/\u003cparty_id\u003e      |  DELETE  |  Deletes Specified Party |\n| /offices/\u003coffice_id\u003e     |  DELETE  |  Deletes Specified Office  |\n| /offices/\u003coffices_id\u003e    |  GET     |  Gets a specific office |\n| /auth/signup             |  POST    |  Sign Up A User  |\n| /auth/login              |  POST    |  Login  An Existing User  |\n| /offices/\u003coffice_id\u003e/register             |  POST    |  Sign Up A Candidate For An Office  |\n| /offices/\u003coffice_id\u003e/register             |  GET    |   Get A Candidate For A Specific Office  |\n| /auth/login              |  POST    |  Login  An Existing User  |\n| /votes/              |  POST    |  Users Can Vote  |\n| /office/\u003coffice_id\u003e/results              |  POST    |  Users Can Vote  |\n\n\u003c/details\u003e\n\n## Author\n\n[David Odari](https://github.com/Davidodari)\n\n## Testing and Running Of App\n\n##### Heroku\n\nApp Link Hosted On Heroku\n\n[POLITICO-API on Heroku](https://blackpolitico-api-heroku.herokuapp.com/)\n\n##### API Documentation\n\n[POLITICO DOCS](https://politicoapi2.docs.apiary.io/#)\n\n##### Local Machine\n\n1. From your terminal clone The Repository on your machine \\ it will be on develop branch\n   `git clone https://github.com/Davidodari/POLITICO-API.git `\n\n3. Start virtual env if is installed and created ,with python 3\\ \n   `. venv/bin/activate` \\\n    to install the virtual env if missing use\\\n    ```pip3 install virtualenv```\\\n    and create virtual environment using the \\\n    ```python3 -m venv venv```\n    \n    Then Run The Above Commands to activate the virtual env when on the root folder of the project which will be\n    Politico API\n\n4. Install Flask in Virtual Environment    \n    -  The terminal will be instatiate a virtual env and appear similar to what is shown below\\\n   ```(venv)blackcoder@blackPC:~/POLITICO-API$ ```\n   -  Then Run \\\n    ```pip install -r requirements.txt``` \\\n    to download required packages for Flask\n    \n5. Run Flask App\n   - Then run the following commands to set up the environment and config in the terminal\n      - export FLASK_APP=run.py\n      - export FLASK_ENV=development\n      - export FLASK_DEBUG=1 ,This will reduce need to restart server in case you make changes\n   - A link to where the app is hosted will appear in the terminal as shown in the below format\n   ``` \n         * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n   ```\n   - With the above link apply a url prefix `/api/v1` such that its `http://127.0.0.1:5000/api/v1/endpoints`\n   \n5. Using an API Test Client like Postman or Insomnia you can run the above endpoints for each request.\n   The Bodys of Requests are below\\\n   \u003cdetails\u003e\n   \n   \u003csummary\u003e Models \u003c/summary\u003e\n   \n   **Office**\n   ```\n   {\n   \"name\":\"office_name\",\n   \"type\":\"office_type\"\n   }\n   ```\n   **Party**\n   ```\n   {\n   \"name\":\"party_name\",\n   \"hqAddress\":\"party_address\",\n   \"logoUrl\":\"party_logo\"\n   }\n   ```\n   **User**\n   ```\n   {\n   \"firstname\":\"first_name\",\n   \"lastname\":\"last_name\",\n   \"othername\":\"other_name\",\n   \"email\":\"dedaap@them.mail.com\",\n   \"phoneNumber\":\"+123442211\",\n   \"password\":\"password\"\n   }\n   ```\n   \u003c/details\u003e\n   \n   As for update just use `name` key and value on offices and parties \n7. For unit tests  on the root folder run `pytest --cov api tests` command and tests will\n   automatically be run with coverage \n   If not installed run the following command in terminal to install pytest with coverage in venv and run above  \\\n   ```pip install -U pytest-cov```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodaridavid%2Fpolitico-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fodaridavid%2Fpolitico-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fodaridavid%2Fpolitico-api/lists"}