API Reference¶
trendflow
¶
Client = GoogleTrendsFetcher
module-attribute
¶
TRENDING_WINDOW_RISING = 8
module-attribute
¶
TRENDING_WINDOW_TOP = 10
module-attribute
¶
TrendingBackend = Literal['auto', 'rpc', 'rss']
module-attribute
¶
__all__ = ['TRENDING_WINDOW_RISING', 'TRENDING_WINDOW_TOP', 'Client', 'ExportFormat', 'GoogleTrendsFetcher', 'InterestByRegionResult', 'InterestOverTimeResult', 'RelatedQuery', 'RelatedResult', 'Region', 'Resolution', 'SearchProperty', 'Timeframe', 'TopicSuggestion', 'TrendingArticle', 'TrendingBackend', 'TrendingItem', 'TrendingResult', 'TrendPoint', 'TrendsFetcher', 'UnknownRpcError']
module-attribute
¶
ExportFormat
¶
GoogleTrendsFetcher
¶
Fetches data via the in-tree :class:GoogleTrendsHttpSession.
Source code in src/trendflow/_fetcher.py
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 | |
current_proxy
property
¶
The proxy currently pinned for queries, if a pool is configured.
__init__(language='en', timeout=10, proxies=None, max_proxy_attempts=None, on_proxy_rotate=None, rpc_ids=None)
¶
proxies is a list of proxy URLs to rotate through, from any mix of providers.
One proxy is pinned per query and the pool advances only when a query fails, because
Google binds its cookie and widget token to the exit IP. max_proxy_attempts
defaults to the pool size, capped at 5; on_proxy_rotate(attempt, error) is called
each time the pool advances.
rpc_ids repoints a batchexecute identifier that Google has renamed --
{"trending": "...", "geo_list": "...", "suggestions": "..."}, any subset. This is
the escape hatch :class:UnknownRpcError refers to: a rename can be worked around in
the caller, with no release and no fork.
Source code in src/trendflow/_fetcher.py
geo_list()
¶
interest_by_region(keyword, resolution, region=Region.US, *, timeframe=Timeframe.PAST_YEAR, category=0, search_property=SearchProperty.WEB)
¶
Where keyword is searched, broken down at resolution.
timeframe defaults to the past year; narrow it to ask where something was searched
during a specific window rather than across the whole year.
Source code in src/trendflow/_fetcher.py
interest_over_time(keywords, timeframe, region, *, category=0, search_property=SearchProperty.WEB)
¶
Relative interest for up to five terms over timeframe.
timeframe takes a :class:Timeframe or a custom "YYYY-MM-DD YYYY-MM-DD" range,
and region any Google geo code -- a country, a sub-region like "US-CA", or a
metro code. category restricts to one subject area, which disambiguates without a
topic id: "jaguar" under Autos is the car. search_property chooses the surface;
results from different properties are separate indexes and not comparable.
Source code in src/trendflow/_fetcher.py
related_queries(keyword, *, timeframe=Timeframe.PAST_YEAR, region=Region.WORLDWIDE, category=0, search_property=SearchProperty.WEB)
¶
Top and rising searches related to keyword.
region defaults to worldwide, which is what this returned unconditionally before it
was a parameter -- pass a country to ask what is searched alongside the term there.
Source code in src/trendflow/_fetcher.py
suggestions(query)
¶
Entity suggestions for a partial query -- the picker behind the UI's "Topic" results.
Pass a returned mid as a keyword to any query method to measure the topic
rather than the literal phrase; a topic aggregates every spelling and translation of
the same concept, so it usually scores far higher than the raw string.
Needs no cookie and no proxy: this RPC answers on IPs the widgetdata endpoints reject.
Source code in src/trendflow/_fetcher.py
trending_now(region=Region.WORLDWIDE, window=TRENDING_WINDOW_RISING, backend='auto')
¶
Trending searches for region.
Accepts any country code, not a fixed list, and worldwide works too. window
selects fastest-growing (:data:TRENDING_WINDOW_RISING) versus highest-volume
(:data:TRENDING_WINDOW_TOP) results.
backend selects the source:
"rpc"-- 50 items with growth percentages and volume."rss"-- 10 items with the news articles behind each trend, which the RPC does not carry, but no growth figures.windowdoes not apply: Google ignores it on the feed. There is no worldwide feed, so a country code is required."auto"(default) -- the RPC, falling back to RSS if it fails. RPC first because it returns five times the items with real growth numbers; defaulting to RSS would quietly degrade results.
:attr:TrendingResult.source reports which one answered.
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
¶
SearchProperty
¶
Bases: StrEnum
Which Google surface to measure.
These are separate indexes, not filters over one dataset, so the same term can look very different across them -- a term may be quiet on web search and busy on YouTube. Values are only comparable within a single property.
Source code in src/trendflow/enums.py
Timeframe
¶
Bases: StrEnum
Time ranges accepted by Google Trends.
Named values for the presets. A custom range is a plain string of two ISO dates,
"2023-01-01 2023-06-30", and every query method accepts one in place of a member.
The range chosen also decides the granularity Google returns: the hourly ranges come back
in minutes, the daily ones hourly, and ALL_TIME monthly. Ask for five years and you
cannot see a spike that lasted an afternoon.
Source code in src/trendflow/enums.py
TopicSuggestion
dataclass
¶
An entity Google recognises, as returned by search suggestions.
mid is the identifier to pass as a keyword to query the topic rather than the
literal phrase -- a topic aggregates every spelling and translation of the same concept.
Source code in src/trendflow/models.py
TrendPoint
dataclass
¶
TrendingArticle
dataclass
¶
A news article behind a trending search. Only the RSS backend reports these.
Source code in src/trendflow/models.py
TrendingItem
dataclass
¶
A single trending search entry.
Both backends fill title and traffic; the rest depends on which one answered,
since Google exposes different fields on each. See :attr:TrendingResult.source.
Source code in src/trendflow/models.py
TrendingResult
dataclass
¶
Current trending searches for a region.
Source code in src/trendflow/models.py
TrendsFetcher
¶
Bases: Protocol
Strategy for retrieving Trends data (swap in tests or alternate backends).
Source code in src/trendflow/_fetcher.py
UnknownRpcError
¶
Bases: Exception
Google returned no frame for the RPC that was called.
That is the signature of an identifier renamed on Google's side.
Source code in src/trendflow/_trends_http/batchexecute.py
trendflow._fetcher
¶
Gprop = Literal['', 'images', 'news', 'youtube', 'froogle']
module-attribute
¶
HTTP_FORBIDDEN = 403
module-attribute
¶
T = TypeVar('T')
module-attribute
¶
TRENDING_WINDOW_RISING = 8
module-attribute
¶
TRENDING_WINDOW_TOP = 10
module-attribute
¶
TrendingBackend = Literal['auto', 'rpc', 'rss']
module-attribute
¶
_SEARCH_PROPERTIES = frozenset((str(p)) for p in SearchProperty)
module-attribute
¶
GoogleTrendsFetcher
¶
Fetches data via the in-tree :class:GoogleTrendsHttpSession.
Source code in src/trendflow/_fetcher.py
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 | |
current_proxy
property
¶
The proxy currently pinned for queries, if a pool is configured.
__init__(language='en', timeout=10, proxies=None, max_proxy_attempts=None, on_proxy_rotate=None, rpc_ids=None)
¶
proxies is a list of proxy URLs to rotate through, from any mix of providers.
One proxy is pinned per query and the pool advances only when a query fails, because
Google binds its cookie and widget token to the exit IP. max_proxy_attempts
defaults to the pool size, capped at 5; on_proxy_rotate(attempt, error) is called
each time the pool advances.
rpc_ids repoints a batchexecute identifier that Google has renamed --
{"trending": "...", "geo_list": "...", "suggestions": "..."}, any subset. This is
the escape hatch :class:UnknownRpcError refers to: a rename can be worked around in
the caller, with no release and no fork.
Source code in src/trendflow/_fetcher.py
geo_list()
¶
interest_by_region(keyword, resolution, region=Region.US, *, timeframe=Timeframe.PAST_YEAR, category=0, search_property=SearchProperty.WEB)
¶
Where keyword is searched, broken down at resolution.
timeframe defaults to the past year; narrow it to ask where something was searched
during a specific window rather than across the whole year.
Source code in src/trendflow/_fetcher.py
interest_over_time(keywords, timeframe, region, *, category=0, search_property=SearchProperty.WEB)
¶
Relative interest for up to five terms over timeframe.
timeframe takes a :class:Timeframe or a custom "YYYY-MM-DD YYYY-MM-DD" range,
and region any Google geo code -- a country, a sub-region like "US-CA", or a
metro code. category restricts to one subject area, which disambiguates without a
topic id: "jaguar" under Autos is the car. search_property chooses the surface;
results from different properties are separate indexes and not comparable.
Source code in src/trendflow/_fetcher.py
related_queries(keyword, *, timeframe=Timeframe.PAST_YEAR, region=Region.WORLDWIDE, category=0, search_property=SearchProperty.WEB)
¶
Top and rising searches related to keyword.
region defaults to worldwide, which is what this returned unconditionally before it
was a parameter -- pass a country to ask what is searched alongside the term there.
Source code in src/trendflow/_fetcher.py
suggestions(query)
¶
Entity suggestions for a partial query -- the picker behind the UI's "Topic" results.
Pass a returned mid as a keyword to any query method to measure the topic
rather than the literal phrase; a topic aggregates every spelling and translation of
the same concept, so it usually scores far higher than the raw string.
Needs no cookie and no proxy: this RPC answers on IPs the widgetdata endpoints reject.
Source code in src/trendflow/_fetcher.py
trending_now(region=Region.WORLDWIDE, window=TRENDING_WINDOW_RISING, backend='auto')
¶
Trending searches for region.
Accepts any country code, not a fixed list, and worldwide works too. window
selects fastest-growing (:data:TRENDING_WINDOW_RISING) versus highest-volume
(:data:TRENDING_WINDOW_TOP) results.
backend selects the source:
"rpc"-- 50 items with growth percentages and volume."rss"-- 10 items with the news articles behind each trend, which the RPC does not carry, but no growth figures.windowdoes not apply: Google ignores it on the feed. There is no worldwide feed, so a country code is required."auto"(default) -- the RPC, falling back to RSS if it fails. RPC first because it returns five times the items with real growth numbers; defaulting to RSS would quietly degrade results.
:attr:TrendingResult.source reports which one answered.
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
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 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
rpc_client
property
¶
The RPC client, for building a trending provider around.
rss_client
property
¶
The RSS client, for building a trending provider around.
autocomplete(keyword)
¶
Entity suggestions from the legacy api/autocomplete endpoint.
Superseded by :meth:suggestions, which uses the RPC the current UI calls and
returns better matches -- "tech" yields Technology there but Technics,
Technivorm, TechnoMarine here. Kept because the endpoint still answers.
Source code in src/trendflow/_trends_http/session.py
geo_list()
¶
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
reset_cookies()
¶
set_proxy(proxy_url)
¶
Pin a proxy for every subsequent request and drop the old exit IP's cookie jar.
Source code in src/trendflow/_trends_http/session.py
suggestions(query)
¶
today_searches(pn='US')
¶
Today's search titles for pn (country code).
Source code in src/trendflow/_trends_http/session.py
trending_searches(geo='Worldwide', window=8)
¶
Trending searches for geo, via the batchexecute RPC.
geo is "Worldwide" or a country code such as "US". Returns raw
[term, growth_percent, volume_index] rows.
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
ProxyPool
¶
Holds proxy URLs and tracks which one is currently pinned.
Source code in src/trendflow/_proxy.py
advance()
¶
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
¶
ResponseError
¶
Bases: Exception
The Trends endpoint returned a non-JSON or error response.
Source code in src/trendflow/_trends_http/exceptions.py
RpcTrendingProvider
¶
The batchexecute RPC: more items, growth and volume, no articles.
Source code in src/trendflow/_providers.py
RssTrendingProvider
¶
The RSS feed: fewer items and no growth figures, but carries the news articles.
Source code in src/trendflow/_providers.py
SearchProperty
¶
Bases: StrEnum
Which Google surface to measure.
These are separate indexes, not filters over one dataset, so the same term can look very different across them -- a term may be quiet on web search and busy on YouTube. Values are only comparable within a single property.
Source code in src/trendflow/enums.py
Timeframe
¶
Bases: StrEnum
Time ranges accepted by Google Trends.
Named values for the presets. A custom range is a plain string of two ISO dates,
"2023-01-01 2023-06-30", and every query method accepts one in place of a member.
The range chosen also decides the granularity Google returns: the hourly ranges come back
in minutes, the daily ones hourly, and ALL_TIME monthly. Ask for five years and you
cannot see a spike that lasted an afternoon.
Source code in src/trendflow/enums.py
TooManyRequestsError
¶
Bases: ResponseError
HTTP 429 from Google Trends.
Source code in src/trendflow/_trends_http/exceptions.py
TopicSuggestion
dataclass
¶
An entity Google recognises, as returned by search suggestions.
mid is the identifier to pass as a keyword to query the topic rather than the
literal phrase -- a topic aggregates every spelling and translation of the same concept.
Source code in src/trendflow/models.py
TrendingProvider
¶
Bases: Protocol
A source of trending searches.
Source code in src/trendflow/_providers.py
TrendingResult
dataclass
¶
Current trending searches for a region.
Source code in src/trendflow/models.py
TrendsFetcher
¶
Bases: Protocol
Strategy for retrieving Trends data (swap in tests or alternate backends).
Source code in src/trendflow/_fetcher.py
UnknownRpcError
¶
Bases: Exception
Google returned no frame for the RPC that was called.
That is the signature of an identifier renamed on Google's side.
Source code in src/trendflow/_trends_http/batchexecute.py
_gprop(value)
¶
Narrow a search property to the literal the session accepts.
The session validates as well, but only once a payload is being built. Checking here means a mistyped plain string fails immediately with the allowed values, rather than surfacing later as something that looks like a network problem.
Source code in src/trendflow/_fetcher.py
_hl_from_language(language)
¶
_param(value)
¶
The wire value for a geo or timeframe.
These are StrEnums, so a member already is its string. Going through str rather
than .value is what lets callers pass a plain string -- a custom date range, or one of
the ~250 region codes and sub-regions that are not enum members.
Source code in src/trendflow/_fetcher.py
_should_rotate(error)
¶
Whether a failure is worth retrying on a different exit IP.
A 429 or a network error says "this IP is blocked". A 404 says the endpoint is gone, and a renamed RPC id fails identically everywhere, so rotating would only burn the pool.
Source code in src/trendflow/_fetcher.py
_trending_geo(region)
¶
Google's RPC takes the literal "Worldwide" rather than an empty geo.
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
¶
TopicSuggestion
dataclass
¶
An entity Google recognises, as returned by search suggestions.
mid is the identifier to pass as a keyword to query the topic rather than the
literal phrase -- a topic aggregates every spelling and translation of the same concept.
Source code in src/trendflow/models.py
TrendPoint
dataclass
¶
TrendingItem
dataclass
¶
A single trending search entry.
Both backends fill title and traffic; the rest depends on which one answered,
since Google exposes different fields on each. See :attr:TrendingResult.source.
Source code in src/trendflow/models.py
_format_growth(growth)
¶
_is_missing_value(val)
¶
_mapping(value)
¶
_rows(value)
¶
A list to iterate, whatever Google sent.
Every parser below reads a positional structure that Google owns and can change without
notice. Individual rows were already guarded; the containers were not, so a null where
a list was expected raised out of the parser and became an error for the caller. Junk in,
empty out -- never a throw.
Source code in src/trendflow/_parsers.py
_split_bracketed_ints(value)
¶
_timestamp(entry)
¶
The epoch seconds on a timeline entry, or None if it does not carry a usable one.
Source code in src/trendflow/_parsers.py
_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
suggestion_rows_to_topics(rows)
¶
Map [mid, title, type, ...] rows from the suggestions RPC to topics.
Source code in src/trendflow/_parsers.py
trending_rows_to_items(rows)
¶
Map [term, growth_percent, volume_index] rows from the trending RPC to items.
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
¶
TopicSuggestion
dataclass
¶
An entity Google recognises, as returned by search suggestions.
mid is the identifier to pass as a keyword to query the topic rather than the
literal phrase -- a topic aggregates every spelling and translation of the same concept.
Source code in src/trendflow/models.py
TrendPoint
dataclass
¶
TrendingArticle
dataclass
¶
A news article behind a trending search. Only the RSS backend reports these.
Source code in src/trendflow/models.py
TrendingItem
dataclass
¶
A single trending search entry.
Both backends fill title and traffic; the rest depends on which one answered,
since Google exposes different fields on each. See :attr:TrendingResult.source.
Source code in src/trendflow/models.py
TrendingResult
dataclass
¶
Current trending searches for a region.
Source code in src/trendflow/models.py
trendflow.enums
¶
ExportFormat
¶
Region
¶
Bases: StrEnum
ISO-style geo codes for Google Trends (hl / geo). Empty string is worldwide.
Source code in src/trendflow/enums.py
Resolution
¶
SearchProperty
¶
Bases: StrEnum
Which Google surface to measure.
These are separate indexes, not filters over one dataset, so the same term can look very different across them -- a term may be quiet on web search and busy on YouTube. Values are only comparable within a single property.
Source code in src/trendflow/enums.py
Timeframe
¶
Bases: StrEnum
Time ranges accepted by Google Trends.
Named values for the presets. A custom range is a plain string of two ISO dates,
"2023-01-01 2023-06-30", and every query method accepts one in place of a member.
The range chosen also decides the granularity Google returns: the hourly ranges come back
in minutes, the daily ones hourly, and ALL_TIME monthly. Ask for five years and you
cannot see a spike that lasted an afternoon.
Source code in src/trendflow/enums.py
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
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 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
rpc_client
property
¶
The RPC client, for building a trending provider around.
rss_client
property
¶
The RSS client, for building a trending provider around.
autocomplete(keyword)
¶
Entity suggestions from the legacy api/autocomplete endpoint.
Superseded by :meth:suggestions, which uses the RPC the current UI calls and
returns better matches -- "tech" yields Technology there but Technics,
Technivorm, TechnoMarine here. Kept because the endpoint still answers.
Source code in src/trendflow/_trends_http/session.py
geo_list()
¶
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
reset_cookies()
¶
set_proxy(proxy_url)
¶
Pin a proxy for every subsequent request and drop the old exit IP's cookie jar.
Source code in src/trendflow/_trends_http/session.py
suggestions(query)
¶
today_searches(pn='US')
¶
Today's search titles for pn (country code).
Source code in src/trendflow/_trends_http/session.py
trending_searches(geo='Worldwide', window=8)
¶
Trending searches for geo, via the batchexecute RPC.
geo is "Worldwide" or a country code such as "US". Returns raw
[term, growth_percent, volume_index] rows.
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.