No description
Find a file
2024-05-07 13:00:52 -05:00
.github Create FUNDING.yml 2024-04-26 12:21:13 -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 Initial commit 2023-05-02 20:57:48 -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 Initial commit 2023-05-02 20:57:48 -05:00
frontmatterUtils.ts update: parsing MD in codeblock (#17 & #16) 2024-05-07 13:00:52 -05:00
LICENSE v0.0.1 2023-05-02 21:55:17 -05:00
main.ts update: parsing MD in codeblock (#17 & #16) 2024-05-07 13:00:52 -05:00
manifest.json update: parsing MD in codeblock (#17 & #16) 2024-05-07 13:00:52 -05:00
marked.min.js update: parsing MD in codeblock (#17 & #16) 2024-05-07 13:00:52 -05:00
package.json update: parsing MD in codeblock (#17 & #16) 2024-05-07 13:00:52 -05:00
README.md update: first approach to loop over response (#14) 2024-05-04 18:24:43 -05:00
styles.css update: parsing MD in codeblock (#17 & #16) 2024-05-07 13:00:52 -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 - Api Request

Obsidian plugin that allows you to make requests to APIs and receive responses in the format of a JSON block or an Obsidian variable.

Important

We now support JSON, TEXT and MARKDOWN responses

GitHub release (latest SemVer) Obsidian plugin release

conf_img

Installation

The plugin can be installed from within Obsidian or manually.

  • 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 Markdown Block (Easier)

To use the plugin, create a code block with the language set to req. Inside the code block, you can specify things like the URL, request method, request data, headers, and the response data you want to display.

Key Description Default
disabled Disables the request
url The URL to send the request to (You can use variables defined in the frontmatter)
method Request method (GET, POST, PUT, DELETE) GET
body Data to send with the request. Data should by in JSON format (You can use variables defined in the frontmatter)
headers Header(s) for the request. Data should by in JSON format (You can use variables defined in the frontmatter)
show Response data to display. You can use a right arrow -> to access nested objects ALL
format Format in which the response should be displayed <li>{}</li>
response-type The type of response we are getting (json, txt or md) json

The plugin will automatically replace the code block with the response from the API. Here are a quick examples:

If you want to show data from nested objects, you can do that by using a right arrow ->. For example, if you want to show the last from the chess_daily object, you can do that like this:

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

It's also posible to show multiple outputs by separating them with a comma:

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>

You can show the entire response by only specifying the url:

url: https://jsonplaceholder.typicode.com/todos/1

Or you can loop over an array. The following example will give you the city from all users:

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

You can use the frontmatter variables in the URL, for instance, if you have a variable numb defined in the frontmatter, you can use it like this:

url: https://jsonplaceholder.typicode.com/todos/{{this.numb}}

You can specify the response type you are getting:

url: https://raw.githubusercontent.com/Rooyca/Rooyca/main/README.md
response-type: md

You can also specify the request method, request data, headers, and the response format:

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

In the example above, the response will be displayed in a h1 tag.

With Configuration

To use the plugin, press Ctrl+P and search for "APIR". The plugin will present you with two options:

  1. Show response in modal
  2. Paste response in current document (at current line)

Select the option that suits your needs. Additionally, you can configure the plugin to output the response in either JSON block format or as an Obsidian variable. This option can be accessed through the plugin's settings.

Settings

The plugin has a few settings that you can configure:

  • 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"})
  • 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 customizability for modal output (e.g. show only specific fields, change color scheme, add custom CSS)
  • Add customizability for variable output (e.g. show only specific fields, change variable name)

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!