跳到主要内容

CSV 姓名智能 API

处理 CSV 文件前先进行验证,然后为每一行补充性别、年龄、族裔和语言预测结果。

基础 URL​

https://api.genderrecognition.com

CSV 格式​

CSV 文件必须包含名和姓两列。后端接受 camelCase 或 snake_case 格式的列名。

firstName,lastName
Alex,Morgan
Jamie,Patel

上传时使用 file 字段,文件大小不得超过 10 MB。

验证端点​

POST /v1/voice-gender-recognition/api/csv/validate

请求标头​

apiKey: YOUR_API_KEY
Content-Type: multipart/form-data

请求正文​

字段类型必填说明
filefile是要验证的 CSV 文件。

示例​

curl -X POST "https://api.genderrecognition.com/v1/voice-gender-recognition/api/csv/validate" \
-H "apiKey: YOUR_API_KEY" \
-F "file=@names.csv"

响应​

{
"success": true,
"message": "CSV file validated successfully",
"csvInfo": {
"rowCount": 2,
"headers": ["firstName", "lastName"],
"sampleData": [
{
"firstName": "Alex",
"lastName": "Morgan"
}
]
},
"userInfo": {
"remainingRequests": 2999,
"canProcess": true
}
}

处理端点​

POST /v1/voice-gender-recognition/api/csv

请求标头​

apiKey: YOUR_API_KEY
Content-Type: multipart/form-data

请求正文​

字段类型必填说明
filefile是要处理的 CSV 文件。
responseFormatstring否使用 csv 可接收 CSV 文件。默认返回 JSON。

JSON 响应示例​

curl -X POST "https://api.genderrecognition.com/v1/voice-gender-recognition/api/csv" \
-H "apiKey: YOUR_API_KEY" \
-F "file=@names.csv"
{
"success": true,
"message": "Successfully processed 2 rows",
"data": [
{
"firstName": "Alex",
"lastName": "Morgan",
"gender": "male",
"genderProbability": 0.86,
"age": "25-34",
"ageProbability": 0.78,
"ethnicity": "English",
"ethnicityProbability": 0.74,
"language": "English",
"languageProbability": 0.8
}
],
"summary": {
"totalRows": 2,
"processedRows": 2,
"remainingRequests": 2997
}
}

CSV 响应示例​

curl -X POST "https://api.genderrecognition.com/v1/voice-gender-recognition/api/csv" \
-H "apiKey: YOUR_API_KEY" \
-F "file=@names.csv" \
-F "responseFormat=csv"

当 responseFormat 为 csv 时,API 会返回 text/csv 格式的可下载处理结果。其他值会返回常规 JSON 响应。

错误情况​

缺少 API 密钥​

{
"error": "API key is required"
}

API 密钥无效​

{
"error": "Invalid API key"
}

缺少文件​

{
"error": "No CSV file uploaded"
}

文件类型无效​

{
"error": "Invalid file type. Only .csv format is allowed."
}

CSV 列无效​

{
"error": "Invalid CSV format. The file must contain columns named 'firstName' or 'first_name' and 'lastName' or 'last_name'. Found columns: name"
}

配额已用尽​

{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "You have exceeded your free tier limit of 50 requests.",
"detailedMessage": "Insufficient remaining requests. Required: 2, Available: 0",
"details": {
"limit": 50,
"used": 50,
"reset_date": "2026-07-01T00:00:00.000Z"
},
"suggested_action": "Please upgrade to a premium plan to continue using the API."
}
}

处理失败​

{
"error": "Internal server error"
}