Export Formats
The request-mock CLI and SDK support 13 export formats for generated HAR data.
Format Table
| Format | CLI Flag | Description | Multi-entry |
|---|---|---|---|
| curl | curl | curl command(s) | One per entry |
| wget | wget | wget command(s) | One per entry |
| Python | python | Python requests code | One per entry |
| Postman | postman | Postman collection v2.1 | Single collection |
| XML | xml | HAR XML representation | Single document |
| YAML | yaml | HAR YAML representation | Single document |
| HAR | har | HAR JSON (standard format) | Single document |
| JSON | json | HAR JSON alias | Single document |
| JSON Lines | jsonl | One JSON entry per line | One per line |
| CSV | csv | Tabular CSV (method, URL, status, ...) | One per row |
| Markdown | markdown | Human-readable markdown table | Single document |
| HTML | html | HTML table | Single document |
| Text | text | Plain text summary | Single document |
CLI Usage
Default output (JSON envelope)
bash
request-mock generate -X GET -u https://api.example.com/users -f harRaw output
bash
request-mock generate -X GET -u https://api.example.com/users -f curl --rawExport to file
bash
request-mock generate -X GET -u https://api.example.com/users -f postman -o collection.jsonRe-export an existing HAR
bash
request-mock export --input out.har -f curl --raw
request-mock export --input out.har -f csv -o output.csvSDK Usage
go
// Export as string
curl, _ := mock.Export(h, mock.FormatCurl)
// Export as bytes with indent
data, _ := mock.ExportBytes(h, mock.FormatJSON, mock.WithExportIndent(2))
// Export to file
mock.ExportToFile(h, mock.FormatCSV, "output.csv")
// MustExport (panics on error)
out := mock.MustExport(h, mock.FormatCurl)Format Constants
go
mock.FormatCurl // "curl"
mock.FormatWget // "wget"
mock.FormatPython // "python"
mock.FormatPostman // "postman"
mock.FormatXML // "xml"
mock.FormatYAML // "yaml"
mock.FormatHAR // "har"
mock.FormatJSON // "json"
mock.FormatJSONLines // "jsonl"
mock.FormatCSV // "csv"
mock.FormatMarkdown // "markdown"
mock.FormatHTML // "html"
mock.FormatText // "text"Implementation
Each format is dispatched in mock.Export() via a switch statement that calls the corresponding method on *har.Har from the har-skills library:
curl→ToCurl()wget→ToWget()python→ToPythonRequests()postman→ToPostmanCollection()xml→ToXML()yaml→ToYAML()har/json→ToJSON()jsonl→ToJSONLines()csv,markdown,html,text→Convert(format, opts)