API 文档

API文档

使用随机用户生成器API的完整指南,包含示例、参数和最佳实践。

免费使用
高性能
实时响应
易于集成
快速开始
在几秒钟内开始使用随机用户生成器API。使用AJAX调用我们的API并接收随机生成的用户数据。
$.ajax({
   url: 'https://randomuserapi.com/api/user',
   dataType: 'json',
   success: function(data) {
     console.log(data);
   }
});
实时示例

API 示例

常用的API调用示例,点击复制按钮复制接口路径,点击测试按钮直接测试接口。

GET
基础用法
生成一个来自美国的随机用户
https://randomuserapi.com/api/user?nat=US
GET
多个用户
生成来自美国的多个用户(最多5000个)
https://randomuserapi.com/api/user?nat=US&results=5
GET
按性别筛选
生成来自美国的特定性别用户
https://randomuserapi.com/api/user?nat=US&gender=female&results=3
GET
组合筛选
为美国用户组合多个筛选条件
https://randomuserapi.com/api/user?nat=US&gender=male&results=2
GET
CSV格式
获取CSV格式的美国用户数据
https://randomuserapi.com/api/user?nat=US&format=csv&results=3
GET
种子结果
使用种子生成可重现的美国用户数据
https://randomuserapi.com/api/user?nat=US&seed=myseed123&results=2
GET
分页
使用分页高效地浏览大型数据集
https://randomuserapi.com/api/user?page=3&results=10&seed=abc
GET
自定义密码
生成具有特定字符集和长度要求的密码
https://randomuserapi.com/api/user?password=upper,lower,1-16
GET
多个国家
在单个API调用中请求来自多个国家的用户
https://randomuserapi.com/api/user?nat=us,dk,fr,gb
GET
字段过滤
仅包含指定字段以优化响应大小
https://randomuserapi.com/api/user?inc=name,email&nat=US
GET
仅邮箱
仅获取用户的邮箱信息
https://randomuserapi.com/api/user?inc=email&nat=US&results=3
GET
联系信息
获取用户的姓名、邮箱和电话信息
https://randomuserapi.com/api/user?inc=name,email,phone&nat=US&results=2
GET
仅地址
仅获取用户的位置信息
https://randomuserapi.com/api/user?inc=location&nat=US&results=2
GET
排除字段
从响应中排除特定字段以减少负载大小
https://randomuserapi.com/api/user?exc=login,registered,id&nat=US&results=2
GET
无信息对象
从响应中移除info对象,仅返回用户数据
https://randomuserapi.com/api/user?inc=name,email&noinfo&nat=US&results=2
多个用户

在单个请求中生成多个用户。指定要生成的用户数量。

https://randomuserapi.com/api/user?results=5000
1-5000个用户
性别筛选

按性别筛选用户。指定'male'或'female'以获取特定性别的用户。

https://randomuserapi.com/api/user?gender=female
malefemale
国籍筛选

按国籍筛选用户。您可以指定用逗号分隔的多个国籍。

https://randomuserapi.com/api/user?nat=us,dk,fr,gb
种子值

使用种子一致地生成相同的用户集。非常适合测试和可重现的结果。

https://randomuserapi.com/api/user?seed=foobar
密码选项

使用字符集和长度约束自定义密码生成。

https://randomuserapi.com/api/user?password=upper,lower,1-16
upperlowernumberspecial
字段选择

包含或排除响应中的特定字段以优化负载大小。

https://randomuserapi.com/api/user?inc=name,location,email
https://randomuserapi.com/api/user?exc=login,registered