Skip to content

Commit

Permalink
update(feat): save response to file
Browse files Browse the repository at this point in the history
  • Loading branch information
Rooyca committed Jun 5, 2024
1 parent 4bd04e2 commit b1dd28c
Show file tree
Hide file tree
Showing 9 changed files with 2,403 additions and 10 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Obsidian plugin release](https://img.shields.io/badge/Obsidian%20plugin%20release-purple?logo=obsidian&style=flat-square)](https://obsidian.md/plugins?id=api-request)
[![Docs site](https://img.shields.io/badge/docs-GitHub_Pages-blue)](https://rooyca.github.io/obsidian-api-request/)

![req_img](req-codeblock.gif)
![req_img](showcase_1.gif)

[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.

Expand All @@ -23,10 +23,16 @@ The plugin can be installed from within Obsidian.

## Usage

[Read documentation](https://rooyca.github.io/obsidian-api-request/)

<details>
<summary>Quick Guide</summary>
There are two ways to use the plugin:

### With Code-blocks

![showcase](showcase_2.gif)

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
Expand Down Expand Up @@ -118,12 +124,17 @@ The plugin has a few settings that you can configure:
- 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"}`)
- Response: The response data to display. If empty all data will be display. You can use a right arrow `->` to access nested objects. For example, if you want to show the `title` from the `user` object, you can do that like this: `user -> title`.
</details>

## To-do

- [x] Add more request types (POST, PUT, DELETE)
- [x] Add support for authentication
- [x] Add customization for modal output
- [ ] Save response to a file
- [ ] Inline query from response
- [ ] Predefined requests
- [ ] GUI for code-blocks

## Feedback and Contributions

Expand Down
13 changes: 12 additions & 1 deletion docs/docs/codeblocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Flags are the way to specify the parameters of our request and also the format i
| disabled | |
| req-repeat | 1t@1s |
| notify-if | |
| save-to | |

### url

Expand Down Expand Up @@ -215,7 +216,7 @@ disabled

!!! 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.
Specifies the number of times the request should be repeated and the interval between each repetition. The default value is `1@1` (read as `X time(s) every X second(s)`).


~~~markdown
Expand All @@ -241,6 +242,16 @@ 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`."

### save-to

Specifies the path to save the response. It'll save the entire response. A file extension is required. It won't create directories.

~~~markdown
```req
url: https://jsonplaceholder.typicode.com/posts/1
save-to: posts/1.json
```
~~~



Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "api-request",
"name": "APIRequest",
"version": "1.2.6",
"version": "1.2.7",
"minAppVersion": "0.15.0",
"description": "Fetch data from APIs or other sources. Responses in JSON, MD or HTML directly in your notes.",
"author": "rooyca",
Expand Down
Loading

0 comments on commit b1dd28c

Please sign in to comment.