https://github.com/itsjimi/req
Send requests from Rofi and CLI
https://github.com/itsjimi/req
cli go golang http http-client request requests rofi rofi-req rofi-scripts
Last synced: 10 months ago
JSON representation
Send requests from Rofi and CLI
- Host: GitHub
- URL: https://github.com/itsjimi/req
- Owner: ItsJimi
- License: mit
- Created: 2020-03-11T19:26:31.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-30T13:41:15.000Z (about 1 year ago)
- Last Synced: 2025-03-29T12:30:35.318Z (10 months ago)
- Topics: cli, go, golang, http, http-client, request, requests, rofi, rofi-req, rofi-scripts
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# req
A simple cli to send http requests.
## Navigate
- [Why](#why)
- [Demo](#demo)
- [Installl](#install)
- [Usage](#usage)
- [Config file](#config-file)
- [List](#list)
- [Run](#run)
- [Reference](#reference)
- [Config file](#config-file-1)
- [Commands](#commands)
- [help](#help)
- [version](#version)
- [list](#list-1)
- [run](#run-1)
- [Rofi](#rofi)
- [Contribute](#contribute)
- [License](#license)
## Why
I created req mainly to use it with [Rofi](https://github.com/davatorium/rofi). At home, I can control domotics directly from Rofi.
> Check the [Rofi](#Rofi) section below.
## Demo
[](https://asciinema.org/a/rpqbwVyj1f4KE2IapyG3r0QCW)
## Install
Use precompiled versions in [releases page](https://github.com/ItsJimi/req/releases)
or
```shell
go install github.com/ItsJimi/req@latest
```
## Usage
First of all, you need to create a `.req.json` in your home directory.
#### Config file
This is the most common `.req.json`.
```json
[
{
"name": "Get first post",
"url": "https://jsonplaceholder.typicode.com/posts/1",
"method": "GET"
}
]
```
#### List
You can list all of available requests by running.
```shell
req list
```
In our case we have one element displayed.
```
Get first post
```
#### Run
You can run one or multiple requests by using run command.
```shell
req run "Get first post"
```
The result is displayed on terminal.
```json
{
"userId": 1,
"id": 1,
"title": "...",
"body": "..."
}
```
## Reference
### Config file
By default, [.req.json](https://github.com/ItsJimi/req/blob/master/.req.json) must be in your home directory.
```json
[
{
"name": "Get first post",
"url": "https://jsonplaceholder.typicode.com/posts/1",
"method": "GET",
"output": "echo \"Title: {{.title}}\nBody: {{.body}}\""
},
{
"name": "Create post",
"url": "https://jsonplaceholder.typicode.com/posts",
"method": "POST",
"headers": [
"Content-type: application/json; charset=UTF-8"
],
"body": {
"title": "foo",
"body": "bar",
"userId": 1
}
}
]
```
> `output` exec commands with bash and use go template to replace variables.
### Commands
- All commands can use `--help` or `-h` to display its specific help.
- All commands can use `--config` or `-c` to use a custom `.json` path. (By default req use a `.req.json` in your home directory)
#### help
Display helper
```shell
req help
```
#### version
Display version req using SemVer.
```shell
req version
```
#### list
Display list of `.req.json` requests names (each separated by `\n`).
```shell
req list
```
### run
Send one or multiple requests and display results.
> Note: You can use --silent or -s to display nothing.
```shell
req run [other request name] [...]
```
### Rofi
Req can be used in rofi with the [rofi-req.sh](https://github.com/ItsJimi/req/blob/master/rofi-req.sh) script.

## Contribute
Feel free to fork and make pull requests.
## License
[MIT](https://github.com/ItsJimi/req/blob/master/LICENSE)