Skip to content

belikh/pySunoAPI

Repository files navigation

Unofficial Suno API Client

This is an unofficial Python client for Suno AI, allowing you to generate music, fetch song details, and manage your account programmatically.

Installation

pip install suno-api

Usage

Authentication

To use this library, you need to obtain your session cookie from the browser.

  1. Log in to Suno.com.
  2. Open Developer Tools (F12) -> Network tab.
  3. Refresh the page.
  4. Find a request to client?_clerk_js_version=... (or any request to suno.com).
  5. Copy the Cookie header value.

Example

from suno.client import SunoClient
import time

# Initialize client
cookie = "YOUR_COOKIE_HERE"
client = SunoClient(cookie)

# Generate a song
print("Generating song...")
clips = client.generate(
    prompt="A chill lofi beat about coding in the rain",
    tags="lofi, hip hop, chill",
    title="Coding in the Rain"
)

for clip in clips:
    print(f"Generated Clip ID: {clip['id']}")

# Wait for generation (simple polling example)
# Note: In a real app, you would poll status
time.sleep(10)

# Get feed/songs
songs = client.get_songs()
for song in songs[:5]:
    print(f"{song['title']} - {song['audio_url']}")

Features

  • Generate Music: Create songs with prompts, tags, and titles.
  • Fetch Songs: Retrieve your generated songs and their metadata (audio URLs, images).
  • Credit Usage: Check your remaining credits.
  • Automatic Token Refresh: Handles JWT token refreshing using your session cookie.

Disclaimer

This is an unofficial library and is not affiliated with Suno AI. Use responsibly and in accordance with Suno's Terms of Service.

About

Unofficial Suno API client library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •