Hacker News new | ask | show | jobs
by eat_veggies 2449 days ago
When reverse engineering or automating an API my workflow will often look like this:

1. Open browser inspector, watch API requests for one I'm interested in

2. Right click, "Copy as cURL"

3. Paste into a text editor, remove some unnecessary headers, re-running the curl command to verify that the headers I removed aren't important

4. Convert into python requests so that I can play with the parameters

2 comments

100% this. I do a lot of small automations against various API's (or sometimes against systems that don't API's at all) and have used this same workflow many times.

Also handy because even well documented API's don't have examples in every language, but most do have examples in curl. So you can easily take those example curl's and dump them out to something programatic in your language.

Right, and Firefox and Chrome both have "Copy as HAR". That should save a step, right?

Plus, you probably have a text editor that knows about JSON, so it's easy to (say) remove keys from a JSON file, or even just keep the keys on separate lines and add/remove entire lines. I haven't seen a text editor (even Emacs!) that was as good at editing shell command parameters. It's a lot easier to quote special characters for JSON, too, compared to quoting special characters for my shell.