fooapi:您的虚拟数据一站式平台
我非常高兴地宣布我的个人项目 fooapi.com 正式上线!虽然部分功能仍在开发中,但我将持续更新并分享项目进展。fooapi 的核心目标是创建一个统一平台,通过多种方式访问不同主题的虚拟数据,为您的项目和创意提供模拟数据支持。
涵盖数据类型:
用户 产品 文章 评论 待办事项 图片 电影 音乐 城市(GeoJSON 格式) 国家(GeoJSON 格式)详细文档请访问 fooapi.com/docs
如何使用?
目前,您可以通过以下两种方式获取数据:
REST API GraphQL 查询 (未来将支持 gRPC)fooapi.com/playground 提供了一个测试平台,方便您练习和测试您的查询。
实用示例
以下是一些 fooapi 的应用示例:
生成占位符图片:
只需访问以下链接,即可自定义图片尺寸、背景色、字体色和文本内容:
fooapi.com/imgmaker/700/500/ff0000/000000/foooo
URL 结构:/imgmaker/:width/:height/:bg/:fn/:text
更多信息请访问 fooapi.com/docs/images
地图数据模拟:
使用以下代码获取 3 个城市数据:
1
2
3
fetch(https://fooapi.com/api/cities?limit=3)
.then(res => res.json())
.then(data => console.log(data))
这些城市数据均为真实数据,而非人工生成,确保地图应用中坐标的准确性。
获取随机用户信息:
1
2
3
fetch(https://fooapi.com/api/users/rand)
.then(res => res.json())
.then(data => console.log(data))
返回示例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"id": "1",
"name": "john",
"lastname": "doe",
"username": "johnxdoe11",
"birthdate": "1990-01-01",
"age": 30,
"gender": "male",
"phone": "+63 791 675 8914",
"email": "foo@example.com",
"country": "usa",
"height": 170,
"weight": 70
}
社交媒体数据模拟:
1
2
3
fetch(https://fooapi.com/api/comments)
.then(res => res.json())
.then(data => console.log(data))
返回示例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[
{
"id": "1",
"comment": "Sunshine and sci-fi sounds like a perfect combo! Enjoy getting lost in your book ",
"reactions": 0,
"postId": "1",
"user": {
"id": "50",
"name": "John",
"lastname": "Smith",
"username": "SmiJohnxD100"
}
},
{
"id": "2",
"comment": "Dont forget the sunscreen! What sci-fi are you reading?",
"reactions": 1,
"postId": "1",
"user": {
"id": "2",
"name": "Akira",
"lastname": "Von Trier",
"username": "alphaVonAkirax853"
}
}
// ...更多数据
]
您可以自由探索其他数据类别。
您的反馈至关重要!
欢迎您提供宝贵的反馈意见!fooapi 可用于模拟各种应用、设计和模型。如果您有任何关于新数据类别或功能的建议,请随时在评论区分享。
以上就是为开发者提供的一体化 Fake API的详细内容,更多请关注php中文网其它相关文章!