suno 0.6.0

Generate AI music from your terminal — Suno v5.5 with tags, exclude, vocal control, and all generation features
use super::SunoClient;
use super::types::{FeedFilters, FeedResponse, FeedV3Request};
use crate::errors::CliError;

impl SunoClient {
    /// List songs using feed/v3. `cursor` is the opaque `next_cursor` token
    /// from a previous response — feed/v3 does NOT accept page numbers.
    /// `None` fetches the first page.
    pub async fn feed(&self, cursor: Option<String>) -> Result<FeedResponse, CliError> {
        let req = FeedV3Request {
            cursor,
            limit: Some(20),
            filters: None,
        };
        self.with_auth_retry(|| async {
            let resp = self.post("/api/feed/v3").json(&req).send().await?;
            let resp = self.check_response(resp).await?;
            Ok(resp.json().await?)
        })
        .await
    }

    /// Search songs using feed/v3 native searchText filter.
    pub async fn search(&self, query: &str) -> Result<FeedResponse, CliError> {
        let req = FeedV3Request {
            cursor: None,
            limit: Some(50),
            filters: Some(FeedFilters {
                search_text: Some(query.to_string()),
                trashed: Some("False".to_string()),
                full_song: None,
                stem: None,
            }),
        };
        self.with_auth_retry(|| async {
            let resp = self.post("/api/feed/v3").json(&req).send().await?;
            let resp = self.check_response(resp).await?;
            Ok(resp.json().await?)
        })
        .await
    }
}