<commit_before># Raiden
[![Build Status](https://api.travis-ci.org/peterjcaulfield/raiden.svg)](http://travis-ci.org/peterjcaulfield/raiden)

`raiden` is CLI for interacting with web API's. With some simple configs, `raiden` will allow you to
execute http requests without the overhead of jumping into a browser or fiddling with `curl`.  

## Why

`raiden` can drastically speed up your workflow with features like:

- Tabbed autocompletion makes any interaction with `raiden` convenient and fast. 
- Dynamic request payloads from static configs. No more manual changing of the request payload between requests.
- Cookie Jar out of the box. Cookies are persisted and used in subsequent requests.
- Requests are very easy to define. `raiden` does the heavy lifting.

---
## Table of contents
- [Installation](#installation)
- [Getting started](#getting-started)
- [Custom Headers](#custom-headers)
- [Forms](#forms)
- [Json](#json)
- [TLS/SSL Protocol](#tlsssl-protocol)
- [Dynamic Request Payloads](#dynamic-request-payloads)


## Installation

`npm install -g raiden`

To enable tab-completion for bash, add the following to your `.bashrc` script:

`which raiden > /dev/null && . "$( raiden initpath )"`

---

## Getting started

First create a hidden `.raiden` folder in your home directory. You then need to create two config files, one for 
the API hostnames and one for the individual API request definitions.

Hostnames are stored `~/.raiden/envs.yml` as key/value. You can also define a `default` host to be used for when 
no host is provided to `raiden`. An example config looks like so:

```
# ~/.raiden/envs.yml

default: 127.0.0.1:8888
dev_api: dev_api.localhost.com:8888

```

API request definitions are stored in `~/.raiden/requests.yml`. An simple example config with one request defined looks like so:

```
# ~/.raiden/requests.yml

get_posts:
    endpoint: posts

```

Using the above two example configs, we could then execute an API request with:
```
raiden request -e dev_api get_posts
```

This would issue a `GET` request to `http://dev_api.localhost.com/posts`

`raiden` supports most of [node request library](https://github.com/request/request/blob/master/README.md) API which
it is built on top of by way of request-promise.

---

## Custom headers

```
# ~/.raiden/requests.yml

get_posts:
    endpoint: posts
    method: GET
    headers: 
        User-Agent: raiden
    qs:             
        rpp: 10
        page: 2<commit_msg>add docs for multiple request configs<commit_after># Raiden
[![Build Status](https://api.travis-ci.org/peterjcaulfield/raiden.svg)](http://travis-ci.org/peterjcaulfield/raiden)

`raiden` is CLI for interacting with web API's. With some simple configs, `raiden` will allow you to
execute http requests without the overhead of jumping into a browser or fiddling with `curl`.  

## Why

`raiden` can drastically speed up your workflow with features like:

- Tabbed autocompletion makes any interaction with `raiden` convenient and fast. 
- Dynamic request payloads from static configs. No more manual changing of the request payload between requests.
- Cookie Jar out of the box. Cookies are persisted and used in subsequent requests.
- Requests are very easy to define. `raiden` does the heavy lifting.

---

## Table of contents
- [Installation](#installation)
- [Getting started](#getting-started)
- [Multiple request configs](#multiple-request-configs)
- [Custom Headers](#custom-headers)
- [Forms](#forms)
- [Json](#json)
- [TLS/SSL Protocol](#tlsssl-protocol)
- [Dynamic Request Payloads](#dynamic-request-payloads)

---

## Installation

`npm install -g raiden`

To enable tab-completion for bash, add the following to your `.bashrc` script:

`which raiden > /dev/null && . "$( raiden initpath )"`

---

## Getting started

First create a hidden `.raiden` folder in your home directory. You then need to create two config files, one for 
the API hostnames and one for the individual API request definitions.

Hostnames are stored `~/.raiden/envs.yml` as key/value. You can also define a `default` host to be used for when 
no host is provided to `raiden`. An example config looks like so:

```
# ~/.raiden/envs.yml

default: 127.0.0.1:8888
dev_api: dev_api.localhost.com:8888

```

API request definitions are stored in `~/.raiden/requests.yml`. An simple example config with one request defined looks like so:

```
# ~/.raiden/requests.yml

get_posts:
    endpoint: posts

```

Using the above two example configs, we could then execute an API request with:
```
raiden request -e dev_api get_posts
```

This would issue a `GET` request to `http://dev_api.localhost.com/posts`

`raiden` supports most of [node request library](https://github.com/request/request/blob/master/README.md) API which
it is built on top of by way of request-promise.

---

---
## Multiple request configs

`raiden` supports multiple request definition config files. If you are working with multiple API's and you wish to segregate the request definitions 
at the API level to different files, simply create additional .yml config files in the `~/.raiden` directory. You can then tell `raiden` which config file
to use for request definitions using the `raiden config` command with the `--set` option:

```
raiden config --set reqfile acme_api_requests.yml
```

`raiden` will then use `~/.raiden/acme_api_requests.yml` for the request definitions.

---

## Custom headers

```
# ~/.raiden/requests.yml

get_posts:
    endpoint: posts
    method: GET
    headers: 
        User-Agent: raiden
    qs:             
        rpp: 10
        page: 2
{'fraction_non_alphanumeric': 0.10589500089589679, 'fraction_numerical': 0.006092098190288478, 'mean_word_length': 3.8120689655172413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1576515', 'n_tokens_mistral': 1749, 'n_tokens_neox': 1641, 'n_words': 659}