Napful is a command-line tool designed to help developers interact with HTTP APIs by running predefined requests.
- List Requests: Easily list all requests saved in the requests folder.
- Execute Requests: Run a specific request by name.
- Environment variable support: Define environment variables in a
.env
file or as actual environment variables to customize your API requests on the fly.
To get started, you can clone the repository and compile the project using Cargo:
git clone https://github.com/thiagokoster/napful
cd napful
cargo build --release
Requests are defined in .txt
files within the requests
folder.
The file format follows:
# Request name
HTTP_METHOD(GET or POST) URL
Header1: value
Header2: value
Body (if applicable)
Here is an example:
# Get posts
GET https://jsonplaceholder.typicode.com/posts
# Create post
POST https://jsonplaceholder.typicode.com/posts
Content-Type: application/json
Accept: application/json
{
"title": "foo",
"body": "bar"
}
To list all the requests from the requests
folder, use the following command:
napful list
To execute a request, use:
napful run "Get posts"
Napful will omit response headers by default. They can be enabled --headers
flag if necessary
napful run "Get posts" --headers
Define environment variables in a .env
file in your requests
folder. The .env
file should follow the format:
BASE_URL=https://api.example.com
API_KEY=your_api_key
You can also specify environment variables in your shell session, which will precede the .env
file.
Variables can be used in the request file like so:
# Get posts
GET {{BASE_URL}}/posts
Napful is released under the MIT License. See the LICENSE file for more details.