{"id":50269594,"url":"https://github.com/vitor-araujo/stocks_api","last_synced_at":"2026-05-27T16:04:40.992Z","repository":{"id":250209790,"uuid":"832644072","full_name":"vitor-araujo/stocks_api","owner":"vitor-araujo","description":"Flask api to fetch stock data from Polygon and Marketwatch and persist using supabase SDK","archived":false,"fork":false,"pushed_at":"2024-07-25T20:26:08.000Z","size":1505,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-26T22:39:40.239Z","etag":null,"topics":["api","flask","postgresql","python","scraping","stocks","web"],"latest_commit_sha":null,"homepage":"","language":"Python","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/vitor-araujo.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":"2024-07-23T12:40:18.000Z","updated_at":"2024-07-25T20:26:12.000Z","dependencies_parsed_at":"2024-07-25T22:32:15.862Z","dependency_job_id":"c786f5f0-93b4-4e19-abd3-9939a6c88662","html_url":"https://github.com/vitor-araujo/stocks_api","commit_stats":null,"previous_names":["vitor-araujo/stocks_api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vitor-araujo/stocks_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitor-araujo%2Fstocks_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitor-araujo%2Fstocks_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitor-araujo%2Fstocks_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitor-araujo%2Fstocks_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitor-araujo","download_url":"https://codeload.github.com/vitor-araujo/stocks_api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitor-araujo%2Fstocks_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33573271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["api","flask","postgresql","python","scraping","stocks","web"],"created_at":"2026-05-27T16:04:14.128Z","updated_at":"2026-05-27T16:04:40.981Z","avatar_url":"https://github.com/vitor-araujo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"images/stock_api_logo.png\" alt=\"Stock API\" width=\"20%\"\u003e\n\u003c/div\u003e\n\n\n![Pytest](https://img.shields.io/badge/tests-passing-brightgreen)\n![Python](https://img.shields.io/badge/python-3.10-blue)\n\n\n## Stock api Overview\n\nStock API is a RESTful service that allows users to retrieve and update stock information. It fetches stock data from external financial APIs, performs data scraping from MarketWatch, and stores data in a Supabase database. This project is designed to be user-friendly and robust, making it easy for users to access and update stock information. \n\n## Features\n\n- Fetch stock data for a given symbol and date from Polygon.io.\n- Scrape performance and competitor data from MarketWatch.\n- Persist stock data, performance data, and competitor data into Supabase-hosted PostgreSQL.\n- Update stock purchase amount with data validation.\n- Uses LRU cache set to 100 to optimse response latency as well as db IO. \n- Test coverage for endpoints and functions.\n- Dockerfile that builds an image containing the ready-to-run API on port 8000\n- Logging with python default logger optmized for log-searching.\n\n## Endpoints\n\n- **GET /stock/{stock_symbol}**: Fetch stock data for the given symbol. Defaults to yesterday if no date is provided.\n- **GET /stock/{stock_symbol}/{date}**: Fetch stock data for the given symbol on the specified date.\n\n```json\n{\n    \"status\": \"String\",\n    \"purchased_amount\": \"Integer\",\n    \"purchased_status\": \"String\",\n    \"request_date\": \"Date (YYYY-MM-DD)\",\n    \"company_code\": \"String\",\n    \"company_name\": \"String\",\n    \"stock_values\": {\n        \"open\": \"Float\",\n        \"high\": \"Float\",\n        \"low\": \"Float\",\n        \"close\": \"Float\"\n    },\n    \"performance_data\": {\n        \"five_days\": \"Float\",\n        \"one_month\": \"Float\",\n        \"three_months\": \"Float\",\n        \"year_to_date\": \"Float\",\n        \"one_year\": \"Float\"\n    },\n    \"competitors\": [\n        {\n            \"name\": \"String\",\n            \"company_code\": \"String\",\n            \"percent_change\": \"Float\",\n            \"market_cap\": {\n                \"currency\": \"String\",\n                \"value\": \"Float\"\n            }\n        }\n    ]\n}\n```\n\n\n- **POST /stock/{stock_symbol}**: Update the stock entity with the purchased amount based on the received argument.\n\n```json\n{\n\t\"message\": \"9999 units of stock meta were added to your stock record\"\n}\n```\n## Usage\n\n### Environment Variables\n\n- `SUPABASE_URL`: URL for the Supabase database.\n- `SUPABASE_KEY`: URL for the Supabase service that wraps the db.\n- `POLYGON_API_KEY`: API key for Polygon.io.\n- `POLYGON_BASE_URL`: Base URL for Polygon.io.\n- `ZENROW_API_KEY`: API key for ZenRows.\n\n### Dependencies\n\n- `Flask`: Web framework.\n- `requests`: HTTP library for Python.\n- `BeautifulSoup`: Library for web scraping.\n- `Supabase`: Client for interacting with Supabase.\n- `dotenv`: Library to load environment variables.\n- `pytest`: Testing framework for Python.\n- `Docker`: Container manager.\n\n## Setup Instructions\n\n### Step 1: Environment Variables\nEnsure you have all the environment variables set correctly as shown in the `.env.example` file. \n\n### Step 2: Supabase Setup\nIf you are starting from scratch, follow these instructions to set up your Supabase tables. If you already have a Supabase key and URL set up, skip to Step 3.\n\nSupabase will require you to create the models there. Follow this data model for the basic functionality to be enabled:\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"images/datamodel.png\" alt=\"Data Model\" width=\"70%\"\u003e\n\u003c/div\u003e\n\n### Step 3: Build the Docker Image\n```bash\ndocker build -t stock_api .\n```\n### Step 4: Run the Docker Container\n```bash\ndocker run -p 8000:8000 stock_api\n```\n\n### Running Tests\nThe Docker image will build and run tests automatically. Ensure the tests pass before using the API.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitor-araujo%2Fstocks_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitor-araujo%2Fstocks_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitor-araujo%2Fstocks_api/lists"}