File size: 3,387 Bytes
0a7e81a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0e9e349
0a7e81a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
"""
Trends Module Schemas
Pydantic models for request/response
"""
from pydantic import BaseModel, Field
from typing import Optional, List
from enum import Enum


# ===================
# Enums
# ===================

class CategoryEnum(str, Enum):
    """Available categories"""
    all = "all"
    arts_entertainment = "arts_entertainment"
    autos_vehicles = "autos_vehicles"
    beauty_fitness = "beauty_fitness"
    books_literature = "books_literature"
    business_industrial = "business_industrial"
    computers_electronics = "computers_electronics"
    finance = "finance"
    food_drink = "food_drink"
    games = "games"
    health = "health"
    hobbies_leisure = "hobbies_leisure"
    home_garden = "home_garden"
    internet_telecom = "internet_telecom"
    jobs_education = "jobs_education"
    news = "news"
    science = "science"
    shopping = "shopping"
    sports = "sports"
    travel = "travel"


class TimeframeEnum(str, Enum):
    """Available timeframes"""
    now_1h = "now_1h"
    now_4h = "now_4h"
    now_1d = "now_1d"
    now_7d = "now_7d"
    today_1m = "today_1m"
    today_3m = "today_3m"
    today_12m = "today_12m"
    today_5y = "today_5y"


class SearchTypeEnum(str, Enum):
    """Search types"""
    web = "web"
    youtube = "youtube"
    news = "news"
    images = "images"
    shopping = "shopping"


# ===================
# Request Models
# ===================

class TrendingNowRequest(BaseModel):
    """Request for trending now"""
    country: str = Field("united_states", description="Country name (e.g., 'bangladesh', 'india', 'united_states')")
    limit: int = Field(20, ge=1, le=50, description="Number of results")


class KeywordResearchRequest(BaseModel):
    """Request for keyword research"""
    keyword: str = Field(..., description="Search keyword")
    region: str = Field("", description="Region code (empty for worldwide, e.g., 'US', 'BD', 'IN')")
    timeframe: TimeframeEnum = Field(TimeframeEnum.today_12m, description="Time range")
    category: CategoryEnum = Field(CategoryEnum.all, description="Category")
    search_type: SearchTypeEnum = Field(SearchTypeEnum.web, description="Search type")


class YouTubeTrendsRequest(BaseModel):
    """Request for YouTube trends"""
    keyword: str = Field(..., description="Search keyword")
    region: str = Field("", description="Region code (empty for worldwide)")
    timeframe: TimeframeEnum = Field(TimeframeEnum.today_12m, description="Time range")


# ===================
# Response Models
# ===================

class TrendingTopic(BaseModel):
    """Single trending topic"""
    rank: int
    topic: str
    country: str
    traffic: str = "N/A"


class TrendingNowResponse(BaseModel):
    """Response for trending now"""
    success: bool
    count: int
    trends: List[TrendingTopic]


class TopicItem(BaseModel):
    """Single topic item"""
    topic: str
    type: Optional[str] = None
    value: int


class QueryItem(BaseModel):
    """Single query item"""
    query: str
    value: str


class RelatedData(BaseModel):
    """Related topics/queries data"""
    keyword: str
    top: List[dict]
    rising: List[dict]


class KeywordResearchResponse(BaseModel):
    """Response for keyword research"""
    success: bool
    keyword: str
    region: str
    timeframe: str
    category: str
    search_type: str
    related_topics: dict
    related_queries: dict