A Swift job talks to Trends API with one POST to https://api.trendsapi.ai/api, a Bearer key, and a JSON body that names a mode. There is no official Swift package. URLSession sends the request. JSONSerialization parses the envelope, then parses the body string a second time. Pulled on 2026-09-12, Google Search for swift programming scored 14.0 for the week of 2026-09-05, down 22.22% from 18.0. swiftui scored 19.0, flat versus 19.0. xcode scored 35.0, up 6.06% from 33.0. Do not treat the Xcode 7D rise as language adoption. The same helper that stores those rows also pulls a live Google Trends board; a 1-day climber on that board is documented in Practical Magic 2 live rank versus weekly Search.
How does a Swift client call Trends API?
POST https://api.trendsapi.ai/api
Authorization: Bearer <api_key>
Content-Type: application/json
{"mode":"get_growth","source":"google search","keyword":"swift programming","percent_growth":["7D","30D","3M","12M"]}
import Foundation
func trendsPost(payload: String) async throws -> Any {
guard let key = ProcessInfo.processInfo.environment["TRENDSAPI_API_KEY"] else {
fatalError("TRENDSAPI_API_KEY is unset")
}
var req = URLRequest(url: URL(string: "https://api.trendsapi.ai/api")!)
req.httpMethod = "POST"
req.setValue("Bearer \(key)", forHTTPHeaderField: "Authorization")
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.httpBody = Data(payload.utf8)
let (data, resp) = try await URLSession.shared.data(for: req)
let code = (resp as? HTTPURLResponse)?.statusCode ?? 0
if code != 200 { fatalError("HTTP \(code)") }
let envelope = try JSONSerialization.jsonObject(with: data) as! [String: Any]
// body is a JSON string; parse it a second time
guard let inner = envelope["body"] as? String,
let innerData = inner.data(using: .utf8) else {
fatalError("missing body")
}
return try JSONSerialization.jsonObject(with: innerData)
}
let inner = try await trendsPost(
payload: #"{"mode":"get_growth","source":"google search","keyword":"swift programming","percent_growth":["7D","30D","3M","12M"]}"#
)
print(inner)
The first mistake most clients make is treating the body field as an object after one parse. It is still a JSON string. Parse the envelope, then parse body a second time. Library docs:
https://developer.apple.com/documentation/foundation/urlsession
https://developer.apple.com/documentation/foundation/jsonserialization
Free tier allows 100 successful requests per month. Only HTTP 200 responses count against quota. Starter is 5,000, Pro is 25,000, Business is 100,000. There is no Swift-specific source on this API. npm covers npmjs package names. python covers PyPI project names. A Swift watchlist that needs CocoaPods or Swift Package Index download counts has to pull those from somewhere else.
What did get_growth return for Swift language tokens?
Pulled on 2026-09-12 with source set to google search. get_growth tips on 2026-09-05. The prior Saturday 2026-08-29 is the last full week in the same series. Bare swift is a polluted token (bird, Taylor Swift, the language). Store the phrase tokens.
| Keyword | Period | Recent | Baseline date | Baseline | Growth |
|---|---|---|---|---|---|
| swift programming | 7D | 14.0 | 2026-08-29 | 18.0 | -22.22% |
| swift programming | 14D | 14.0 | 2026-08-22 | 15.0 | -6.67% |
| swift programming | 30D | 14.0 | 2026-08-08 | 24.0 | -41.67% |
| swift programming | 3M | 14.0 | 2026-06-06 | 100.0 | -86.0% |
| swift programming | 12M | 14.0 | 2025-09-06 | 38.0 | -63.16% |
| swift programming | YTD | 14.0 | 2026-01-03 | 24.0 | -41.67% |
| swift language | 7D | 14.0 | 2026-08-29 | 21.0 | -33.33% |
| apple swift | 7D | 16.0 | 2026-08-29 | 25.0 | -36.0% |
| swiftui | 7D | 19.0 | 2026-08-29 | 19.0 | 0.0% |
| swiftui | 3M | 19.0 | 2026-06-06 | 100.0 | -81.0% |
| swiftlang | 7D | 48.0 | 2026-08-29 | 0.0 | vs 0.0 |
| xcode | 7D | 35.0 | 2026-08-29 | 33.0 | +6.06% |
| vapor swift | 7D | 15.0 | 2026-08-29 | 27.0 | -44.44% |
| vapor | 7D | 70.0 | 2026-08-29 | 78.0 | -10.26% |
| objective-c | 7D | 18.0 | 2026-08-29 | 20.0 | -10.0% |
| swift | 7D | 19.0 | 2026-08-29 | 21.0 | -9.52% |
swift programming and swiftui closed at different 7D directions. The phrase token fell 22.22%. SwiftUI was flat at 19.0. xcode rose 6.06% to 35.0. vapor swift fell 44.44% to 15.0. Bare vapor scored 70.0. That is the English word, not the server framework. A job that alerts "Swift is up" off Xcode 7D is reading the IDE series. Store each string.
3M is a summer crash on the language and UI tokens. swift programming is 14.0 versus 100.0 on 2026-06-06 (-86.0%). swift language is 14.0 versus 80.0 (-82.5%). apple swift is 16.0 versus 100.0 (-84.0%). swiftui is 19.0 versus 100.0 (-81.0%). vapor swift is 15.0 versus 86.0 (-82.56%). xcode is 35.0 versus 93.0 (-62.37%). objective-c is 18.0 versus 66.0 on 3M (-72.73%) and 18.0 versus 9.0 on YTD (+100.0%). Do not alert language adoption off a framework 3M crash. YouTube for the same phrase token is milder (next section).
get_time_series for swift programming on Google Search closed at 14 on 2026-09-05, matching get_growth 14.0. Adjacent weeks: 18 on 2026-08-29, 15 on 2026-08-22, 24 on 2026-08-08, 36 on 2026-08-01. The series hit 100 on 2026-06-06, with 96 on 2026-05-16, 83 on 2026-05-30, and 80 on 2026-05-23. The 2025-09-06 close was 38. The 2026-01-03 close was 24. The 7D drop from 18 to 14 sits at the bottom of that summer drop, not at a new high.
get_time_series for swiftui closed at 19 on 2026-09-05, matching get_growth 19.0. Adjacent weeks: 19 on 2026-08-29, 23 on 2026-08-22, 30 on 2026-08-08. Peak 100 on 2026-06-06, with 97 on 2026-05-16 and 95 on 2026-06-20. Flat 7D at 19.0 is the floor after that peak, not a recovery.
swiftlang is a sparse series. Tip 48.0 versus 0.0 on 2026-08-29, which printed growth 999999. Report 48.0 versus 0.0. Do not store 999999. 14D was 48.0 versus 45.0 (+6.67%). 3M was 48.0 versus 61.0 (-21.31%). 12M was 48.0 versus 0.0 on 2025-09-06. YTD was 48.0 versus 69.0 on 2026-01-03 (-30.43%). The series is mostly zeros until late 2025, then 90 on 2025-12-13 and 100 on 2026-02-28. Concatenated domain tokens are not the language token.
Bare swift Search tipped 19.0, down 9.52% from 21.0, with estimated volume 1,370,000 versus 1,510,000. 3M was 19.0 versus 29.0 (-34.48%) with baseline volume 2,090,000. 12M was 19.0 versus 33.0 (-42.42%) with baseline volume 2,380,000. The phrase tokens in this pull did not include volume fields. Do not copy the polluted swift volume onto swift programming. The Kotlin OkHttp sibling of this helper is Kotlin Trends API.
What did YouTube, News, and Wikipedia return?
YouTube for swift programming tipped 51.0 on 2026-09-05, flat versus 51.0 on 2026-08-29. 14D was 51.0 versus 35.0 (+45.71%). 30D was 51.0 versus 43.0 (+18.6%). 3M was 51.0 versus 56.0 (-8.93%). 12M was 51.0 versus 42.0 (+21.43%). YTD was 51.0 versus 40.0 (+27.5%). Search 3M was -86.0%. YouTube 3M was -8.93%. A Search summer crash is not a YouTube crash. get_time_series closed at 51 on 2026-09-05, matching get_growth. Adjacent weeks: 51 on 2026-08-29, 35 on 2026-08-22, 43 on 2026-08-08. Peak in this pull is 100 on 2023-07-15. Tip 51 is not that peak.
YouTube for swiftui moved the other way on 7D. It tipped 31.0, up 3.33% from 30.0 on 2026-08-29, while Search for the same token was flat. 14D was 31.0 versus 34.0 (-8.82%). 30D was 31.0 versus 29.0 (+6.9%). 3M was 31.0 versus 27.0 (+14.81%) while Search 3M was -81.0%. 12M was 31.0 versus 49.0 (-36.73%). YTD was 31.0 versus 36.0 (-13.89%). Phrase YouTube and phrase Search are not one series.
Keyword Google News for swift programming tipped 3.0 on 2026-09-05 versus 0.0 on every listed baseline, which printed growth 999999. The payload marked data_quality low with a warning that the underlying signal is over 90% zeros. Report 3.0 versus 0.0. Keyword News and the Google News Top News board are different feeds. Store the low-quality flag. Do not fill News from Search 14.0.
Wikipedia resolved two titles. Keyword Swift (programming language) resolved with August score 0.0 and 10,726 views versus July 2.6 / 11,453 (score -100.0%, volume -6.35%). 3M volume was 10,726 versus 12,557 (-14.58%). 12M volume was 10,726 versus 14,474 on 2025-08-01 (-25.89%) while the score went 0.0 versus 13.3 (-100.0%). YTD volume was 10,726 versus 14,270 (-24.84%). 7D and 14D collapsed to the same monthly point. Report both score and volume.
Keyword Swift is a different page. August score 4.1 with 1,996 views versus July 6.2 / 2,293 (score -33.87%, volume -12.95%). 3M volume was 1,996 versus 2,101 (-5.0%). 12M volume was 1,996 versus 1,879 (+6.23%) while the score went 4.1 versus 3.3 (+24.24%). YTD volume was 1,996 versus 2,453 (-18.63%). The language page has more August views than the short title (10,726 versus 1,996). That is the opposite of a short-title-wins resolution. Compare Wikipedia on volume. Do not join either page onto Search 14.0. Notes for the Wikipedia source sit on Wikipedia Trends.
How does a watchlist store live boards next to weekly scores?
get_top_trends has no keyword. It returns a ranked board. Pair it with get_growth for the tokens that appear, using the exact board string.
{"mode":"get_top_trends","type":"Google Trends","limit":25}
{"mode":"get_top_trends","type":"Google Trends","sort":"rank_change","window":"1d","limit":25}
The Google Trends board at 2026-09-12T08:01:39Z ranked iphone duo 1, labor day 2, iphone 18 3, and practical magic 2 16. The 1-day rank_change sort (18 rows, baseline 2026-09-11T02:01:29Z) put practical magic 2 at rank 16 with rank_change 46 from prev_rank 62. The 7-day sort returned 2 rows and omitted that token. Weekly Search for the same phrase was 50.0, up 72.41% from 29.0. Live rank and the 7-day mover list can disagree even when weekly Search is already grinding up. The walk-through is Practical Magic 2 live rank versus weekly Search.
A Swift watchlist that stores six Search tokens (swift programming, swiftui, xcode, swiftlang, vapor swift, objective-c) plus one Google Trends board uses 7 successful 200s. Four runs per 30-day month is 28 calls and fits the free cap of 100. Daily polling of that set is about 210 calls and needs Starter (5,000). Modes and sources for the modes live at https://trendsapi.ai/docs. Google Search board strings are not always valid get_growth keywords. Pair get_top_trends rank, rank_change, and get_growth before writing an alert. Source notes for Search sit on Google Trends.
The Rust sibling of this helper is Rust Trends API. The Go sibling is Go Trends API. The Python sibling is Python Trends API.
Envelope checklist
POST https://api.trendsapi.ai/apiwithAuthorization: Bearer <api_key>.- Modes are
get_time_series,get_growth, andget_top_trendsonly. - Parse
bodytwice before readingresultsor dated points. - Google Search uses the exact token typed.
swift,swift programming,swift language,apple swift,swiftlang,swiftui,xcode, andvapor swiftare eight series. Wikipedia titles are resolved names; confirm the title and compare on volume before joining. - Quota counts successful 200 responses: free 100/month, then 5,000 / 25,000 / 100,000 on paid tiers.
No Swift package is required. A 40-line URLSession helper covers growth, series, and board pulls for jobs that already run under launchd or a systemd timer.