跳转到主要内容
POST
/
api
/
v1
/
generate
/
get-timestamped-lyrics
获取带时间戳的歌词
curl --request POST \
  --url https://api.sunoapi.org/api/v1/generate/get-timestamped-lyrics \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "taskId": "5c79****be8e",
  "audioId": "e231****-****-****-****-****8cadc7dc"
}
'
import requests

url = "https://api.sunoapi.org/api/v1/generate/get-timestamped-lyrics"

payload = {
"taskId": "5c79****be8e",
"audioId": "e231****-****-****-****-****8cadc7dc"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({taskId: '5c79****be8e', audioId: 'e231****-****-****-****-****8cadc7dc'})
};

fetch('https://api.sunoapi.org/api/v1/generate/get-timestamped-lyrics', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sunoapi.org/api/v1/generate/get-timestamped-lyrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'taskId' => '5c79****be8e',
'audioId' => 'e231****-****-****-****-****8cadc7dc'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.sunoapi.org/api/v1/generate/get-timestamped-lyrics"

payload := strings.NewReader("{\n \"taskId\": \"5c79****be8e\",\n \"audioId\": \"e231****-****-****-****-****8cadc7dc\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.sunoapi.org/api/v1/generate/get-timestamped-lyrics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"taskId\": \"5c79****be8e\",\n \"audioId\": \"e231****-****-****-****-****8cadc7dc\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.sunoapi.org/api/v1/generate/get-timestamped-lyrics")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"taskId\": \"5c79****be8e\",\n \"audioId\": \"e231****-****-****-****-****8cadc7dc\"\n}"

response = http.request(request)
puts response.read_body
{
  "code": 200,
  "msg": "success",
  "data": {
    "alignedWords": [
      {
        "word": "[Verse]\nWaggin'",
        "success": true,
        "startS": 1.36,
        "endS": 1.79,
        "palign": 0
      }
    ],
    "waveformData": [
      0,
      1,
      0.5,
      0.75
    ],
    "hootCer": 0.3803191489361702,
    "isStreamed": false
  }
}

参数选择逻辑

  1. audioId 参数:
    • audioId 参数为必需参数,用于标识确切的曲目
    • 为生成任务中的音频轨道提供唯一标识符

开发者注意事项

  1. 时间戳值以秒为单位
  2. 返回的波形数据可用于音频可视化
  3. 对于纯音乐曲目(使用 instrumental=true 生成的),将没有歌词数据
  4. 典型用例:音乐播放器界面中的卡拉OK式歌词显示

授权

Authorization
string
header
必填

🔑 API 认证说明

所有接口都需要通过 Bearer Token 方式进行认证。

获取 API Key

  1. 访问 API Key 管理页面 获取您的 API Key

使用方式

在请求头中添加:

Authorization: Bearer YOUR_API_KEY

⚠️ 注意:

  • 请妥善保管您的 API Key,不要泄露给他人
  • 如果怀疑 API Key 泄露,请立即在管理页面重置

请求体

application/json
taskId
string
必填

音乐生成任务的任务ID。用于标识包含歌词的生成任务。

示例:

"5c79****be8e"

audioId
string
必填

要获取歌词的音轨的音频ID。

示例:

"e231****-****-****-****-****8cadc7dc"

响应

请求成功

code
enum<integer>

状态码说明

  • ✅ 200 - 请求成功
  • ⚠️ 400 - 参数错误
  • ⚠️ 401 - 没有访问权限
  • ⚠️ 404 - 请求方式或者路径错误
  • ⚠️ 405 - 调用超过限制
  • ⚠️ 413 - 主题或者prompt过长
  • ⚠️ 429 - 积分不足
  • ⚠️ 430 - 您的调用频率过高,请稍后再试。
  • ⚠️ 455 - 网站维护
  • ❌ 500 - 服务器异常
可用选项:
200,
400,
401,
404,
405,
413,
429,
430,
455,
500
示例:

200

msg
string

当 code != 200 时,展示错误信息

示例:

"success"

data
object