No description
Find a file
2024-05-21 15:16:38 -05:00
.github update(style): copy button and list rendering 2024-05-09 22:18:12 -05:00
docs update(docs): req run repeatedly & notifications 2024-05-21 15:16:38 -05:00
src update(feat): req run repeatedly & notifications 2024-05-21 14:40:51 -05:00
.editorconfig Initial commit 2023-05-02 20:57:48 -05:00
.eslintignore Initial commit 2023-05-02 20:57:48 -05:00
.eslintrc Initial commit 2023-05-02 20:57:48 -05:00
.gitignore update(ref): improving readability(1) 2024-05-20 03:11:07 -05:00
.npmrc Initial commit 2023-05-02 20:57:48 -05:00
apir.gif update: fix empty name and add gif to readme 2023-08-21 23:09:58 -05:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2024-04-26 12:31:24 -05:00
config_img.png New features (added methods & custom output) 2023-05-24 00:08:28 -05:00
esbuild.config.mjs update(style): copy button and list rendering 2024-05-09 22:18:12 -05:00
LICENSE v0.0.1 2023-05-02 21:55:17 -05:00
manifest.json update(feat): req run repeatedly & notifications 2024-05-21 14:40:51 -05:00
package.json update(feat): req run repeatedly & notifications 2024-05-21 14:40:51 -05:00
README.md update(docs): req run repeatedly & notifications 2024-05-21 15:16:38 -05:00
req-codeblock.gif refactor: move tode to src folder 2024-05-09 10:46:52 -05:00
styles.css update(ref): improving readability(1) 2024-05-20 03:11:07 -05:00
tsconfig.json Initial commit 2023-05-02 20:57:48 -05:00
version-bump.mjs Initial commit 2023-05-02 20:57:48 -05:00
versions.json Initial commit 2023-05-02 20:57:48 -05:00

APIR - APIRequest

GitHub release (latest SemVer) Obsidian plugin release Docs site

req_img

Obsidian plugin that allows you to make requests to APIs or any other URL and display the response in a code-block.

Installation

The plugin can be installed from within Obsidian.

Obsidian Community Plugin Browser

  • Go to Settings -> Community plugins
  • Make sure Restricted mode is off
  • Click Browse
  • Search for APIRequest
  • Click Install and then Enable

Usage

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. Check docs.

url: https://api.chess.com/pub/player/hikaru/stats
show: chess_daily -> last -> rating

Multiple outputs can be displayed:

url: https://api.chess.com/pub/player/hikaru/stats
show: chess_daily -> last -> rating, chess_daily -> best -> rating
format: <p>Last game: {}</p> <strong>Best game: {}</strong>

It's possible to loop over an array.

url: https://jsonplaceholder.typicode.com/users
show: {..} -> address -> city

Here is a more complex example:

url: https://my-json-server.typicode.com/typicode/demo/comments
format: <h1>{}</h1>
method: post
body: {"id":1}
headers: {"Accept": "application/json"}
show: id

Responses can be stored in localStorage with the req-id flag.

url: https://jsonplaceholder.typicode.com/users/1
show: id
req-id: id-persona

How to get responses from localStorage

For this you'll need dataview.

dv.paragraph(localStorage.getItem("req-id-persona"))

Is mandatory to use req- before whatever you defined in req-id flag.

You could also used inline:

$=localStorage.getItem("req-id-persona")

But this is a little buggy and don't work all the time. (Use this for short and unformatted responses)

How to remove responses from localStorage

In order to remove a response from the localStorage you can use the following code:

localStorage.removeItem("req-id-persona")

For removing all responses use:

localStorage.clear()

Or just go to the plugin settings and click the button Clear ID's to remove all responses.

With Configuration

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.

Settings

The plugin has a few settings that you can configure:

req_settings

  • URL: The URL to send the request to.
  • 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"})
  • 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.

To-do

  • Add more request types (POST, PUT, DELETE)
  • Add support for authentication
  • Add customization for modal output

Feedback and Contributions

If you encounter any issues or have feedback on the plugin, feel free to open an issue on the GitHub repository. Contributions are also welcome!