Spaces:
Running
Running
| <html lang="en" data-bs-theme="dark"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>API Documentation - Cosmic Guide Horoscope API</title> | |
| <!-- Bootstrap CSS --> | |
| <link href="https://cdn.replit.com/agent/bootstrap-agent-dark-theme.min.css" rel="stylesheet"> | |
| <!-- Custom CSS --> | |
| <link href="/static/css/custom.css" rel="stylesheet"> | |
| <!-- Feather Icons --> | |
| <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script> | |
| </head> | |
| <body> | |
| <nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4"> | |
| <div class="container"> | |
| <a class="navbar-brand" href="/"> | |
| <i data-feather="star"></i> Cosmic Guide | |
| </a> | |
| <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"> | |
| <span class="navbar-toggler-icon"></span> | |
| </button> | |
| <div class="collapse navbar-collapse" id="navbarNav"> | |
| <ul class="navbar-nav ms-auto"> | |
| <li class="nav-item"> | |
| <a class="nav-link" href="/">Home</a> | |
| </li> | |
| <li class="nav-item"> | |
| <a class="nav-link active" href="/docs">API Documentation</a> | |
| </li> | |
| <li class="nav-item"> | |
| <a class="nav-link" href="/#about">About</a> | |
| </li> | |
| </ul> | |
| </div> | |
| </div> | |
| </nav> | |
| <main class="container"> | |
| <div class="row"> | |
| <div class="col-md-3 mb-4"> | |
| <div class="sticky-top pt-4" style="top: 2rem;"> | |
| <div class="list-group"> | |
| <a href="#overview" class="list-group-item list-group-item-action bg-dark">Overview</a> | |
| <a href="#authentication" class="list-group-item list-group-item-action bg-dark">Authentication</a> | |
| <a href="#rate-limiting" class="list-group-item list-group-item-action bg-dark">Rate Limiting</a> | |
| <a href="#endpoints" class="list-group-item list-group-item-action bg-dark">Endpoints</a> | |
| <a href="#horoscope-get" class="list-group-item list-group-item-action bg-dark ms-3">Get Horoscope</a> | |
| <a href="#horoscope-get-all" class="list-group-item list-group-item-action bg-dark ms-3">Get All Horoscopes</a> | |
| <a href="#horoscope-scrape" class="list-group-item list-group-item-action bg-dark ms-3">Scrape Horoscope</a> | |
| <a href="#horoscope-consolidate" class="list-group-item list-group-item-action bg-dark ms-3">Consolidate Horoscope</a> | |
| <a href="#scheduler" class="list-group-item list-group-item-action bg-dark ms-3">Scheduler</a> | |
| <a href="#examples" class="list-group-item list-group-item-action bg-dark">Examples</a> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="col-md-9"> | |
| <div class="bg-dark p-4 rounded shadow-sm mb-4"> | |
| <h1 id="overview">Horoscope API Documentation</h1> | |
| <p class="lead">Complete reference for the Cosmic Guide Horoscope API with LLM Integration</p> | |
| </div> | |
| <div class="bg-dark p-4 rounded shadow-sm mb-4"> | |
| <h2 id="overview">Overview</h2> | |
| <p>This API allows you to scrape horoscope data from multiple astrological websites, consolidate the information using LLM processing, and retrieve it in a structured format. It's designed to be easy to use while providing powerful data processing capabilities.</p> | |
| <h3>Base URL</h3> | |
| <code>http://localhost:5000</code> | |
| </div> | |
| <div class="bg-dark p-4 rounded shadow-sm mb-4"> | |
| <h2 id="authentication">Authentication</h2> | |
| <p>Currently, no authentication is required to use the API. However, the API uses rate limiting to prevent abuse.</p> | |
| </div> | |
| <div class="bg-dark p-4 rounded shadow-sm mb-4"> | |
| <h2 id="rate-limiting">Rate Limiting</h2> | |
| <p>To prevent overwhelming target websites and the API itself, rate limiting is implemented:</p> | |
| <ul> | |
| <li>API-wide limit: 10 requests per minute</li> | |
| <li>Per-domain limit: 5 requests per minute</li> | |
| </ul> | |
| <p>When a rate limit is exceeded, the API will return a 429 status code with information about how long to wait before retrying.</p> | |
| </div> | |
| <div class="bg-dark p-4 rounded shadow-sm mb-4"> | |
| <h2 id="endpoints">Endpoints</h2> | |
| <div class="card bg-dark border-secondary mb-4"> | |
| <div class="card-header" id="horoscope-get"> | |
| <h3>Get Horoscope</h3> | |
| <code>GET /api/horoscope/get/{sign}</code> | |
| </div> | |
| <div class="card-body"> | |
| <p>Get horoscope for a specific zodiac sign.</p> | |
| <h4>Parameters</h4> | |
| <ul> | |
| <li><code>sign</code> (path parameter): Zodiac sign (e.g., aries, taurus, gemini, etc.)</li> | |
| <li><code>date</code> (query parameter, optional): Date in YYYY-MM-DD format. Defaults to today's date.</li> | |
| <li><code>source</code> (query parameter, optional): Specific source to get the horoscope from.</li> | |
| </ul> | |
| <h4>Response</h4> | |
| <pre><code>{ | |
| "id": 1, | |
| "sign": "aries", | |
| "date": "2025-05-13", | |
| "prediction": "Today is a good day for new beginnings...", | |
| "source": "astrology.com", | |
| "created_at": "2025-05-13T00:00:00.000Z" | |
| }</code></pre> | |
| </div> | |
| </div> | |
| <div class="card bg-dark border-secondary mb-4"> | |
| <div class="card-header" id="horoscope-get-all"> | |
| <h3>Get All Horoscopes</h3> | |
| <code>GET /api/horoscope/get-all</code> | |
| </div> | |
| <div class="card-body"> | |
| <p>Get horoscopes for all zodiac signs for a specific date.</p> | |
| <h4>Parameters</h4> | |
| <ul> | |
| <li><code>date</code> (query parameter, optional): Date in YYYY-MM-DD format. Defaults to today's date.</li> | |
| </ul> | |
| <h4>Response</h4> | |
| <pre><code>{ | |
| "date": "2025-05-13", | |
| "horoscopes": { | |
| "aries": [ | |
| { | |
| "id": 1, | |
| "sign": "aries", | |
| "date": "2025-05-13", | |
| "prediction": "Today is a good day for new beginnings...", | |
| "source": "astrology.com", | |
| "created_at": "2025-05-13T00:00:00.000Z" | |
| }, | |
| { | |
| "id": 2, | |
| "sign": "aries", | |
| "date": "2025-05-13", | |
| "prediction": "You'll find new opportunities today...", | |
| "source": "horoscope.com", | |
| "created_at": "2025-05-13T00:00:00.000Z" | |
| } | |
| ], | |
| "taurus": [ | |
| // Taurus horoscopes... | |
| ], | |
| // Other signs... | |
| } | |
| }</code></pre> | |
| </div> | |
| </div> | |
| <div class="card bg-dark border-secondary mb-4"> | |
| <div class="card-header" id="horoscope-scrape"> | |
| <h3>Scrape Horoscope</h3> | |
| <code>POST /api/horoscope/scrape</code> | |
| </div> | |
| <div class="card-body"> | |
| <p>Scrape horoscope for a specific sign from a source.</p> | |
| <h4>Request Body</h4> | |
| <pre><code>{ | |
| "sign": "aries", | |
| "source": "astrology.com", // Optional | |
| "date": "2025-05-13" // Optional, defaults to today | |
| }</code></pre> | |
| <h4>Response</h4> | |
| <pre><code>{ | |
| "success": true, | |
| "sign": "aries", | |
| "scraped_date": "2025-05-13", | |
| "prediction": "Today is a good day for new beginnings...", | |
| "date": "2025-05-13", | |
| "source": "astrology.com", | |
| "source_name": "Astrology.com", | |
| "type": "horoscope" | |
| }</code></pre> | |
| </div> | |
| </div> | |
| <div class="card bg-dark border-secondary mb-4"> | |
| <div class="card-header" id="horoscope-scrape-all"> | |
| <h3>Scrape All Horoscopes</h3> | |
| <code>POST /api/horoscope/scrape-all</code> | |
| </div> | |
| <div class="card-body"> | |
| <p>Scrape horoscopes for all signs from all sources.</p> | |
| <h4>Request Body</h4> | |
| <pre><code>{ | |
| "date": "2025-05-13" // Optional, defaults to today | |
| }</code></pre> | |
| <h4>Response</h4> | |
| <pre><code>{ | |
| "results": [ | |
| // Array of scraped horoscopes | |
| ] | |
| }</code></pre> | |
| </div> | |
| </div> | |
| <div class="card bg-dark border-secondary mb-4"> | |
| <div class="card-header" id="horoscope-consolidate"> | |
| <h3>Consolidate Horoscope</h3> | |
| <code>POST /api/horoscope/consolidate/{sign}</code> | |
| </div> | |
| <div class="card-body"> | |
| <p>Consolidate horoscopes for a specific sign using LLM.</p> | |
| <h4>Parameters</h4> | |
| <ul> | |
| <li><code>sign</code> (path parameter): Zodiac sign (e.g., aries, taurus, gemini, etc.)</li> | |
| </ul> | |
| <h4>Request Body</h4> | |
| <pre><code>{ | |
| "date": "2025-05-13" // Optional, defaults to today | |
| }</code></pre> | |
| <h4>Response</h4> | |
| <pre><code>{ | |
| "message": "Consolidated horoscope created for aries on 2025-05-13", | |
| "horoscope": { | |
| "id": 1, | |
| "sign": "aries", | |
| "date": "2025-05-13", | |
| "consolidated_prediction": "The stars align perfectly for you today...", | |
| "sources": "[\"astrology.com\", \"horoscope.com\"]", | |
| "created_at": "2025-05-13T00:00:00.000Z" | |
| } | |
| }</code></pre> | |
| </div> | |
| </div> | |
| <div class="card bg-dark border-secondary mb-4"> | |
| <div class="card-header" id="scheduler"> | |
| <h3>Scheduler API</h3> | |
| <code>Various endpoints</code> | |
| </div> | |
| <div class="card-body"> | |
| <p>Endpoints for managing scheduled jobs.</p> | |
| <h4>Get Scheduled Jobs</h4> | |
| <code>GET /api/horoscope/schedule</code> | |
| <pre><code>{ | |
| "jobs": [ | |
| { | |
| "id": 1, | |
| "name": "scrape_daily_horoscopes", | |
| "frequency": "daily", | |
| "last_run": "2025-05-12T00:00:00.000Z", | |
| "next_run": "2025-05-13T00:00:00.000Z", | |
| "enabled": true, | |
| "created_at": "2025-05-01T00:00:00.000Z", | |
| "active": true | |
| } | |
| ] | |
| }</code></pre> | |
| <h4>Add Scheduled Job</h4> | |
| <code>POST /api/horoscope/schedule</code> | |
| <p>Request Body:</p> | |
| <pre><code>{ | |
| "name": "scrape_daily_horoscopes", | |
| "frequency": "daily" | |
| }</code></pre> | |
| <h4>Remove Scheduled Job</h4> | |
| <code>DELETE /api/horoscope/schedule/{name}</code> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-dark p-4 rounded shadow-sm mb-4"> | |
| <h2 id="examples">Examples</h2> | |
| <h3>Python Example</h3> | |
| <pre><code> | |
| import requests | |
| import json | |
| # Get horoscope for Aries | |
| response = requests.get('http://localhost:5000/api/horoscope/get/aries') | |
| data = response.json() | |
| print(f"Aries horoscope: {data['prediction']}") | |
| # Scrape and consolidate horoscope | |
| response = requests.post( | |
| 'http://localhost:5000/api/horoscope/consolidate/taurus', | |
| json={} # Use default date (today) | |
| ) | |
| consolidated = response.json() | |
| print(f"Consolidated Taurus horoscope: {consolidated['horoscope']['consolidated_prediction']}") | |
| </code></pre> | |
| <h3>JavaScript Example</h3> | |
| <pre><code> | |
| // Get all horoscopes for today | |
| async function getAllHoroscopes() { | |
| const response = await fetch('http://localhost:5000/api/horoscope/get-all'); | |
| const data = await response.json(); | |
| // Display each sign's horoscope | |
| for (const sign in data.horoscopes) { | |
| const horoscopes = data.horoscopes[sign]; | |
| if (horoscopes.length > 0) { | |
| console.log(`${sign.toUpperCase()}: ${horoscopes[0].prediction}`); | |
| } | |
| } | |
| } | |
| getAllHoroscopes(); | |
| </code></pre> | |
| </div> | |
| </div> | |
| </div> | |
| </main> | |
| <footer class="footer mt-5 py-3 bg-dark"> | |
| <div class="container text-center"> | |
| <span class="text-muted">Cosmic Guide - AI-Powered Horoscopes © 2025</span> | |
| </div> | |
| </footer> | |
| <!-- Bootstrap JS Bundle --> | |
| <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> | |
| <!-- Custom JS --> | |
| <script> | |
| // Initialize Feather icons | |
| document.addEventListener('DOMContentLoaded', function() { | |
| feather.replace(); | |
| }); | |
| </script> | |
| </body> | |
| </html> | |