API Reference¶
trendflow
¶
Client = GoogleTrendsFetcher
module-attribute
¶
__all__ = ['Client', 'ExportFormat', 'GoogleTrendsFetcher', 'InterestByRegionResult', 'InterestOverTimeResult', 'RelatedQuery', 'RelatedResult', 'Region', 'Resolution', 'Timeframe', 'TrendingItem', 'TrendingResult', 'TrendPoint', 'TrendsFetcher']
module-attribute
¶
ExportFormat
¶
GoogleTrendsFetcher
¶
Fetches data via the in-tree :class:GoogleTrendsHttpSession.
Source code in src/trendflow/_fetcher.py
InterestByRegionResult
dataclass
¶
InterestOverTimeResult
dataclass
¶
Interest over time for one or more keywords.
Source code in src/trendflow/models.py
export(fmt, path)
¶
Write results to CSV or JSON (UTF-8) via :mod:trendflow._exporters.
to_dataframe()
¶
Build a pandas DataFrame with a date column and one column per keyword.
Source code in src/trendflow/models.py
Region
¶
Bases: StrEnum
ISO-style geo codes for Google Trends (hl / geo). Empty string is worldwide.
Source code in src/trendflow/enums.py
RelatedQuery
dataclass
¶
RelatedResult
dataclass
¶
Resolution
¶
Timeframe
¶
TrendPoint
dataclass
¶
TrendingItem
dataclass
¶
TrendingResult
dataclass
¶
TrendsFetcher
¶
Bases: Protocol
Strategy for retrieving Trends data (swap in tests or alternate backends).
Source code in src/trendflow/_fetcher.py
trendflow._fetcher
¶
TRENDING_PN = {Region.US: 'united_states', Region.GB: 'united_kingdom', Region.DE: 'germany', Region.FR: 'france', Region.IT: 'italy', Region.ES: 'spain', Region.CA: 'canada', Region.AU: 'australia', Region.JP: 'japan', Region.IN: 'india', Region.BR: 'brazil', Region.MX: 'mexico', Region.NL: 'netherlands', Region.SE: 'sweden', Region.PL: 'poland', Region.TR: 'turkey'}
module-attribute
¶
GoogleTrendsFetcher
¶
Fetches data via the in-tree :class:GoogleTrendsHttpSession.
Source code in src/trendflow/_fetcher.py
GoogleTrendsHttpSession
¶
Stateful client for Google Trends internal APIs (explore + widgetdata).
Composes :class:TrendsJsonTransport for HTTP; this class holds comparison
state and returns raw JSON for callers to parse (e.g. :mod:trendflow._parsers).
Source code in src/trendflow/_trends_http/session.py
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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
interest_by_region(resolution='COUNTRY', inc_low_vol=False, inc_geo_code=False)
¶
Return the raw default object from the interest-by-region response.
Source code in src/trendflow/_trends_http/session.py
interest_over_time()
¶
Return the raw default object from the interest-over-time widget response.
Source code in src/trendflow/_trends_http/session.py
multirange_interest_over_time()
¶
Return the raw default object from the multirange interest-over-time response.
Source code in src/trendflow/_trends_http/session.py
related_queries()
¶
Per-keyword related queries: top / rising lists of ranked-keyword dicts.
Source code in src/trendflow/_trends_http/session.py
related_topics()
¶
Per-keyword related topics: top / rising lists of ranked-keyword dicts.
Source code in src/trendflow/_trends_http/session.py
today_searches(pn='US')
¶
Today's search titles for pn (country code).
Source code in src/trendflow/_trends_http/session.py
trending_searches(pn='united_states')
¶
Trending search titles for the given property namespace key (e.g. united_states).
Source code in src/trendflow/_trends_http/session.py
InterestByRegionResult
dataclass
¶
InterestOverTimeResult
dataclass
¶
Interest over time for one or more keywords.
Source code in src/trendflow/models.py
export(fmt, path)
¶
Write results to CSV or JSON (UTF-8) via :mod:trendflow._exporters.
to_dataframe()
¶
Build a pandas DataFrame with a date column and one column per keyword.
Source code in src/trendflow/models.py
Region
¶
Bases: StrEnum
ISO-style geo codes for Google Trends (hl / geo). Empty string is worldwide.
Source code in src/trendflow/enums.py
RelatedResult
dataclass
¶
Resolution
¶
Timeframe
¶
TrendingResult
dataclass
¶
TrendsFetcher
¶
Bases: Protocol
Strategy for retrieving Trends data (swap in tests or alternate backends).
Source code in src/trendflow/_fetcher.py
trendflow._parsers
¶
InterestByRegionResult
dataclass
¶
InterestOverTimeResult
dataclass
¶
Interest over time for one or more keywords.
Source code in src/trendflow/models.py
export(fmt, path)
¶
Write results to CSV or JSON (UTF-8) via :mod:trendflow._exporters.
to_dataframe()
¶
Build a pandas DataFrame with a date column and one column per keyword.
Source code in src/trendflow/models.py
RegionalInterestRow
dataclass
¶
RelatedQuery
dataclass
¶
RelatedResult
dataclass
¶
Resolution
¶
TrendPoint
dataclass
¶
TrendingItem
dataclass
¶
TrendingResult
dataclass
¶
_is_missing_value(val)
¶
_split_bracketed_ints(value)
¶
_to_int_or_none(val)
¶
Source code in src/trendflow/_parsers.py
infer_granularity(d0, d1)
¶
interest_by_region_rows(default, keyword, kw_list)
¶
Rows from geoMapData for keyword (index in kw_list selects the value column).
Source code in src/trendflow/_parsers.py
interest_by_region_to_result(default, keyword, kw_list, resolution)
¶
Source code in src/trendflow/_parsers.py
interest_over_time_to_result(default, keywords, geo)
¶
Build :class:InterestOverTimeResult from a widget default object (timelineData).
Source code in src/trendflow/_parsers.py
parse_rising_related(rows)
¶
Source code in src/trendflow/_parsers.py
parse_top_related(rows)
¶
Source code in src/trendflow/_parsers.py
related_queries_to_result(raw, keyword)
¶
Pick the bucket for keyword, or the sole bucket if only one series exists.
Source code in src/trendflow/_parsers.py
trending_result_from_titles(titles)
¶
trending_titles_to_items(titles)
¶
Map trending search title strings to :class:TrendingItem (no traffic/articles in this endpoint).
Source code in src/trendflow/_parsers.py
trendflow.models
¶
ExportFormat
¶
InterestByRegionResult
dataclass
¶
InterestOverTimeResult
dataclass
¶
Interest over time for one or more keywords.
Source code in src/trendflow/models.py
export(fmt, path)
¶
Write results to CSV or JSON (UTF-8) via :mod:trendflow._exporters.
to_dataframe()
¶
Build a pandas DataFrame with a date column and one column per keyword.
Source code in src/trendflow/models.py
RegionalInterestRow
dataclass
¶
RelatedQuery
dataclass
¶
RelatedResult
dataclass
¶
Resolution
¶
TrendPoint
dataclass
¶
TrendingItem
dataclass
¶
trendflow.enums
¶
trendflow._trends_http
¶
Google Trends internal JSON API client.
Split for maintainability: :mod:~trendflow._trends_http.endpoints (URLs),
:mod:~trendflow._trends_http.exceptions, :mod:~trendflow._trends_http.transport
(HTTP + cookies), :mod:~trendflow._trends_http.session (state + raw JSON).
Browser UIs may POST extra JSON to /api/explore;
this library uses query-parameter POSTs for tokens.
BASE_TRENDS_URL = 'https://trends.google.com/trends'
module-attribute
¶
__all__ = ['BASE_TRENDS_URL', 'GoogleTrendsHttpSession', 'ResponseError', 'TooManyRequestsError']
module-attribute
¶
GoogleTrendsHttpSession
¶
Stateful client for Google Trends internal APIs (explore + widgetdata).
Composes :class:TrendsJsonTransport for HTTP; this class holds comparison
state and returns raw JSON for callers to parse (e.g. :mod:trendflow._parsers).
Source code in src/trendflow/_trends_http/session.py
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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
interest_by_region(resolution='COUNTRY', inc_low_vol=False, inc_geo_code=False)
¶
Return the raw default object from the interest-by-region response.
Source code in src/trendflow/_trends_http/session.py
interest_over_time()
¶
Return the raw default object from the interest-over-time widget response.
Source code in src/trendflow/_trends_http/session.py
multirange_interest_over_time()
¶
Return the raw default object from the multirange interest-over-time response.
Source code in src/trendflow/_trends_http/session.py
related_queries()
¶
Per-keyword related queries: top / rising lists of ranked-keyword dicts.
Source code in src/trendflow/_trends_http/session.py
related_topics()
¶
Per-keyword related topics: top / rising lists of ranked-keyword dicts.
Source code in src/trendflow/_trends_http/session.py
today_searches(pn='US')
¶
Today's search titles for pn (country code).
Source code in src/trendflow/_trends_http/session.py
trending_searches(pn='united_states')
¶
Trending search titles for the given property namespace key (e.g. united_states).
Source code in src/trendflow/_trends_http/session.py
ResponseError
¶
Bases: Exception
The Trends endpoint returned a non-JSON or error response.
Source code in src/trendflow/_trends_http/exceptions.py
TooManyRequestsError
¶
Bases: ResponseError
HTTP 429 from Google Trends.