]> BookStack Code Mirror - api-scripts/blob - node-generate-postman-collection/readme.md
Added postman collection gen example
[api-scripts] / node-generate-postman-collection / readme.md
1 # Generate Postman Collection
2
3 This script will scan the BookStack API documentation and generate
4 out an importable collection for [Postman](https://www.postman.com/).
5
6 **Note:** This has been built quite hastily so the output may not be
7 100% accurate but should massively speed up most use-cases.
8
9 [An example of the output can be found here](https://gist.githubusercontent.com/ssddanbrown/de805abfdf1a1defb54500055de5e7ea/raw/7ec246a4d140c98313f3bcda00e1bac6d9e68b68/bs.postman_collection.json).
10
11 The output collection will contain a folder for each of the API categories.
12 Collection variables are used to configure the API base url, token ID
13 and token secret. 
14
15 ## Requirements
16
17 You will need NodeJS installed (Tested on v16, may work on earlier versions).
18
19 ## Running
20
21 First, download all the files in the same directory as this readme to a folder on your system
22 and run the below from within that directory.
23
24 ```bash
25 # Install NodeJS dependencies via NPM
26 npm install 
27
28 # Setup
29 # ALTERNATIVELY: Open the script and add to the empty strings in the variables at the top.
30 export BS_URL=https://bookstack.example.com # Set to be your BookStack base URL
31 export BS_TOKEN_ID=abc123 # Set to be your API token_id
32 export BS_TOKEN_SECRET=123abc # Set to be your API token_secret
33
34 # Running the script
35 node index.js
36 ```
37
38 The script outputs stdout on the command line, so you'll most likely want to redirect the output to a file.
39         
40 ## Examples
41
42 ```bash
43 # Generate the collection to a 'bookstack.postman_collection.json' file. 
44 node index.js > bookstack.postman_collection.json
45 ```