Skip to content

Commit

Permalink
update(docs): req run repeatedly & notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Rooyca committed May 21, 2024
1 parent 324b68c commit 264e26c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# APIR - API Request
# APIR - APIRequest


[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/rooyca/obsidian-api-request?logo=github&color=ee8449&style=flat-square)](https://github.com/rooyca/obsidian-api-request/releases/latest)
Expand All @@ -7,11 +7,7 @@

![req_img](req-codeblock.gif)

Obsidian plugin that allows you to make requests to API's and receive responses in code-blocks or store them in `localStorage`.

> [!IMPORTANT]
>
> JSON, TEXT, HTML and MARKDOWN responses supported
[Obsidian](https://obsidian.md/) plugin that allows you to make requests to APIs or any other URL and display the response in a code-block.

## Installation

Expand All @@ -31,7 +27,7 @@ There are two ways to use the plugin:

### With Code-blocks

To use it, create a code-block with the language set to `req`. Inside the code-block, you can specify `url`, `method`, `body`, `headers`, `format`, etc.
To use it, create a code-block with the language set to `req`. Inside the code-block, you can specify `url`, `method`, `body`, `headers`, `format`, etc. [Check docs](https://rooyca.github.io/obsidian-api-request/codeblocks/).

```req
url: https://api.chess.com/pub/player/hikaru/stats
Expand Down Expand Up @@ -109,14 +105,15 @@ To use the plugin, press `Ctrl+P` and search for `APIR`. There are two options:
1. Show response in modal
2. Paste response in current document (at current line)

[Check docs](https://rooyca.github.io/obsidian-api-request/settings/).

#### Settings

The plugin has a few settings that you can configure:

![req_settings](config_img.png)

- URL: The URL to send the request to.
- Format Output: Just JSON blocks (for now).
- Method: Choose between GET, POST, PUT & DELETE.
- Body: The data to send with the request. Data should by in JSON format.
- Headers: The header data to send with the request. Data should by in JSON format. (`{"Content-Type": "application/json", "Authorization": "Bearer TOKEN"}`)
Expand Down
41 changes: 38 additions & 3 deletions docs/docs/codeblocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Flags are the way to specify the parameters of our request and also the format i
| response-type | json |
| req-id | req-general |
| disabled | |
| req-repeat | 1t@1s |
| notify-if | |

### url

Expand All @@ -28,7 +30,7 @@ url: https://jsonplaceholder.typicode.com/users/{{this.id}}
```
~~~

!!! info "Where `{{this.id}}` is a variable (`id`) defined in the frontmatter."
!!! note "Where `{{this.id}}` is a variable (`id`) defined in the frontmatter."


### method
Expand Down Expand Up @@ -59,7 +61,7 @@ body: {"title": {{this.title}}, "body": "bar", "userId": 1}
```
~~~

!!! info "Where `{{this.title}}` is a variable (`title`) defined in the frontmatter."
!!! note "Where `{{this.title}}` is a variable (`title`) defined in the frontmatter."

### headers

Expand Down Expand Up @@ -133,7 +135,7 @@ format: <h1>{}</h1> <p>{}</p>
```
~~~

!!! info "In this example, first `{}` will be replaced by the title, and second `{}` will be replaced by the body."
!!! note "In this example, first `{}` will be replaced by the title, and second `{}` will be replaced by the body."


### res-type
Expand Down Expand Up @@ -209,6 +211,39 @@ disabled
```
~~~

### req-repeat

!!! warning "This only works with JSON responses"

Specifies the number of times the request should be repeated and the interval between each repetition. The default value is `1t@1s` (read as `X time(s) every X second(s)`). Letters `t` and `s` are not mandatory.


~~~markdown
```req
url: api.coincap.io/v2/rates/bitcoin
req-repeat: 5@5
```
~~~

### notify-if

!!! warning "This only works with JSON responses"

Specifies the condition to trigger a notification. Can be used to monitor a specific value. The path syntax used to access nested objects varies from the `show` flag, here dots are used instead of arrows and not spaces are allowed in the path.

~~~markdown
```req
url: api.coincap.io/v2/rates/bitcoin
req-repeat: 5@5
notify-if: data.rateUsd < 69889
```
~~~

!!! note "In the example above, a notification will be triggered everytime the value of `data.rateUsd` is less than `69889`."







Expand Down

0 comments on commit 264e26c

Please sign in to comment.