Skip to content
YKTechHubInc

开发

示例数据。

测试应用时可以调用的示例人物、文章和商品。

桌上打开的笔记本电脑,旁边是一盆植物和一只黄杯子。

图片

160 by 160 placeholder300 by 120 placeholder90 by 160 placeholder128 by 160 placeholder

地址

{
  "id": 1,
  "slug": "electronics",
  "name": "Electronics",
  "width": 1200,
  "height": 630,
  "image": "/mock/img/1200x630",
  "count": 3,
  "products": [
    {
      "id": 1,
      "name": "Pocket phone",
      "price": 429,
      "category": "electronics",
      "width": 400,
      "height": 400,
      "image": "/mock/img/400x400"
    },
    {
      "id": 2,
      "name": "Studio headphones",
      "price": 89,
      "category": "electronics",
      "width": 800,
      "height": 600,
      "image": "/mock/img/800x600"
    },
    {
      "id": 3,
      "name": "Compact keyboard",
      "price": 74,
      "category": "electronics",
      "width": 1200,
      "height": 480,
      "image": "/mock/img/1200x480"
    }
  ]
}

如何调用

No key. Any site can call these. A normal read is cached for a day. A write is not.

列表和单条

Lists are /mock/users, /mock/posts, /mock/comments, /mock/products, and /mock/categories. One record adds the id: /mock/users/1. A category also accepts its slug, as in /mock/categories/electronics.

筛选

userId, postId, and category keep the matching records. q searches the fields. limit is at most 100. offset skips that many records. A list answers with data, total, limit, and offset.

图片

/mock/img/640x480 returns an SVG. Width and height run from 16 to 2000. status and delay do not apply to pictures.

写入

POST /mock/products with a JSON body. The same JSON comes back with HTTP 201, and the list does not change. PUT /mock/users/1 returns the body you sent. DELETE /mock/users/1 returns that body, or deleted and the id when you send none. The next read still has the original record. The body is 100000 characters or fewer.

失败

status sets the HTTP status and still returns the same JSON. Use an integer from 200 to 599. 204, 205, and 304 are refused, because they cannot carry JSON. delay waits that many milliseconds, up to 10000, then returns the same JSON. Both can be used together: /mock/products?status=503&delay=1500.

A missing collection or record is 404. status and delay do not change that. A simulated response is not cached.