---
title: "设置歌曲评级"
method: PUT
path: "/songs/{id}/rating"
tags: ["歌曲管理"]
---

# 设置歌曲评级

`PUT /songs/{id}/rating`

## Request

- Base URL: `https://localhost:58091/api/v1`
- URL: `https://localhost:58091/api/v1/songs/{id}/rating`
- Auth: API key in header `Authorization`

设置单首歌曲的评级（0-100 整数；0 表示清除评级，未评级歌曲缺省 0）。评级是用户主观标注，仅存数据库，不写入音频文件标签。星级 UI 按 20/颗映射（如 80 = 4 星）。

## Path parameters

- `id` integer, required

## Request body

- object
  - `rating` integer

## Response `200`

成功返回 {id, rating}

- object

## Other responses

- `400`: 评级值超出 0-100 范围
- `404`: 歌曲不存在
- `500`: 服务器错误

## Changes

- **2026-11-17** `4b48b91de725`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/songloft-org/apis/songloft-api/changes/songs/:id/rating/put.md)

---

[API](https://skmtc.dev/songloft-org/apis/songloft-api.md) - [All operations](https://skmtc.dev/songloft-org/apis/songloft-api/llms.txt) - [OpenAPI document](https://skmtc.dev/songloft-org/apis/songloft-api/revisions/5bc05f13fffd?raw)
