{"id":19793282,"url":"https://github.com/carpodok/sentiment-analysis-api","last_synced_at":"2026-04-17T11:32:17.499Z","repository":{"id":244566965,"uuid":"815602591","full_name":"carpodok/sentiment-analysis-api","owner":"carpodok","description":"A basic API for sentiment analysis, leveraging the OpenAI API. Features include user authentication, customizable sentiment categories, rate limiting, daily usage limits, and Redis integration for efficient data management.","archived":false,"fork":false,"pushed_at":"2024-07-23T07:56:45.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-01T20:51:08.839Z","etag":null,"topics":["javascript","mongodb","nodejs","openai-api","redis","rest-api"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/carpodok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-06-15T15:42:22.000Z","updated_at":"2024-07-23T07:56:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"bf2ddb7a-b2e5-49be-ac5d-8a7779a3cbea","html_url":"https://github.com/carpodok/sentiment-analysis-api","commit_stats":null,"previous_names":["carpodok/sentiment-analysis-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/carpodok/sentiment-analysis-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpodok%2Fsentiment-analysis-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpodok%2Fsentiment-analysis-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpodok%2Fsentiment-analysis-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpodok%2Fsentiment-analysis-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carpodok","download_url":"https://codeload.github.com/carpodok/sentiment-analysis-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carpodok%2Fsentiment-analysis-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31927773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T10:35:34.458Z","status":"ssl_error","status_checked_at":"2026-04-17T10:35:09.472Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["javascript","mongodb","nodejs","openai-api","redis","rest-api"],"created_at":"2024-11-12T07:09:22.882Z","updated_at":"2026-04-17T11:32:17.481Z","avatar_url":"https://github.com/carpodok.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sentiment Analysis API\n\n![Frame 7](https://github.com/carpodok/sentiment-analysis-api/assets/64840495/e95b74f9-f6b6-40bf-871b-0418cb8bd7fb)\n\n## Overview\nThis repository provides a basic API for sentiment analysis, utilizing the OpenAI API for processing text inputs. The API categorizes sentiment as positive, negative, or neutral.\n\n## Key Features\n- ***Sentiment Analysis:*** Analyzes and categorizes text sentiment.\n- ***OpenAI API Integration:*** Uses OpenAI API for text analysis.\n- ***User Authentication:*** Users must be logged in to use the API.\n- ***Customizable Categories:*** Users can customize sentiment categories. Defaults are `positive`, `negative`, and `neutral`.\n- ***Rate Limiter:*** Limits usage to 100 requests per 15 minutes.\n- ***Daily Usage Limit:*** Each user has 150 requests per day, renewed nightly at 00:00.\n- ***Redis Integration:*** Utilizes Redis for efficient in-memory data storage and management.\n\n\n\n## Used Technologies\n- `express`: Web framework for Node.js.\n- `mongoose`: MongoDB object modeling tool.\n- `jsonwebtoken`: JSON Web Token implementation.\n- `bcryptjs`: Library to hash passwords.\n- `express-validator`: Middleware for validating and sanitizing user inputs\n- `dotenv`: Module to load environment variables.\n- `express-rate-limit`: Middleware to limit repeated requests.\n- `node-cron`:Task scheduler for Node.js.\n- `nodemon`: Utility to monitor for changes in Node.js applications.\n- `openai`: For sentiment analysis.\n- `redis`: In-memory data structure store.\n\n\n## Endpoints\n\n- ### POST /register\n\n```bash\nhttp://localhost:3000/register\n```\n\nHeaders:\n```bash\nContent-Type: application/json\n```\n\nRequest:\n```bash\n{\n    \"name\": \"ali\",\n    \"email\":\"a@gmail.com\",\n    \"password\":\"123456\"\n}\n```\n\nResponse:\n```bash\n{\n  \"success\": true,\n  \"token\": \"\"\n}\n```\n\n\u003chr\u003e\n\n- ### POST /login\n\n```bash\nhttp://localhost:3000/login\n```\n\nHeaders:\n```bash\nContent-Type: application/json\n```\n\nRequest:\n```bash\n{\n    \"email\":\"a@gmail.com\",\n    \"password\":\"123456\"\n}\n```\n\nResponse:\n```bash\n{\n  \"success\": true,\n  \"token\": \"\"\n}\n```\n\n\u003chr\u003e\n\n- ### POST /analyze\n\n```bash\nhttp://localhost:3000/analyze\n```\n\nHeaders:\n```bash\nContent-Type: application/json\nAuthorization: Bearer your_access_token_here\n```\n\nRequest:\n```bash\n\n{\n    \"text\": \"The customer service was not good enough, and I am very disappointed with the experience.\"\n}\n```\n\nResponse:\n```bash\n{\n  \"success\": true,\n  \"data\": \"Negative\"\n}\n```\n\u003chr\u003e\n\n- ### POST /custom-sentiment-categories\n\n```bash\nhttp://localhost:3000/custom-sentiment-categories\n```\n\nHeaders:\n```bash\nContent-Type: application/json\nAuthorization: Bearer your_access_token_here\n```\n\nRequest:\n```bash\n{\n  \"categories\": [\"Happy\", \"Sad\", \"Angry\"]\n}\n```\n\nResponse:\n```bash\n{\n  \"success\": true,\n  \"data\": [\n    \"Happy\",\n    \"Sad\",\n    \"Angry\"\n  ]\n}\n```\n\u003chr\u003e\n\n- ### GET /profile\n\n```bash\nhttp://localhost:3000/profile\n```\n\nHeaders:\n```bash\nContent-Type: application/json\nAuthorization: Bearer your_access_token_here\n```\n\nResponse:\n```bash\n{\n  \"success\": true,\n  \"data\": {\n    \"_id\": \"6666059d80df1c6f48e43c1f\",\n    \"name\": \"ali\",\n    \"email\": \"a@gmail.com\",\n    \"customSentimentCategories\": [\n      \"Happy\",\n      \"Sad\",\n      \"Angry\"\n    ],\n    \"requestCount\": 1,\n    \"requestLimit\": 2,\n    \"createdAt\": \"2024-06-09T19:42:21.608Z\",\n    \"__v\": 1\n  }\n}\n```\n\u003chr\u003e\n\u003cbr\u003e\n\n\n## Setup\n### 1.Clone the Repo:\n\n```bash\ngit clone https://github.com/carpodok/sentiment-analysis-api.git\n```\n\n#### 2. Install Dependencies:\n```bash\nnpm install\n```\n\n#### 3. Configure Environment Variables\nCreate a `.env`file in the root directory and add the following variables:\n\n```bash\nPORT=3000\nOPENAI_API_KEY=your_api_key\nMONGO_URI=\"your_mongo_uri\"\nJWT_SECRET=jwt_secret\nREDIS_URL=redis://127.0.0.1:6379\n```\n\n#### 4. Start the server:\n\n```bash\nnem start\n```\n\nFor development purpose with live reload, use this:\n\n```bash\nnpm run dev\n```\n\n\n## License\n\nThis project is lisenced under the MIT License.\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarpodok%2Fsentiment-analysis-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarpodok%2Fsentiment-analysis-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarpodok%2Fsentiment-analysis-api/lists"}