From 264e26c13802a030d1fb35407b378efee9d12cd7 Mon Sep 17 00:00:00 2001 From: rooyca Date: Tue, 21 May 2024 15:16:38 -0500 Subject: [PATCH] update(docs): req run repeatedly & notifications --- README.md | 13 +++++-------- docs/docs/codeblocks.md | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 8f7983f..71b5a7a 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -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 @@ -109,6 +105,8 @@ 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: @@ -116,7 +114,6 @@ 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"}`) diff --git a/docs/docs/codeblocks.md b/docs/docs/codeblocks.md index 87430fe..3e24e44 100644 --- a/docs/docs/codeblocks.md +++ b/docs/docs/codeblocks.md @@ -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 @@ -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 @@ -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 @@ -133,7 +135,7 @@ format:

{}

{}

``` ~~~ -!!! 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 @@ -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`." + + + +