Postman’s gotten too heavy for my taste, and setting it up cleanly on Nix isn’t always smooth. Anyone found a lightweight, API testing tool that fits well in a Nix workflow — ideally with OpenAPI or collection support?
Great question. Curious if any of these suggestions suit you:
- xh or httpie are flexible commands for interacting with HTTP APIs
- I haven’t tried posting but that may give you more of a Postman feel, but in the terminal (note that it is only in nixpkgs unstable for now)
While those are command-line/tui tools, if that isn’t to your liking, you could take a look at insomnia
httpie + jq is pretty good for testing. But I haven’t really found a good shell script based test framework yet. I went so far as to user powershell and pester with httpie and jq but that’s also a pain to setup.
I didn’t even think about Powershell. Depending on your needs, using Powershell commands Invoke-WebRequest, Invoke-RestMethod, ConvertFrom-Json, ConvertTo-Json could work well, and with Powershell’s native object support (rather than just passing text around, although it can do that too) working with JSON is pretty straightforward. For that reason, I wouldn’t think httpie and jq would be necessary in a Powershell environment. Pester is a brilliant idea, @truh.
I don’t think of Powershell as “lightweight” but compared to Postman, it would feel that way. But it is a very different ecosystem than most shells, and would take some getting used to.
I don’t know of any additional framework that builds a testing client around it, but if you’re thinking about powershell, nushell also has excellent inherent support for json and http requests (and in the last release, background jobs with channels).
If you happen to use vscode, there are several extensions that are basically postman clones. I don’t have any particular recommendations, though.
I was using Powershell because of Pester, I don’t usually use Powershell. I wasn’t able to find any test framework as good as Pester for bash.
httpie and jq work well in powershell. Writing and reading the test code is a joy. Honestly also pretty convenient to be able to just run any other command from your test suite and to be able to use the same tools for testing CLIs.
But installing the test environment is pretty annoying.
Here a small excerpt
Describe "GET /api/v1/product" {
It "should respond with 12 products" {
http GET :8000/api/v1/product `
| jq --raw-output '.data | length' `
| Should -Be 12
}
}
restish is pretty good, you can generate your api.json
using nix, because its just json, and then you get an open-api client for free that can handle oauth2 for you as well (as long as its client credentials, or non-confidential code with pkce).
Thanks for these — I’ve used httpie
before, but haven’t checked out xh
. I’ll give it a go. Insomnia’s GUI is decent, though it’s still a bit much when I want quick terminal interactions. Appreciate the list!
That combo sounds powerful but yeah, I can imagine setup being frustrating. Pester’s structure does look clean for assertions though. Do you keep your test cases version-controlled, or is it more ad hoc?
Yeah, Powershell’s object handling is one of its underrated features. I just wish it felt less alien on non-Windows environments. I’m curious, do you think it’d be worth it to script out some setup steps for nix integration?
Nushell’s been on my radar but I haven’t had a good excuse to dive in. Might be time. For VSCode extensions, I’ve seen REST Client — have you tried that one, or is it more like traditional Postman alternatives?
That testing structure with Describe
and It
blocks is super readable. I agree, being able to mix shell commands and HTTP calls makes it so flexible. If only the setup pain could be reduced, I’d be all in on this.
Nushell does much of what powershell does but in a way that integrates well on multiple platforms. Plus, syntax is pretty familiar if you’ve done some rust.
I’ve started using it recently, http test suites were the first thing that came to mind for more use cases
I also found Postman to have become too heavy, I tried both Insomnia and Hoppscotch and the latter seemed better in my opinion
It feels alien to me in Windows, too . Well-designed, but alien.
My takeaway from this thread is that Nushell is probably a better option, but I am not yet understanding “script out setup steps” for Powershell. It is already in nixpkgs, so you can install it with nix. Then launch with pwsh
.
I’d add https://hurl.dev to the list too.
I’m using bruno https://www.usebruno.com/
Httpyac perhaps? It’s a command line tool.
I keep my test cases in the same repo as the project source code.