📅  最后修改于: 2023-12-03 14:58:40.978000             🧑  作者: Mango
随机人员数据 API 是一个为开发者提供随机生成虚拟人员信息的接口。它可用于模拟测试数据、生成随机用户信息或填充数据库等应用场景。该 API 提供了生成随机姓名、性别、年龄、地址、邮箱等人员信息的功能。
https://api.example.com/random-person
GET
| 参数名 | 类型 | 必需 | 描述 | | -------- | ------- | ---- | ---------------------------------- | | gender | string | 否 | 性别("male"或"female") | | age_min | integer | 否 | 最小年龄(默认为0) | | age_max | integer | 否 | 最大年龄(默认为100) | | nationality | string | 否 | 国籍("en"、"fr"、"es"、"cn"等) | | count | integer | 否 | 返回的人员数量(默认为1) |
成功返回时,将返回一个 JSON 对象,包含请求参数指定的数量的人员信息。
示例响应:
{
"data": [
{
"name": "John Doe",
"gender": "male",
"age": 32,
"address": "123 Main St, Anytown, USA",
"email": "johndoe@example.com"
},
{
"name": "Jane Smith",
"gender": "female",
"age": 25,
"address": "456 Elm St, Othertown, USA",
"email": "janesmith@example.com"
}
]
}
| 字段名 | 类型 | 描述 | | -------- | ------- | --------------- | | name | string | 姓名 | | gender | string | 性别 | | age | integer | 年龄 | | address | string | 地址 | | email | string | 电子邮箱 |
GET https://api.example.com/random-person?gender=male&age_min=20&age_max=30&count=5
{
"data": [
{
"name": "John Doe",
"gender": "male",
"age": 25,
"address": "123 Main St, Anytown, USA",
"email": "johndoe@example.com"
},
{
"name": "Adam Smith",
"gender": "male",
"age": 28,
"address": "456 Elm St, Othertown, USA",
"email": "adams@example.com"
},
{
"name": "David Johnson",
"gender": "male",
"age": 22,
"address": "789 Oak St, Thistown, USA",
"email": "davidj@example.com"
},
{
"name": "Michael Brown",
"gender": "male",
"age": 24,
"address": "987 Pine St, Somewhere, USA",
"email": "mikebrown@example.com"
},
{
"name": "Chris Davis",
"gender": "male",
"age": 27,
"address": "321 Maple St, Nowhere, USA",
"email": "chrisd@example.com"
}
]
}
如果发生错误,将返回一个带有错误消息的JSON对象。
示例错误响应:
{
"error": "Invalid parameters"
}
| 错误码 | 描述 | | ------ | --------------------- | | 400 | 请求参数无效 | | 500 | 服务器内部错误 |
以上就是随机人员数据 API 的详细介绍,希望对开发者有所帮助!