一键清理掉所有无用的Collection

实际上我没有找到这样的功能,所以使用Postman的Api,自己开发了一个Python脚本,脚本内容如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22

import requests, json

get_all_collections_url = "https://api.getpostman.com/collections"
delete_collection_url = "https://api.getpostman.com/collections/"

headers = {'X-Api-Key': ''}

protect = ["SpringBoot Actuator", "Login"]

result = requests.get(get_all_collections_url, headers=headers)

if result.status_code == 200:
    for item in json.loads(str(result.content, encoding="utf-8"))["collections"]:
        if item["name"] in protect:
            continue

        requests.delete(delete_collection_url + item["id"], headers=headers)

        print("delete {} success".format(item["name"]))


如果你要使用,需要将X-Api-Key换成你自己的。

参考资料

  1. Postman API - Postman Public Workspace