get_text_animations API Documentation
Interface Overview
Interface Name: get_text_animations
Interface URL: POST /openapi/capcut-mate/v1/get_text_animations
Function Description: Get text entrance/exit animation list, returns all supported text entrance/exit animations that meet the conditions. Supports filtering by animation type (entrance, exit, loop) and membership mode (all, VIP, free).
More Documentation
π For more detailed documentation and tutorials, please visit: https://docs.jcaigc.cn
Request Parameters
Request Body (application/json)
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| mode | integer | No | 0 | Animation mode: 0=all, 1=VIP, 2=free |
| type | string | Yes | - | Animation type: in=entrance, out=exit, loop=loop |
Animation Mode Description
| Mode Value | Mode Name | Description |
|---|---|---|
| 0 | All | Returns all animations (including VIP and free) |
| 1 | VIP | Returns only VIP animations |
| 2 | Free | Returns only free animations |
Animation Type Description
| Type Value | Type Name | Description |
|---|---|---|
| in | Entrance Animation | Animation effect when text appears |
| out | Exit Animation | Animation effect when text disappears |
| loop | Loop Animation | Continuous loop animation effect for text |
Request Examples
Get All Entrance Animations
{
"mode": 0,
"type": "in"
}
Get VIP Exit Animations
{
"mode": 1,
"type": "out"
}
Get Free Loop Animations
{
"mode": 2,
"type": "loop"
}
Response Format
Success Response
{
"effects": "[{\"resource_id\":\"7314291622525538843\",\"type\":\"in\",\"category_id\":\"ruchang\",\"category_name\":\"ε
₯εΊ\",\"duration\":500000,\"id\":\"35395178\",\"name\":\"ε°ιͺι£ε¨\",\"request_id\":\"\",\"start\":0,\"icon_url\":\"https://lf5-hl-hw-effectcdn-tos.byteeffecttos.com/obj/ies.fe.effect/459c196951cadbd024456a63db89481f\",\"material_type\":\"sticker\",\"panel\":\"\",\"path\":\"\",\"platform\":\"all\"},{\"resource_id\":\"7397306443147252233\",\"type\":\"in\",\"category_id\":\"ruchang\",\"category_name\":\"ε
₯εΊ\",\"duration\":500000,\"id\":\"77035159\",\"name\":\"εθ²θΎε
₯\",\"request_id\":\"\",\"start\":0,\"icon_url\":\"https://lf5-hl-hw-effectcdn-tos.byteeffecttos.com/obj/ies.fe.effect/c15f5c313f8170c558043abf300a0692\",\"material_type\":\"sticker\",\"panel\":\"\",\"path\":\"\",\"platform\":\"all\"}]"
}
Animation Object Structure
Each animation object contains the following fields:
| Field Name | Type | Description |
|---|---|---|
| resource_id | string | Animation resource ID |
| type | string | Animation type (in/out/loop) |
| category_id | string | Animation category ID |
| category_name | string | Animation category name |
| duration | integer | Animation duration (microseconds) |
| id | string | Animation unique identifier |
| name | string | Animation name |
| request_id | string | Request ID (usually empty) |
| start | integer | Animation start time |
| icon_url | string | Animation icon URL |
| material_type | string | Material type (usually "sticker") |
| panel | string | Panel information |
| path | string | Path information |
| platform | string | Supported platforms (usually "all") |
Error Response
400 Bad Request - Parameter Validation Failed
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Request parameter validation failed",
"details": "type parameter must be in, out, or loop"
}
}
500 Internal Server Error - Failed to Get Animations
{
"error": {
"code": "TEXT_ANIMATION_GET_FAILED",
"message": "Failed to get text animations",
"details": "Failed to get animation data"
}
}
Error Codes
| Error Code | HTTP Status Code | Description | Solution |
|---|---|---|---|
| VALIDATION_ERROR | 400 | Request parameter validation failed | Check if type parameter is in/out/loop and mode parameter is 0/1/2 |
| TEXT_ANIMATION_GET_FAILED | 500 | Failed to get text animations | Check service status and try again later |
Usage Instructions
Parameter Instructions
- type parameter: Required parameter, can only choose one of "in", "out", "loop"
- mode parameter: Optional parameter, default is 0 (all animations)
- Response data: The effects field is in JSON string format and needs to be parsed before use
Animation Application Scenarios
-
Entrance Animation (in):
- Applicable for scenes where text appears
- Such as fade-in entrance, snow drift, color change input, etc.
- Usually lasts between 0.5-1 seconds
-
Exit Animation (out):
- Applicable for scenes where text disappears
- Such as fade-out exit, rotate disappear, etc.
- Usually lasts between 0.6-0.8 seconds
-
Loop Animation (loop):
- Applicable for text that needs to continuously attract attention
- Such as heartbeat, flashing effect, etc.
- Usually lasts between 1-1.2 seconds and can loop infinitely
Usage Recommendations
- Choose appropriate animation types based on video content style
- VIP animations usually have better effects but require membership privileges
- It is recommended to first get all animations, then filter as needed
- Can combine animation preview images (icon_url) for users to choose
Example Code
JavaScript Example
// Get all entrance animations
const getInAnimations = async () => {
const response = await fetch('/openapi/capcut-mate/v1/get_text_animations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
mode: 0,
type: 'in'
})
});
const result = await response.json();
const animations = JSON.parse(result.effects);
console.log('Entrance animations list:', animations);
};
// Get free loop animations
const getFreeLoopAnimations = async () => {
const response = await fetch('/openapi/capcut-mate/v1/get_text_animations', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
mode: 2,
type: 'loop'
})
});
const result = await response.json();
const animations = JSON.parse(result.effects);
console.log('Free loop animations list:', animations);
};
Python Example
import requests
import json
def get_text_animations(mode=0, animation_type='in'):
"""Get text animations list"""
url = 'http://localhost:8000/v1/get_text_animations'
data = {
'mode': mode,
'type': animation_type
}
response = requests.post(url, json=data)
if response.status_code == 200:
result = response.json()
animations = json.loads(result['effects'])
return animations
else:
print(f"Request failed: {response.status_code}")
return []
# Usage example
in_animations = get_text_animations(mode=0, animation_type='in')
print(f"Got {len(in_animations)} entrance animations")
vip_out_animations = get_text_animations(mode=1, animation_type='out')
print(f"Got {len(vip_out_animations)} VIP exit animations")
Related Interfaces
- add_captions - Batch add subtitles (can use animation effects)
- add_text_style - Create text rich text styles
- add_effects - Add video effects
Technical Implementation
File Structure
src/
βββ schemas/get_text_animations.py # Request/response data models
βββ service/get_text_animations.py # Business logic implementation
βββ router/v1.py # API route definition
Core Logic
- Parameter Validation: Validate the validity of type and mode parameters
- Data Filtering: Filter animation data based on type and mode parameters
- Data Formatting: Convert animation data to JSON string format
- Response Return: Return API response that conforms to specifications
Data Source
Currently using mock data, in actual projects should:
- Get animation data from database
- Or get animation resources from third-party API
- Support dynamic updates of animation resources
Version Information: v1.0
Last Updated: 2024-09-24
π Project Resources
GitHub: https://github.com/Hommy-master/capcut-mate
Gitee: https://gitee.com/taohongmin-gitee/capcut-mate
Top comments (0)