API Testing Tools
Learn what API testing tools are, why you need them before building an Axum backend, and how to use command-line and graphical clients like curl, HTTPie, Postman, and Insomnia to inspect HTTP requests and responses.
When you build a web API with Axum, your server will listen for HTTP requests and send back HTTP responses. Before you write any Rust code, you need a way to create those requests yourself and see exactly what comes back. That is the entire job of an API testing tool. It is a separate program that pretends to be a browser, a mobile app, or another server, and it sends a request to a URL that you choose. The tool then shows you the response body, the status code, and every header that arrived. You will use this constantly while developing an Axum backend, because you cannot point a normal browser at an API endpoint that returns raw JSON and expect it to show you everything cleanly.
This page covers the testing tools themselves. You already have several development helpers installed. Now you need something that can talk to an HTTP server once you build one with Axum. There is no Axum-specific testing tool. API testing tools are completely framework-agnostic, which means they work equally well with Axum, Actix Web, Node.js Express, Django, or any other HTTP server. That is an important idea to absorb early: these tools know nothing about Rust or Axum. They only know the HTTP protocol, which is the common language every web API speaks.
Why You Need a Dedicated Tool Instead of a Browser
A browser is actually an API client, but a very limited one for development work. When you type http://localhost:3000/health into a browser address bar, the browser sends an HTTP GET request to your server. It does that part correctly. The problem is what the browser does with the response. It will try to render the response body as a web page. If your Axum server returns a JSON string like {"status":"ok"}, the browser shows that text, but it does not show you the response headers clearly. It does not let you choose which HTTP method to send. A browser address bar always sends GET. If you need to test a POST request, a DELETE request, or a PATCH request, a browser alone cannot do it without opening developer tools. Even then, the experience is clunky.
API testing tools solve this by giving you total control over every part of the request: the method, the URL, the headers, the body, and the query parameters. They also display the response in a structured way, separating the status line, the headers, and the body so you can see each piece without squinting at a browser's network tab. A good mental model is that an API testing tool is like a stethoscope for your server. You place it on the server's HTTP endpoint, send a known signal, and watch what comes back. If something is wrong, the tool helps you see whether the problem is in the request you sent or the response the server produced.
The Four Tools Covered Here
There are four API testing tools worth knowing when you start with Axum. They split into two categories: command-line tools and graphical tools.
The command-line tools are curl and httpie. curl is already installed on almost every operating system. It is the baseline tool that every developer eventually learns, and it is perfect for quick checks from a terminal. httpie is a newer command-line tool that formats requests and responses in a more readable way, with colored output and a simpler syntax.
The graphical tools are Postman and Insomnia. These are desktop applications with windows, buttons, dropdown menus, and saved collections of requests. They are excellent when you want to organize many API endpoints, share them with a team, or test a sequence of requests that depend on each other. Postman is the most widely known, and Insomnia is a popular open-source alternative.
All four tools do the same core job. They differ in how you interact with them and how much setup they require. A beginner should learn one command-line tool first, because it forces you to understand the raw HTTP request without hiding anything behind a user interface. After that, a graphical tool becomes a productivity booster rather than a confusing layer of abstraction.
A Starter Example with curl
Before you write any Axum code, you can test curl against a public API that already exists on the internet. This proves the tool works on your machine and teaches you how to read its output. Open a terminal and run this exact command:
curl http://localhost:3000/health
If nothing is running on port 3000, you will see an error like Connection refused. That is expected and useful to see, because it teaches you what a failed connection looks like. Now run a request against a real public endpoint to see a successful response:
curl https://httpbin.org/json
The output will be a block of JSON. The httpbin.org service is a free testing API that returns predictable responses for all kinds of requests. The /json endpoint returns a simple JSON object. When you run this command, curl opens a network connection to the httpbin.org server, sends an HTTP GET request for the /json path, receives the response, and prints the response body to your terminal.
To see more than the body, add the -i flag, which stands for "include headers":
curl -i https://httpbin.org/json
The output now starts with several lines that look like HTTP/2 200 (or HTTP/1.1 200, depending on the connection), date: ..., content-type: application/json, and a few others. After a blank line, the JSON body appears. The first line is the status line. The number 200 means "OK", which is the standard HTTP success code. The lines after that are response headers, which are key-value pairs of metadata that describe the response. The body is the actual payload you care about. This separation between headers and body is the single most important thing to understand when testing APIs. Every API testing tool, no matter how fancy, is ultimately showing you these same pieces: status, headers, and body.
Your Tool Is Working:
If the curl https://httpbin.org/json command prints a JSON object and the -i version shows a 200 status line at the top, your API testing setup is working correctly. You can now send requests to any HTTP server, including the Axum server you will build later.
Testing Different HTTP Methods with curl
An API is not just a collection of URLs. Each URL can respond differently depending on the HTTP method used. The most common methods are:
- GET - retrieve data
- POST - create new data
- PUT - replace existing data completely
- PATCH - update part of existing data
- DELETE - remove data
The curl command uses GET by default. To send a different method, you use the -X flag followed by the method name in uppercase. Here is a POST request to the httpbin.org testing service:
curl -X POST https://httpbin.org/post
The response body will be a JSON object that echoes back information about your request. You will see a "method" field set to "POST", an empty "data" field, and a "headers" object. This is httpbin.org telling you exactly what it received from your request. It is an extremely useful debugging tool because it acts as a mirror.
Now try a DELETE request:
curl -X DELETE https://httpbin.org/delete
The response again shows a "method" field, this time set to "DELETE". You did not change the command much, but the server received a completely different method and would handle it differently in a real application. An Axum route for DELETE could remove a record from a database, while the GET route on the same path could list records. Testing both methods separately is how you verify that each route works.
Adding Request Headers and Query Parameters
Most real API requests include headers and query parameters. A query parameter is a key-value pair that appears after a ? in the URL. It is how you filter or paginate data on a GET request. Here is an example against httpbin.org:
curl "https://httpbin.org/get?name=alice&page=2"
The response echoes back an "args" object containing {"name": "alice", "page": "2"}. The quotes around the URL in the terminal are important. Without them, the & character might be interpreted by your shell as a background operator, and only https://httpbin.org/get?name=alice would be sent as the URL. Whenever your URL contains & or ?, wrap it in quotes. That is one of the most common beginner mistakes with curl.
A request header is a key-value pair sent separately from the URL. Headers carry metadata like authentication tokens, content types, and user agent strings. You add a header with the -H flag:
curl -H "X-Request-ID: 12345" https://httpbin.org/headers
The httpbin.org/headers endpoint returns a JSON object showing every header your request sent. You should see the X-Request-Id header you just added, alongside default headers that curl sends automatically, like User-Agent and Accept. This is why the endpoint is so valuable for learning. It reveals the invisible parts of an HTTP request.
You can add multiple headers by repeating the -H flag:
curl -H "Authorization: Bearer fake-token" -H "Content-Type: application/json" https://httpbin.org/headers
Every header appears in the echoed response. When you later build an Axum server that requires an Authorization header, you will use a command like this to test both the success path and the failure path when the header is missing.
Quoting URLs and Headers:
Always wrap URLs that contain ? or & in double quotes, and wrap header values that contain spaces or colons in double quotes as well. The shell will silently mangle unquoted strings, and your request will not go where you think it goes. This is the most common source of "curl is not working" confusion for beginners.
Sending JSON Bodies with curl
A POST request is only useful if it can carry data. The most common data format for Axum APIs is JSON. The body is the raw text sent after the headers, and for JSON it is usually a string like {"name":"Alice","email":"alice@example.com"}. You send it with the -d flag:
curl -X POST -H "Content-Type: application/json" -d '{"name":"Alice","email":"alice@example.com"}' https://httpbin.org/post
The response echoes back your JSON in the "data" field as a string, and it also shows the parsed JSON in the "json" field. This confirms that the server received both the raw body and understood it as JSON because you set the Content-Type header. If you omit the Content-Type header, the server may still receive the raw body, but it will not know that it is JSON, and an Axum extractor that expects JSON would reject it.
On Windows terminals, single quotes do not work the same way they do on Unix-like systems. In PowerShell, curl on its own is an alias for Invoke-WebRequest, not the real curl program, so call curl.exe explicitly and wrap the JSON in single quotes, which PowerShell passes through unchanged:
curl.exe -X POST -H "Content-Type: application/json" -d '{"name":"Alice","email":"alice@example.com"}' https://httpbin.org/post
In the older Command Prompt (powershell.exe), single quotes do not work either, so use double quotes around the JSON and escape the inner double quotes with a backslash:
curl -X POST -H "Content-Type: application/json" -d "{\"name\":\"Alice\",\"email\":\"alice@example.com\"}" https://httpbin.org/post
The escaping rules differ between terminals, which is one reason many developers move to a graphical tool for complex requests. But if you learn the command-line version, you will understand what the graphical tool is doing under the surface.
The Complete curl Command Walkthrough
At this point, you have seen pieces of a curl command. Now run a single command that combines several ideas at once. This is the kind of request you will send to an Axum server constantly:
curl -X POST "https://httpbin.org/post?source=terminal" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer abc123" \
-d '{"title":"Learn Axum","completed":false}'
The \ at the end of each line is a line continuation character for Unix-like shells. It tells the shell that the command continues on the next line. This is only for readability in your terminal; you can also write the entire command on one line. Here is what each part does:
-X POSTsets the HTTP method to POST.- The URL includes a query parameter
source=terminal, which would let the server know where the request came from. - The first
-Htells the server that the body is JSON, so it knows how to parse it. - The second
-Hsends an authorization token, which the server would validate. - The
-dflag sends the JSON body containing the actual data.
When you run this, httpbin.org echoes back every element: the method, the query parameters, the headers, and the body. For a beginner, this response is a complete education in what an HTTP request actually is. When you later build an Axum handler that extracts JSON, validates an authorization header, and reads query parameters, you will already know what the incoming request looks like from the client's perspective.
curl Is Already Installed:
On macOS, Linux, and Windows 10 and 11, curl ships with the operating system. There is no installation step. Open a terminal, type curl --version, and you will see version information. If for some reason it is missing, install it through your system's package manager.
How to Save Responses and Control Verbosity
Sometimes you want to save the response body to a file rather than printing it to the terminal. The -o flag lets you specify an output file:
curl -o response.json https://httpbin.org/json
After running this, the terminal shows a progress meter but not the JSON body. The body is now inside a file named response.json in your current directory. Open it with any text editor or with cat response.json to see the content.
If you want to see the HTTP status code alone, combine the -o flag to discard the body and the -w flag to write a custom format string:
curl -o /dev/null -w "%{http_code}\n" https://httpbin.org/json
The -o /dev/null part sends the body to a special file that discards it. The -w flag prints just the status code followed by a newline. You will see 200 on your screen. On Windows, /dev/null does not exist; use NUL instead:
curl -o NUL -w "%{http_code}\n" https://httpbin.org/json
This technique is useful when you are running a script that checks whether your Axum server is up. You do not need the full response body; you only need to know that the server responded with a successful status code. Testing an API endpoint is not only about reading JSON manually. It also means being able to automate the check.
HTTPie as a Friendlier Command-Line Alternative
curl is powerful, but its syntax is terse. httpie is a command-line tool designed to make the same requests with less punctuation. The command name is http. Instead of -X POST, you write http POST. Instead of -H "Content-Type: application/json", httpie automatically sets content type when you pass JSON data with := syntax. Here is a GET request:
http https://httpbin.org/json
The output is colorized and formatted. You see the status line, the headers, and the body clearly separated. Now a POST request with JSON:
http POST https://httpbin.org/post title="Learn Axum" completed:=false
Notice that there is no -X, no -H, and no -d. The word POST tells httpie which method to use. The key-value pairs at the end become the JSON body. Fields using = are sent as strings, while := sends the value as a non-string JSON type, in this case a boolean. httpie also automatically adds the Content-Type: application/json header. The response shows the same information curl would show, but formatted with syntax highlighting and a cleaner layout.
Adding a header is also simpler:
http POST https://httpbin.org/post Authorization:"Bearer abc123" title="Learn Axum"
The Authorization header is specified inline before the data fields. httpie sends the headers and the JSON body, and httpbin.org echoes everything back. If you want to see the response without colour, use the --pretty=none flag, or pipe the output to another program. (Do not confuse this with --raw, which sends a raw request body instead of structured JSON data.)
httpie is available as a separate installation. On macOS you can install it with Homebrew, on Linux with your package manager, and on Windows with a package manager like Chocolatey or Scoop. Because curl is always present, httpie is an optional comfort layer, not a requirement. But many developers prefer it for daily interactive use because the output is so much easier to scan.
When to Use curl vs HTTPie:
Use curl when you want maximum portability, when you are writing shell scripts, or when you are following a tutorial that uses curl because it is the universal baseline. Use httpie for interactive exploration, because the colored output and simpler syntax reduce mental overhead. Both send identical HTTP requests; only the typing experience differs.
GUI-Based Testing with Postman and Insomnia
Command-line tools are excellent for quick checks, but they have limits. When an API has twenty endpoints, each requiring a different combination of methods, headers, and bodies, typing commands repeatedly becomes tedious. You also lose the ability to save requests in a visual, organized way and share them with others. Graphical API clients solve this.
Postman and Insomnia are desktop applications. They present a window where you select the HTTP method from a dropdown, type the URL in a text box, add headers in a table, write the body in an editor, and click a Send button. The response appears in a separate panel, with tabs for the body, headers, cookies, and status information. Both applications let you save requests into named collections, which act like folders of related API calls. You can create a collection called "Health Checks" and put every request related to health endpoints inside it. You can create environment variables so that the base URL is defined once and reused across every request, meaning you can switch from a local server to a staging server by changing a single value.
The key difference between the two is their ecosystem and history. Postman has a larger user base, more tutorials, and a more mature collaborative platform. It also has features that go beyond simple testing, like automated test scripts and mock servers. Insomnia is open-source at its core, with a cleaner interface and fewer prompts to create an account. Both are fully capable of everything you need for Axum development. The choice is mostly personal preference.
There is a third option worth knowing about, though it is not covered deeply here: the REST Client extension for VS Code. If you already use VS Code, you might prefer to send API requests directly from your editor without opening another application. A .http file in VS Code can contain requests written in a simple plaintext format, and the extension sends them and shows the response in a split pane. This keeps your API testing adjacent to your Rust code, which some developers find convenient.
A GUI Cannot Replace Understanding HTTP:
A graphical client makes requests easier to compose, but it cannot tell you why a request fails if you do not understand what the request actually contains. If you skip learning curl and jump straight into a GUI, you will struggle to debug Axum extractor failures because you will not know whether the problem is your JSON body, your content type header, or your URL. Learn the command-line basics first, then use the GUI to make your workflow faster.
Installing and Starting with Postman or Insomnia
You should install at least one graphical client now so that it is ready when you start building Axum routes. Both tools offer downloads from their official websites. For Postman, visit the Postman downloads page and choose the installer for your operating system. For Insomnia, visit the Insomnia downloads page or check your package manager, since Insomnia is available through Homebrew on macOS and several Linux package managers.
After installation, launch the application. You may be prompted to create an account. Postman strongly encourages an account for its sync features, while Insomnia allows local usage without one in most versions. Once the main window opens, look for a button labeled "New Request" or a plus icon. Click it. A request editor appears. Set the method to GET, type https://httpbin.org/json in the URL field, and click Send. The response panel fills with the JSON body and the status code 200 OK. This is the graphical equivalent of the first curl command you ran earlier.
Now change the method to POST, set the URL to https://httpbin.org/post, and open the Body tab. Select the "raw" body type and choose JSON from the format dropdown. Type this into the body editor:
{
"title": "Learn Axum",
"completed": false
}
Add a header by opening the Headers tab. Add a row with the key Content-Type and the value application/json. Click Send. The response shows the echoed body, headers, and method. You have just done in a GUI what took a long curl command earlier. The advantage of the GUI is that you can save this request, duplicate it, and modify it later without retyping everything. The disadvantage is that you had to click through several tabs to see what a single command line showed at once.
A Successful GUI Test:
When you send the GET request to https://httpbin.org/json from Postman or Insomnia and see a status of 200 OK with a JSON body, your graphical API client is configured correctly. You can now use it for any future Axum endpoint without worrying that the tool itself is broken.
Organizing Requests into Collections
A collection is a named group of saved requests. In both Postman and Insomnia, collections appear in a sidebar on the left side of the window. You can create a collection called "Axum API" and inside it create folders for different resource groups, such as "Health", "Users", and "Tasks". Each folder holds the requests for that resource. For the Users folder, you might have four saved requests:
- GET all users
- GET a single user by ID
- POST create a user
- DELETE remove a user
When you save a request, you give it a name and it appears in the collection. Clicking the name restores the full request exactly as you saved it: the method, URL, headers, and body. This is the primary workflow benefit of a GUI client. You build up a complete, clickable map of your API. When you later add a new endpoint in Axum, you add a corresponding saved request in your collection, and you always have a manual test ready.
Environment variables add another layer of usefulness. You can define a variable called base_url with the value http://localhost:3000 for local development. In every saved request, set the URL to {{base_url}}/users instead of hardcoding the full address. When you deploy your server to a staging environment, change the base_url variable to the staging URL, and every request in your collection automatically targets the new server. This is much faster than editing twenty URLs by hand.
Testing an Axum Endpoint Before You Build It
This page deliberately focuses on testing tools without writing any Axum code. That is because the tooling must work first. But it helps to know what a typical Axum test will look like once you have a server running. Suppose you create an Axum server with a route GET /health that returns the string "ok". The server will listen on port 3000. To test it, you will run the Axum program in one terminal and then run this command in a second terminal:
curl http://localhost:3000/health
If everything works, the terminal prints ok. That is the entire test. If the server is not running, you see Connection refused. If the route path is wrong, you see a 404 Not Found status. If the handler panics, the connection is dropped without any HTTP response at all - curl reports Empty reply from server - and the panic message is printed in the server's terminal. (A 500 Internal Server Error only appears if you add CatchPanicLayer from tower-http, which converts panics into 500 responses; plain Axum does not do that.) The API testing tool itself never changes; it always sends the request you ask for and shows the result. The tool is a constant, and the server is the variable. That is why you set up and learn the tool before you start building the server.
When your Axum server grows, you will test POST routes with JSON bodies, routes that require authentication headers, and routes that accept path parameters like /users/42. Each of those tests will look exactly like the examples on this page, just pointed at localhost instead of httpbin.org. The skills transfer directly. A path parameter in the URL is just part of the string you type into the tool. A JSON body is just the text you put in the body editor. A required header is just a key-value pair you add in the headers section.
Port Conflicts and Localhost:
When you test a local Axum server, make sure no other program is using the same port. If you run an Axum server on port 3000 and something else is already using that port, the server fails to start. You will see an error like "Address already in use" in the Axum terminal. Change the port or stop the other program. The API testing tool cannot fix this; it only reports that the request failed or went to the wrong server.
A Stepper for Verifying Your API Testing Setup
Before moving on, confirm that every tool you plan to use is working correctly. This sequence assumes you have not yet built an Axum server, so it uses httpbin.org as the test target.
Step 1: Verify curl from the command line
Open a terminal and run curl https://httpbin.org/json. You should see a JSON object printed to the terminal. If you see Connection refused or a timeout, check your internet connection and firewall. curl itself is almost certainly working; it is the network path that is failing.
Step 2: Verify curl can send POST requests with JSON
Run curl -X POST -H "Content-Type: application/json" -d '{"test":true}' https://httpbin.org/post. The response should include a "json" field showing {"test": true}. This confirms that your shell quoting, JSON formatting, and method flags are all correct.
Step 3: Optionally install HTTPie and repeat the same request
If you want the friendlier command-line experience, install HTTPie using your package manager, then run http POST https://httpbin.org/post test:=true. The output should be colorized and show the same echoed JSON. If you do not want to install HTTPie, skip this step; curl is sufficient.
Step 4: Install a graphical client if you plan to use one
Download and install Postman or Insomnia from the official website. Launch the application, create a new request, set the method to GET, and enter https://httpbin.org/json in the URL field. Click Send. The response panel should show a 200 OK status and a JSON body.
Step 5: Save a request in a collection
In your graphical client, create a new collection called "Test Setup". Save the GET request to httpbin.org/json inside that collection. Confirm that clicking the saved request restores the method, URL, and response without re-entering anything. This proves the organization workflow is ready for your future Axum endpoints.
After completing these steps, you have a working API testing environment. Every tool is configured, every tool has been proven against a known-good public API, and you understand the basic request and response shapes. When you write your first Axum route, testing it will be the easiest part of the workflow.
Common Mistakes and How to Recover
Several errors come up repeatedly for developers new to API testing. The first is forgetting to set the Content-Type header when sending a JSON body with curl. The server receives the body but does not know how to interpret it. An Axum Json extractor will reject the request with a 400 Bad Request or an error about a missing content type. The fix is to add -H "Content-Type: application/json" to the command.
The second mistake is confusing URL path parameters with query parameters. In the URL http://localhost:3000/users/42, the 42 is a path parameter. It becomes part of the route definition in Axum, like /users/{id}. In the URL http://localhost:3000/users?page=2, the page=2 is a query parameter. Axum handles path and query parameters through different extractors. When you type the URL into a testing tool, make sure the number is in the right place.
The third mistake is running the command against the wrong URL because of an unquoted &. If you type curl http://localhost:3000/items?page=1&size=10 without quotes on a Unix shell, the shell interprets & as a command separator. It runs curl http://localhost:3000/items?page=1 in the background and then tries to run a command called size=10. The result is confusion and a failed request. Always quote URLs with query strings.
The fourth mistake involves the graphical clients: forgetting to save the request after modifying it. Many beginners change the method, body, or URL, run the request, and close the tab without saving. The next time they open the client, the changes are gone. Use the Save button frequently, or duplicate a request before experimenting so the original stays intact.
Never Put Real Secrets in Saved Requests:
When you save a request that includes an Authorization header or an API key, that secret is stored in the client's local files or in your account's cloud storage. During development you will often use fake or local tokens, which is fine. But never save production passwords, API keys, or user tokens in a request you might accidentally share or sync. Use environment variables with placeholder values instead.
When to Test Your Axum API During Development
The API testing tool is not something you use only at the end. You use it from the very first route you create. After writing a handler, you start the server and immediately send a request from your testing tool. This loop is fast: write a few lines of Rust, run the server, send a request, read the response, and adjust. The testing tool is the feedback mechanism. Without it, you are writing code blindly and hoping the route works. With it, you get instant confirmation that the handler received the right inputs and produced the right output.
You will also use the testing tool to test failure cases. A well-built API does not only handle valid input. It must also reject invalid input with meaningful error responses. You will intentionally send a POST request with missing required fields, a GET request to a nonexistent ID, and a request without a required header. The tool lets you construct these invalid requests precisely and observe how your error handling behaves. This is impossible to do with a browser alone, and it is exactly why a dedicated API testing tool is part of the standard development toolkit.
Summary and What Comes Next
The core insight from this page is that an API testing tool is a neutral observer. It sends exactly the HTTP request you specify and shows exactly what comes back. It does not care whether your server is written in Rust with Axum, in Python with FastAPI, or in any other language. That neutrality is what makes it valuable. When a request fails, the failure is either in the request you constructed or in the server you wrote, and the tool gives you the raw evidence to tell which one it is.
Between the four tools covered here, you have two command-line paths and two graphical paths. curl is the universal baseline that teaches you the raw protocol. httpie is the friendlier terminal alternative for interactive work. Postman and Insomnia add saved collections, environment variables, and a visual editor for complex workflows. A beginner should start with curl, become comfortable reading status lines and headers, and then adopt whichever graphical client fits their preference. The tooling is now ready. The next step in your journey is to create an actual Axum project and write a route, at which point every command on this page becomes a live test against your own code instead of a public test service.