Skip to content

Commit 3918043

Browse files
dylanjeffersclaude
andcommitted
[Feed] Add GET /v1/users/{id}/feed/for-you endpoint
Server-side replacement for the client-side blend in apps' useForYouFeed.ts. Four candidate streams interleaved with a fixed 10-slot pattern, pos: [R R R F R T R F U R] giving 60% recommended (50% baseline + 10% filler when other sources thin out), 20% following originals, 10% trending, 10% underground. When a slot's preferred source is exhausted, falls through in priority order recommended → following → trending → underground. Each source caps at 200 candidates; the union is deduped by track_id and the caller's already-saved tracks are filtered at the SQL level (client filtered them client-side; filtering early avoids burning candidates on already-saved tracks). Pagination (limit/offset) applies to the composed list. Source SQL mirrors the underlying single-source endpoints: - recommended: v1_users_recommended_tracks.go (top tracks from the user's top-played genres, excluding played) — switched to score-DESC ordering for stable pagination - following: v1_users_feed.go w/ filter=original - trending: v1_tracks_trending.go (week) - underground: v1_tracks_trending_underground.go (week, sub-1500 follower & following artists) Liveness, gating, and unlisted/deleted filters mirror those files and v1_events_remix_contests.go. Path-param userId (the requesting user) follows the same pattern as /v1/users/:userId/recommended-tracks and /v1/users/:userId/feed. Consumed by apps' useForYouFeed.ts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1450066 commit 3918043

4 files changed

Lines changed: 797 additions & 0 deletions

File tree

api/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ func NewApiServer(config config.Config) *ApiServer {
426426
g.Get("/users/:userId/albums", app.v1UserAlbums)
427427
g.Get("/users/:userId/playlists", app.v1UserPlaylists)
428428
g.Get("/users/:userId/feed", app.v1UsersFeed)
429+
g.Get("/users/:userId/feed/for-you", app.v1UsersFeedForYou)
429430
g.Get("/users/:userId/connected_wallets", app.v1UsersConnectedWallets)
430431
g.Get("/users/:userId/transactions/audio", app.v1UsersTransactionsAudio)
431432
g.Get("/users/:userId/transactions/audio/count", app.v1UsersTransactionsAudioCount)

api/swagger/swagger-v1.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9439,6 +9439,66 @@ paths:
94399439
"500":
94409440
description: Server error
94419441
content: {}
9442+
/users/{id}/feed/for-you:
9443+
get:
9444+
tags:
9445+
- users
9446+
summary: Get For You feed for user
9447+
description:
9448+
Returns a personalized For You track feed for the user. Mirrors
9449+
the client-side blend of recommended, following originals, weekly
9450+
trending, and underground trending using a fixed 10-slot
9451+
interleave (60% recommended, 20% following, 10% trending, 10%
9452+
underground). Already-saved tracks are filtered out and results
9453+
are deduped by track ID.
9454+
operationId: Get User For You Feed
9455+
security:
9456+
- {}
9457+
- OAuth2:
9458+
- read
9459+
parameters:
9460+
- name: id
9461+
in: path
9462+
description: A User ID
9463+
required: true
9464+
schema:
9465+
type: string
9466+
- name: limit
9467+
in: query
9468+
description: The number of items to fetch
9469+
schema:
9470+
type: integer
9471+
default: 10
9472+
minimum: 1
9473+
maximum: 100
9474+
- name: offset
9475+
in: query
9476+
description:
9477+
The number of items to skip. Useful for pagination (page number
9478+
* limit)
9479+
schema:
9480+
type: integer
9481+
default: 0
9482+
minimum: 0
9483+
maximum: 200
9484+
- name: user_id
9485+
in: query
9486+
description: The user ID of the user making the request
9487+
schema:
9488+
type: string
9489+
responses:
9490+
"200":
9491+
description: Success
9492+
content:
9493+
application/json:
9494+
schema:
9495+
$ref: "#/components/schemas/tracks"
9496+
"400":
9497+
description: Bad request
9498+
content: {}
9499+
"500":
9500+
description: Server error
9501+
content: {}
94429502
/users/{id}/library/albums:
94439503
get:
94449504
tags:

0 commit comments

Comments
 (0)