12 ms·
Just Use Curl
- colesantiago 1y ago[flagged]
- brightball 1y agoTo a degree, I understand when people do it when speaking. It can easily be a bad habit, it can slip, it can be your age and the influences around you. When it comes to doing it in a written blog post that you hope other people will read? Boggles the the mind.
- PhilipRoman 1y agoSeems inspired by https://motherfuckingwebsite.com/ https://motherfuckingwebsite.com/ Either way I don't see an issue since it's clearly semi-ironic/self-aware and not an actual rant. Edit: actually even the styling is suspiciously similar to http://bettermotherfuckingwebsite.com/ http://bettermotherfuckingwebsite.com/
- demaga 1y agoThis message on their homepage makes me think author doesn't want other people to read it: > More coming soon. Or not. I don't owe you shit.
- Nekobai 1y agoHonestly, I've never used Postman and I kinda want to start using it now just because of the tone the post has been written with.
- shakna 1y agoThis might just be a cultural thing. Using swearing for emphasis is a non-event where I am. You'll find it equally in documentation as in conversation. There is no taboo around it. It isn't considered to be some "bad habit". We're two decades removed from "Where the bloody hell are you?" [0] You won't find many people reacting to swearing over here as if it's unprofessional. It's just another emphatic. [0] https://en.wikipedia.org/wiki/So_where_the_bloody_hell_are_you%3F https://en.wikipedia.org/wiki/So_where_the_bloody_hell_are_y...
- deleted 1y ago[deleted]
- deleted 1y ago[deleted]
- chuckadams 1y agoI'm pretty sure using cURL to do SOAP would result in a lot more cursing :-|
- hk1337 1y ago*curlsing
- alt187 1y agoNo. It's funny, and it humanizes the writer. Everything doesn't have to be tight-lipped and formally clenched for your enjoyment, Sire.
- unxgod 1y agoyou and everyone below sound like weenies.
- deafpolygon 1y agoI've been using curl, like forever. I don't understand the preoccupation for using postman, et. al. -- why pay for something that literally requires a little bit of light RTFM?
- Xenoamorphous 1y agoI use both. It's quite convenient to have all the collections available and just send the request with a couple of clicks.
- CaptainOfCoit 1y agoFor repeated commands, my projects have a Make/Just file that has cURL commands I wanna validate. Sometimes I even load JSON from a tests/fixtures/*.json file, that also can be reused for other non-E2E tests. Not sure how some developers could be so allergic to the terminal, don't you already spend a lot of time there?
- troupo 1y agoEven those who spend a lot of time in the terminal are capable of recognizing its limitations.
- Xenoamorphous 1y ago> Not sure how some developers could be so allergic to the terminal, don't you already spend a lot of time there? Who says I'm allergic to the terminal? I already stated that I use curl. I could also ask why are some developers so allergic to any kind of UI. And they're very vocal about it. Just use whatever you want.
- CaptainOfCoit 1y ago> Who says I'm allergic to the terminal? I already stated that I use curl. Preferring "a couple of clicks" vs "run one command" seems to indicate so, otherwise I'm not sure why'd someone would prefer the former instead of the latter.
- Havoc 1y ago> It's already on your machine, dipshit Does anyone actually enjoy this uhm style of writing?
- crims0n 1y agoMe, I have a dark and immature sense of humor.
- seandoe 1y agoI like it. It makes me smile. Don't take it personally.
- bravetraveler 1y agoDitto, enjoy the catharsis. Good advice to not take it personally, I'll try to give a less aggressive point of view. All of this has come to mind [but not repeated out of kindness or laziness, whichever]. So, to start: someone wants me to install Postman/similar and pay real money to share and make a request? Absolutely not. I can read the spec from Swagger, or whatever, too... and write down what was useful [for others]. We all have cURL or some version of Python. Surely a few phrases of text worth making plans to save, and paying for [at least twice, you to research and them to store], are worth putting into source control. It's free, even gifts dividends. How? Automation that works faster than a human pushing a button. Or creates more buttons!
- deleted 1y ago[deleted]
- forgetfulness 1y ago13 years old me, back when Maddox offered a very fresh and novel form of content you could grab on your way through the Information Superhighway
- amelius 1y agoAs long as I agree to what is being said, I like this style :)
- 1y ago
- hypeatei 1y agoThere's also hurl: https://hurl.dev https://hurl.dev You define all your requests in a plaintext format and can inject variables etc... plus the name is kinda funny.
- blueflow 1y agoBasically a shell script with a curl invocation in it, except you need to install extra software to execute it. Misses the point of the article.
- hypeatei 1y agoI mean, the article did say: It doesn't need to render a fucking Chromium instance to make a web request. It doesn't depend on a service to run. It doesn't require an "Enterprise" subscription for basic features. So I'd say it meets all of the criteria except being on your machine already.
- bravetraveler 1y agoTheir words, not mine; the first header: "It's already on your machine". We can belabor it, but the domain is 'justuse'. No room for 'except' [unless you're reasonable, of course]. The 'egregious' things are charging to share what will fit very well in SCM (preventing real automation)... and breaking due to Online First/only. It makes sense to require the endpoint I'm talking to. Why would Postman need AWS/us-east-1 [0] for a completely unrelated API? Joyful rent-seeking. cURL, your suggestion (hurl), or HTTPie all make far more sense. Store what they need in the place where you already store stuff. Profit, for free: never go down. Automate/take people out of the button-pushing pattern for a gold star. 0: https://news.ycombinator.com/item?id=45645172 https://news.ycombinator.com/item?id=45645172
- millerm 1y agoYup. Article mentioned `jq` as well. That's an external tool (and so is cURL if we are all being honest here).
- anotherhue 1y ago
- c0balt 1y ago> The UI/UX is perfect While I like curl, this is highly subjective, some people just prefer a GUI that can guide you and/or be visually explored. This whole piece also reads like someone is quite angry at people preferring a different workflow than them. Some aspects, like shell history, are also not the magic bullet they propose here as it doesn't, e. G., cover the actual responses. Curl's ability to do almost everything is a minor curse here too as it means that any documentation (man pages, options help) is very large.
- catapart 1y agoJust fyi: the writing style is a meme. I think it's following the "just use html"[0] format (though, that may be its own riff on the meme). Not to detract from you point; just to say that the author is probably not as angry as this could make them seem. [0] https://justfuckingusehtml.com/ https://justfuckingusehtml.com/
- dlopes7 1y agoNot to mention saving headers, tokens, doing multiple requests using the results from the previous, etc. This guy would say "just use bash" and ignore the average user experience.
- andoando 1y agoYou can do all that in a shell script though
- 1y ago
- brap 1y agoAfter decades it should have been obvious by now that the vast majority of users prefer GUIs.
- Aperocky 1y agodefine "user" people needing/using curl would have been a very distinct subset of users.
- CaptainOfCoit 1y agoYeah, hence why no one uses terminals for doing work with git, codex, claude-code, neovim and curl, everyone and their mother are using desktop GUIs for those things, clearly.
- c-hendricks 1y agoInversely, plenty of people use GUIs for all of those things.
- CaptainOfCoit 1y agoYes, I agree, and have no qualms with people who prefer GUIs. But to say that "majority of users (developers?)" prefer GUIs seems outlandish at best.
- ____mr____ 1y agoI am the only person in my 10 person team that prefers the cli for stuff like git and while the ratio was a little more balanced during my time at college, it was still skewed towards GUIs. I don't think its unreasonable to think that developers might prefer GUIs over CLI
- maleldil 1y agoMany developers are on Windows, and those tend to prefer GUIs. CLI reliance is mostly a macOS/Linux thing.
- taylodl 1y agoCurl and jq are plenty to get the job done. As the author points out, you can capture all your curl commands in scripts and then orchestrate with other scripts for testing purposes. On top of all the benefits the author has already mentioned, you get a boost if you're doing your development work in a VM, as I do. It's less you have to install, configure, and manage. Sure, that can be automated, but it's just more stuff you have to take care of and the longer you have to wait for a fresh VM to be ready.
- runxiyu 1y agoUsing -X POST is often wrong as it "changes the actual method string in the HTTP request [... and] does not change behavior accordingly" (Stenberg, 2015). Although, it is correct for the article's mention of "Send POST requests"... just that typically people don't send POST requests out of the blue with no data.
- kaoD 1y agoI think you misinterpret the text you're quoting (but it's hard to tell since you didn't include a link). -X POST is not wrong, it's just superfluous when using other flags like -d where the method can be inferred. POST requests are often sent with no data (anything that is not idempotent should, unless there's another verb that could fit better).
- jmholla 1y agoHere's the article in question. [0] I think runxiyu is correct. The author delves a bit more into the issue. > One of most obvious problems is that if you also tell curl to follow HTTP redirects (using -L or --location), the -X option will also be used on the redirected-to requests which may not at all be what the server asks for and the user expected. Dropping the -X will make curl adhere to what the server asks for. And if you want to alter what method to use in a redirect, curl already have dedicated options for that named --post301, --post302 and --post303! Per the man page (`man 1 curl`), > The method string you set with -X, --request will be used for all requests, which if you for example use -L, --location may cause unintended side-effects when curl does not change request method according to the HTTP 30x response codes - and similar. `-d` and `--data` will appropriately change the headers of their requests. Funnily, `--post301` and `--post302` which have a similar effect as `-X POST` are RFC 7231 compliant, browsers just don't do that. [2][3] This is so ubiquitous that the error codes 307 and 308 were added to support the original behavior of repeating the request verbatim at the target address. Compare the following: > nc -l -p 8080 -q 1 <<< $'HTTP/1.1 301 Moved Permanently\nLocation: http://localhost:8081\n\n' & nc -l -p 8081 -q 1 <<< $'HTTP/1.1 200 OK\nContent-Length: 0\n\n' & curl -L --data test localhost:8080; wait > nc -l -p 8080 -q 1 <<< $'HTTP/1.1 301 Moved Permanently\nLocation: http://localhost:8081\n\n' & nc -l -p 8081 -q 1 <<< $'HTTP/1.1 200 OK\nContent-Length: 0\n\n' & curl -X POST -L --data test localhost:8080; wait > nc -l -p 8080 -q 1 <<< $'HTTP/1.1 308 Permanent Redirect\nLocation: http://localhost:8081\n\n' & nc -l -p 8081 -q 1 <<< $'HTTP/1.1 200 OK\nContent-Length: 0\n\n' & curl -L --data test localhost:8080; wait What happens here: 1. In the 301 case with just `--data`, the request turns into a GET request when sent to the redirect. 2. In the 301 case with `-X POST`, the request stays a `POST` request, but doesn't send any data to the redirect. 3. Finally, in the case where the server returns a 308, we see the POST request is kept and the data is resent. To further expand slightly on a different thing that might surprise some people, the data options will automatically set the content type by adding the header, `Content-Type: application/x-www-form-urlencoded`, as if sending form data from a browser. This behvaior can be overridden with a manual `-H`, `--header` argument (e.g., `-H 'Content-Type: application/json`). Edit: cube00 pointed out that newer versions of curl than mine have `--json` which will do that automatically. [4] [0]: https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-curl-x/ https://daniel.haxx.se/blog/2015/09/11/unnecessary-use-of-cu... [1]: https://www.rfc-editor.org/rfc/rfc7231 https://www.rfc-editor.org/rfc/rfc7231 [2]: https://evertpot.com/http/301-moved-permanently https://evertpot.com/http/301-moved-permanently [3]: https://evertpot.com/http/302-found https://evertpot.com/http/302-found [4]: https://news.ycombinator.com/item?id=45655409 https://news.ycombinator.com/item?id=45655409
- deleted 1y ago[deleted]
- hi41 1y agoI am a total newbie to curl. I am so excited to come across this post. Thanks, op! I want to use curl to send json and xml requests instead of using Postman and SoapUI while also using a jks file which stores a certificate for secure connection to API. (Clarified regarding certificate)
- eknkc 1y agoI use httpie (not httpie actually, https://github.com/ducaale/xh https://github.com/ducaale/xh but it has the exact same ux). For the life of me, I can't remember curl flags for some reason. Even fucking -X POST... Sending JSON is pain too. For quick and easy http requests, httpie has been fantastic.
- behnamoh 1y agoxh is mandatory Rust rewrite of httpie :)
- ocdtrekkie 1y agoHeh the home page is good too.
- mithcs 1y agohttpie (xh) gives way better UX for api testing and related tasks. https://github.com/httpie/cli https://github.com/httpie/cli https://github.com/ducaale/xh https://github.com/ducaale/xh
- cube00 1y agoIf you're able to use a curl release after March 2022, --json [1] is a great shortcut for REST API calls. [1]: https://curl.se/docs/manpage.html#--json https://curl.se/docs/manpage.html#--json
- KORraN 1y agoFor the record, since version 7.82.0.
- andrewrn 1y agoI might get lit on fire for this, but I don't find manpages very easy to use. If want to quickly remember an option or argument order, I am met with a wall of text. Does anyone have tips for how to make it more useful? Maybe I could grep better for options? For example in the link, the author lists out common curl commands like making a POST request or adding a header. If you tried to look through the manpage for this, this would take a long time. There's another utility called tldr that does a better job of this by providing common usage examples that almost always instantly give me what I need, but its not nearly as comprehensive as man.
- gbuk2013 1y agoAsk your AI tool of choice - it’s great at reading manpages. I also add my most favourite prompt instruction “be succinct”. :)
- mfiro 1y agoAdd this to the end of .bashrc function cheat() { curl cht.sh/$1 } Then in terminal you can use the following to see the examples: $ cheat curl
- andrewrn 1y agoHoly shit this website is insanely helpful. Many thanks!
- basscomm 1y ago> Does anyone have tips for how to make it more useful? Maybe I could grep better for options? For example in the link, the author lists out common curl commands like making a POST request or adding a header. If you tried to look through the manpage for this, this would take a long time. You can search a man page by pressing the '/' key, typing in what you want, and pressing 'enter'. 'n' jumps to the next instance of your search string 'N' jumps to the previous instance.
- andrewrn 1y agoOkay good point… I still think common usage examples would be nice because I don’t even know what some commands are capable of
- vimdiesel1 1y ago[dead]
- wraptile 1y agoCurl's UX is very dated and I wouldn't recommend it to any new user. Use many alternatives like httpie [1] or something like curlie [2] which is just an UX wrapper around the same libcurl. Httpie also has a postman-like web interface. 1 - https://httpie.io/ https://httpie.io/ 2 - https://rs.github.io/curlie/ https://rs.github.io/curlie/
- behnamoh 1y agocurl may be outdated but at least it's a survivor. the alternatives (esp. the suspicious httpie grift) won't make it.
- wraptile 1y agosure libcurl is great but curl CLI is pretty ancient and awful and completely unnecessary to use today as any front-end can plug into libcurl and provide a much better experience. If you're only requesting your own APIs then you don't even need libcurl and any http 1.1 client will provide much better experience like httpie. The issue with "survivor" software is that UX cannot be refined due to legacy support and that's what's great about curl itself is that libcurl and CLI front-end are separate tools allowing for alternative modern front-ends.
- xd1936 1y agoCan you define "the suspicious httpie grif"?
- wraptile 1y agoMy guess would be they don't like the fact that httpie is branching out to paid (well currently still 0$) GUI desktop/web apps. The CLI still remains under open source under BSD so I think OP is just yelling at clouds here.
- jonathanberger 1y agoDoes anyone have suggestions for when I need to use bearer auth and the token is super long? With curl I end up finding the command becomes hard to read, even taking advantage of backslashes. With Postman, it tidily hides the token out of the way on a separate tab and gets out of my way.
- humlex 1y agoWhat i do is assign the token to a variable. I typically copy the secret to my clipboard, and then use the pbpaste command in macos terminal when assigning it to avoid secrets in my command history.
- miningape 1y agothis. A while ago I was working on a DSL to solve this exact issue (env switching, http requests + chained requests e.g. to an auth server to retrieve a token) - but I haven't had the time recently, and I moved jobs to a GraphQL shop, so it feels a bit more pointless now :D
- KORraN 1y agoI love the second part of your tip, thank you.
- Izkata 1y agoI don't know how consistent this is across shells, but at least in bash putting a space before the command keeps it out of the history: $ ONE=1 $ TWO=2 $ echo $ONE $TWO 1 2 $ history | tail -n 4 2002 clear 2003 ONE=1 2004 echo $ONE $TWO 2005 history | tail -n 4
- johnisgood 1y agoYeah, I have been using this feature of bash ever since its existence and it is quite handy at times, especially when I do "printf "<sensitive data>" | qr".
- skydhash 1y ago
- zamadatix 1y agoCurl is great for running individual API calls, API clients are great for when you're actually working on the API or architecting an app with one. Not that there are things one can't do with API development from the CLI, but there is a lot more to API clients than that feature list (it doesn't even include anything around stuff one might want to do with openapi definitions!) and by the time you string it all together you get why people like the tool that did that for them instead.
- eddywebs 1y agoThis is a very funny, love it ! every developer needs to know basics like such, I hope this site continues.
- garciasn 1y agoThis person is my spirit animal. "You can remember 400 Kubernetes commands but not curl -x POST?" That was exactly what I needed this morning.
- cabirum 1y agoInstead of "-X POST" and "-H 'Content-Type: application/json'", use "-d" or "--json", asshat.
- eddieroger 1y agoIt's clear at this point that terminal apps have lost to GUIs, but cURL is the one place where I think that's a shame. cURL /always just works/. It is predictable, consistent, transparent, and pretty easy to use in its simple forms, but with plenty of room for complexity if you wish to go the far. There's a reason libcurl is in everything from automobile infotainment systems to toasters. I'm glad to use a GUI over libcurl that doesn't also need a cloud to work, but at the end of the day, I find myself piping cURL to jq more than almost anything else. Way back when Postman was but a mere Chrome plugin, I spent a lot longer than I'd have liked fighting with a request that should have been logging GET requests but wasn't. Imagine my surprise when I found that it was following Chrome's caching rules and not actually making my requests despite me intentionally firing off those requests. If only I had just used cURL...
- bdcravens 1y ago> Now everyone's downloading 500MB Electron monstrosities that take 3 minutes to boot up just to send a fucking GET request. While curl is fine, most of the time I use the REST Client extension in VS Code. While VS Code is an Electron monstrosity, assuming you already have it, that extension is less than 3MB. Even the full-feature GUI extensions like Thunder Client are scarcely bigger. Hate VS Code, and never let your hands touch anything other than vim or emacs? Fine, there's a number of extensions that run in the browser that do the same thing.
- internet_points 1y agoTIL about jo, why did I not know about that ten years ago $ jo details[author]=Dickens details[age]=dead books="$(jo -a 'Oliver Twist' 'Great Expectations')" {"details":{"author":"Dickens","age":"dead"},"books":["Oliver Twist","Great Expectations"]}
- deleted 1y ago[deleted]
- novoreorx 1y agoWhen I made the script httpstat [1] 9 years ago, I had this exact thought - if I want to show the statistics of a HTTP request, why not just use curl, why bother working out the figures myself? And since then, the more I use curl, the more I find it robust, sophesticated and irreplaciable. It's the only thing and everything I need. [1]: https://github.com/reorx/httpstat https://github.com/reorx/httpstat
- on_the_train 1y agoUnless you're on Windows, which comes with a special version of curl that misses some crucial functionality. I didn't think I've the successfully used curl in my life though. Every time there's confusion about parameters. It's always been was faster to just write a quick python script that uses requests. Plus the author can be a bit special. One of the most overrated pieces of software on the planet
- cosmotic 1y agoThe author could benefit from some research into user centered design. CLI is notorious for poor discoverability and consistency, two halmarks of GUI (at least 20 years ago; these days less focus is put on these elements). Humans are very not good at remembering command line flags but great at looking at then manipulating a screen that shows fields for all the flags.
- deleted 1y ago[deleted]
- cassianoleal 1y agoThat may be true for a tool that's not used often. For professional tooling, muscle memory and response time beat discoverability any day of the week. GUIs are (usually) slow and break the flow. They cater for the bottom of the pile of users, in detriment of the top.
- cosmotic 1y agoHow is muscle memory an exclusive benefit of CLI? How is response time superior for a CLI? I've used GUI tools for git professionally for years and it seems much faster, safer, and easier to use. I've had peers that use CLI instead and they appear to struggle for all the expected reasons (poor feedback, poor discoverability, etc).
- cassianoleal 1y agoGit is an interesting example. I have a few commands and one-liners that perform certain tasks. I can chain them together without looking at the screen. In fact, I can be reading code on the editor while I perform them on the terminal from muscle memory alone. I build a mental model of the branch I'm working on and how it relates to trunk and work from there. Each command updates that mental model. A GUI will never be as fast as that. Now, you're right - a GUI that can be fully navigated with the keyboard can get somewhat close. That is, until an update changes the place of a button, or the organisation of a menu. CLIs almost universally have stable contracts with the user. Don't get me wrong, I like GUIs for a lot of tasks: web browsing, CAD work, even programming. I just find that "everything should be a GUI" only serves to bring top performers down closer to the mean at best. Furthermore, a crappy CLI is really only crappy until muscle memory sets in. A crappy GUI generally remains a crappy experience for as long as it's used. Is muscle memory an exclusive benefit of CLI? No, but it's am universal benefit of the CLI, whereas it's only incidental on GUIs.
- insane_dreamer 1y agoI use httpie; like curl but with easier syntax.
- opengrass 1y agoBusiness idea: Firefox or Chromium fork replacing http(s), or beg Ladybird developers to make it standard.
- JeremyNT 1y agoI love curl and use it all the time (copying requests from the browser is maybe the most common usage) but: > Q: But Postman has testing and automation! > A: So does cURL in a shell script with || and && and actual programming languages. You want assertions? Pipe to grep or write a 3-line Python script. Done. IMO if you're reaching for an "actual programming language" it's probably time to put curl down and switch to libcurl or whatever native equivalent is in that language.
- theshrike79 1y agoThe Google style guide is a good reference: https://google.github.io/styleguide/shellguide.html#s1.2-when-to-use-shell https://google.github.io/styleguide/shellguide.html#s1.2-whe... - If you are writing a script that is more than 100 lines long, or that uses non-straightforward control flow logic, you should rewrite it in a more structured language now. Bear in mind that scripts grow. Rewrite your script early to avoid a more time-consuming rewrite at a later date. - When assessing the complexity of your code (e.g. to decide whether to switch languages) consider whether the code is easily maintainable by people other than its author.
- cassianoleal 1y agoCute, but a few years back $client was an early-ish adopter of Anthos Service Mesh (Google-managed(ish) Istio for GKE), and to install it we had to run a Bash script that was over 1,000 lines long. When we questioned the Google engineer assigned to support us, he snickered and said "you can trust it".
- cyberge99 1y agoIs curl ever going to have a mature /sane way to handle silent output? I seem to have to redirect 2>&1 and other -o- options. It’s annoying. Always has been.
- knifeinhead 1y agoI've decided, I'm writing all my wiki's in this style moving forward.