mirror of
https://github.com/rooyca/obsidian-api-request.git
synced 2026-07-22 07:50:27 +00:00
2106 lines
No EOL
50 KiB
HTML
2106 lines
No EOL
50 KiB
HTML
|
|
<!doctype html>
|
|
<html lang="en" class="no-js">
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
|
|
|
|
|
|
|
<link rel="prev" href="../">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="icon" href="../../assets/images/favicon.png">
|
|
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.7.6">
|
|
|
|
|
|
|
|
<title>代码块 - APIRequest</title>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../assets/stylesheets/main.484c7ddc.min.css">
|
|
|
|
|
|
<link rel="stylesheet" href="../../assets/stylesheets/palette.ab4e12ef.min.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
|
|
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
|
|
|
|
|
|
|
|
<script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
|
|
|
|
|
|
|
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="indigo">
|
|
|
|
|
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
|
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
|
<label class="md-overlay" for="__drawer"></label>
|
|
<div data-md-component="skip">
|
|
|
|
|
|
<a href="#_1" class="md-skip">
|
|
Skip to content
|
|
</a>
|
|
|
|
</div>
|
|
<div data-md-component="announce">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<header class="md-header md-header--shadow" data-md-component="header">
|
|
<nav class="md-header__inner md-grid" aria-label="Header">
|
|
<a href="../.." title="APIRequest" class="md-header__button md-logo" aria-label="APIRequest" data-md-component="logo">
|
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>
|
|
|
|
</a>
|
|
<label class="md-header__button md-icon" for="__drawer">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
|
|
</label>
|
|
<div class="md-header__title" data-md-component="header-title">
|
|
<div class="md-header__ellipsis">
|
|
<div class="md-header__topic">
|
|
<span class="md-ellipsis">
|
|
APIRequest
|
|
</span>
|
|
</div>
|
|
<div class="md-header__topic" data-md-component="header-topic">
|
|
<span class="md-ellipsis">
|
|
|
|
代码块
|
|
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<form class="md-header__option" data-md-component="palette">
|
|
|
|
|
|
|
|
|
|
<input class="md-option" data-md-color-media="" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="indigo" aria-label="Switch to dark mode" type="radio" name="__palette" id="__palette_0">
|
|
|
|
<label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_1" hidden>
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
|
|
</label>
|
|
|
|
|
|
|
|
|
|
|
|
<input class="md-option" data-md-color-media="" data-md-color-scheme="slate" data-md-color-primary="indigo" data-md-color-accent="indigo" aria-label="Switch to light mode" type="radio" name="__palette" id="__palette_1">
|
|
|
|
<label class="md-header__button md-icon" title="Switch to light mode" for="__palette_0" hidden>
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
|
|
</label>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
|
|
|
|
|
|
|
|
|
|
|
|
<label class="md-header__button md-icon" for="__search">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
|
|
</label>
|
|
<div class="md-search" data-md-component="search" role="dialog">
|
|
<label class="md-search__overlay" for="__search"></label>
|
|
<div class="md-search__inner" role="search">
|
|
<form class="md-search__form" name="search">
|
|
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
|
|
<label class="md-search__icon md-icon" for="__search">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
|
|
</label>
|
|
<nav class="md-search__options" aria-label="Search">
|
|
|
|
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
|
|
</button>
|
|
</nav>
|
|
|
|
</form>
|
|
<div class="md-search__output">
|
|
<div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
|
|
<div class="md-search-result" data-md-component="search-result">
|
|
<div class="md-search-result__meta">
|
|
Initializing search
|
|
</div>
|
|
<ol class="md-search-result__list" role="presentation"></ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="md-header__source">
|
|
<a href="https://github.com/Rooyca/obsidian-api-request/" title="Go to repository" class="md-source" data-md-component="source">
|
|
<div class="md-source__icon md-icon">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M439.6 236.1 244 40.5c-5.4-5.5-12.8-8.5-20.4-8.5s-15 3-20.4 8.4L162.5 81l51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.3 199v121.9c25.3 12.5 22.3 41.8 9.1 55-6.4 6.4-15.2 10.1-24.3 10.1s-17.8-3.6-24.3-10.1c-17.6-17.6-11.1-46.9 11.2-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1C3 240.6 0 247.9 0 255.5s3 15 8.5 20.4l195.6 195.7c5.4 5.4 12.7 8.4 20.4 8.4s15-3 20.4-8.4l194.7-194.7c5.4-5.4 8.4-12.8 8.4-20.4s-3-15-8.4-20.4"/></svg>
|
|
</div>
|
|
<div class="md-source__repository">
|
|
GitHub
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</header>
|
|
|
|
<div class="md-container" data-md-component="container">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<main class="md-main" data-md-component="main">
|
|
<div class="md-main__inner md-grid">
|
|
|
|
|
|
|
|
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
|
|
<div class="md-sidebar__scrollwrap">
|
|
<div class="md-sidebar__inner">
|
|
|
|
|
|
|
|
|
|
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
|
|
<label class="md-nav__title" for="__drawer">
|
|
<a href="../.." title="APIRequest" class="md-nav__button md-logo" aria-label="APIRequest" data-md-component="logo">
|
|
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>
|
|
|
|
</a>
|
|
APIRequest
|
|
</label>
|
|
|
|
<div class="md-nav__source">
|
|
<a href="https://github.com/Rooyca/obsidian-api-request/" title="Go to repository" class="md-source" data-md-component="source">
|
|
<div class="md-source__icon md-icon">
|
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M439.6 236.1 244 40.5c-5.4-5.5-12.8-8.5-20.4-8.5s-15 3-20.4 8.4L162.5 81l51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.3 199v121.9c25.3 12.5 22.3 41.8 9.1 55-6.4 6.4-15.2 10.1-24.3 10.1s-17.8-3.6-24.3-10.1c-17.6-17.6-11.1-46.9 11.2-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1C3 240.6 0 247.9 0 255.5s3 15 8.5 20.4l195.6 195.7c5.4 5.4 12.7 8.4 20.4 8.4s15-3 20.4-8.4l194.7-194.7c5.4-5.4 8.4-12.8 8.4-20.4s-3-15-8.4-20.4"/></svg>
|
|
</div>
|
|
<div class="md-source__repository">
|
|
GitHub
|
|
</div>
|
|
</a>
|
|
</div>
|
|
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_1" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_1" id="__nav_1_label" tabindex="0">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
English
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_1_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_1">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
|
|
|
|
English
|
|
|
|
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../../en/codeblocks/" class="md-nav__link">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
Usage
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../../en/usecase" class="md-nav__link">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
Use Cases
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_2" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_2" id="__nav_2_label" tabindex="0">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
Español
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_2">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
|
|
|
|
Español
|
|
|
|
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../../es/" class="md-nav__link">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
Inicio
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_2_2" >
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_2_2" id="__nav_2_2_label" tabindex="0">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
Uso
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_2_2_label" aria-expanded="false">
|
|
<label class="md-nav__title" for="__nav_2_2">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
|
|
|
|
Uso
|
|
|
|
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../../es/codeblocks/" class="md-nav__link">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
Cómo usar
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../../es/usecase" class="md-nav__link">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
Casos de uso
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3" checked>
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="0">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
中文
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="true">
|
|
<label class="md-nav__title" for="__nav_3">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
|
|
|
|
中文
|
|
|
|
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../" class="md-nav__link">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
概述
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
|
|
|
|
|
|
|
|
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3_2" checked>
|
|
|
|
|
|
<label class="md-nav__link" for="__nav_3_2" id="__nav_3_2_label" tabindex="0">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
用法
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_3_2_label" aria-expanded="true">
|
|
<label class="md-nav__title" for="__nav_3_2">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
|
|
|
|
用法
|
|
|
|
|
|
</label>
|
|
<ul class="md-nav__list" data-md-scrollfix>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item md-nav__item--active">
|
|
|
|
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
|
|
|
|
|
|
|
|
|
|
|
|
<label class="md-nav__link md-nav__link--active" for="__toc">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
代码块
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<span class="md-nav__icon md-icon"></span>
|
|
</label>
|
|
|
|
<a href="./" class="md-nav__link md-nav__link--active">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
代码块
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<label class="md-nav__title" for="__toc">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Table of contents
|
|
</label>
|
|
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_2" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
🏳️ 标志
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_3" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
🔒 安全注意事项
|
|
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="🔒 安全注意事项">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_4" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
输入验证
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_5" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
📖 变量与数据复用
|
|
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="📖 变量与数据复用">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_6" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
本地存储与变量
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_7" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
前置元数据变量
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_8" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
全局变量
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_9" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
特殊变量
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_10" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
标志详情
|
|
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="标志详情">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#url" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
url
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#method" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
method
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#body" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
body
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#headers" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
headers
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#show" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
show
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#req-uuid" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
req-uuid
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#hidden" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
hidden
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#disabled" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
disabled
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#save-as" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
save-as
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#auto-update" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
auto-update
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#format" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
format
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#properties" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
properties
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_11" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
💡 常见模式
|
|
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="💡 常见模式">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_12" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
身份验证流程
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_13" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
错误处理
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_14" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
性能提示
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_15" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
📚 扩展阅读
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_16" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
❓ 故障排除
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="md-nav__item">
|
|
<a href="../usecase" class="md-nav__link">
|
|
|
|
|
|
|
|
<span class="md-ellipsis">
|
|
|
|
|
|
用例
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
|
|
<div class="md-sidebar__scrollwrap">
|
|
<div class="md-sidebar__inner">
|
|
|
|
|
|
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<label class="md-nav__title" for="__toc">
|
|
<span class="md-nav__icon md-icon"></span>
|
|
Table of contents
|
|
</label>
|
|
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_2" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
🏳️ 标志
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_3" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
🔒 安全注意事项
|
|
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="🔒 安全注意事项">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_4" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
输入验证
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_5" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
📖 变量与数据复用
|
|
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="📖 变量与数据复用">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_6" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
本地存储与变量
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_7" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
前置元数据变量
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_8" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
全局变量
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_9" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
特殊变量
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_10" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
标志详情
|
|
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="标志详情">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#url" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
url
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#method" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
method
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#body" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
body
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#headers" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
headers
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#show" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
show
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#req-uuid" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
req-uuid
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#hidden" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
hidden
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#disabled" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
disabled
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#save-as" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
save-as
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#auto-update" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
auto-update
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#format" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
format
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#properties" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
properties
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_11" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
💡 常见模式
|
|
|
|
</span>
|
|
</a>
|
|
|
|
<nav class="md-nav" aria-label="💡 常见模式">
|
|
<ul class="md-nav__list">
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_12" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
身份验证流程
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_13" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
错误处理
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_14" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
性能提示
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
</nav>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_15" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
📚 扩展阅读
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="md-nav__item">
|
|
<a href="#_16" class="md-nav__link">
|
|
<span class="md-ellipsis">
|
|
|
|
❓ 故障排除
|
|
|
|
</span>
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="md-content" data-md-component="content">
|
|
|
|
<article class="md-content__inner md-typeset">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h1 id="_1">👨🏻💻 代码块</h1>
|
|
<p><code>codeblock</code> 是一个多功能代码块,可用于直接从你的笔记中发送 API 请求。本指南涵盖所有可用的标志以及如何有效且安全地使用它们。</p>
|
|
<h2 id="_2">🏳️ 标志</h2>
|
|
<p>标志是指定请求参数的方式。所有标志都<strong>不区分大小写</strong>。</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>标志</th>
|
|
<th>默认值</th>
|
|
<th>必需</th>
|
|
<th>描述</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td><a href="#url">url</a></td>
|
|
<td></td>
|
|
<td>✅ 是</td>
|
|
<td>要请求的 API 端点</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#method">method</a></td>
|
|
<td>GET</td>
|
|
<td>否</td>
|
|
<td>HTTP 方法 (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS)</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#body">body</a></td>
|
|
<td></td>
|
|
<td>否</td>
|
|
<td>请求体 (JSON 格式)</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#headers">headers</a></td>
|
|
<td></td>
|
|
<td>否</td>
|
|
<td>请求头 (JSON 格式)</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#show">show</a></td>
|
|
<td>ALL</td>
|
|
<td>否</td>
|
|
<td>用于提取特定数据的 JSONPath</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#req-uuid">req-uuid</a></td>
|
|
<td>req-general</td>
|
|
<td>否</td>
|
|
<td>用于缓存的唯一 ID</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#hidden">hidden</a></td>
|
|
<td>FALSE</td>
|
|
<td>否</td>
|
|
<td>隐藏输出</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#disabled">disabled</a></td>
|
|
<td></td>
|
|
<td>否</td>
|
|
<td>禁用请求</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#save-as">save-as</a></td>
|
|
<td></td>
|
|
<td>否</td>
|
|
<td>将响应保存到文件</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#auto-update">auto-update</a></td>
|
|
<td>FALSE</td>
|
|
<td>否</td>
|
|
<td>总是获取新数据</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#format">format</a></td>
|
|
<td></td>
|
|
<td>否</td>
|
|
<td>自定义输出格式</td>
|
|
</tr>
|
|
<tr>
|
|
<td><a href="#properties">properties</a></td>
|
|
<td></td>
|
|
<td>否</td>
|
|
<td>更新前置元数据属性</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<hr />
|
|
<h2 id="_3">🔒 安全注意事项</h2>
|
|
<div class="admonition danger">
|
|
<p class="admonition-title">重要安全指南</p>
|
|
<ul>
|
|
<li><strong>始终使用 HTTPS</strong>: 使用 <code>https://</code> URL 以确保加密通信</li>
|
|
<li><strong>保护 API 密钥</strong>: 将敏感令牌存储在全局变量中,永远不要在笔记中硬编码</li>
|
|
<li><strong>验证输入</strong>: 插件会验证所有输入,但只连接到受信任的 API</li>
|
|
<li><strong>检查缓存数据</strong>: 定期从设置中清除旧的缓存响应</li>
|
|
</ul>
|
|
</div>
|
|
<h3 id="_4">输入验证</h3>
|
|
<p>所有用户输入都会自动验证:</p>
|
|
<ul>
|
|
<li><strong>URL</strong>: 只允许 <code>http://</code> 和 <code>https://</code> 协议</li>
|
|
<li><strong>UUID</strong>: 仅清理为字母数字、连字符和下划线</li>
|
|
<li><strong>文件路径</strong>: 阻止目录遍历 (<code>..</code>) 和绝对路径</li>
|
|
<li><strong>JSONPath</strong>: 验证表达式以防止脚本注入</li>
|
|
<li><strong>格式字符串</strong>: 清理 HTML 以防止 XSS 攻击</li>
|
|
</ul>
|
|
<hr />
|
|
<h2 id="_5">📖 变量与数据复用</h2>
|
|
<h3 id="_6">本地存储与变量</h3>
|
|
<p>API 响应可以存储在 <code>localStorage</code> 中,并在其他代码块或笔记中重用。要存储响应,必须使用 <code>req-uuid</code> 标志为其分配唯一标识符。</p>
|
|
<p>你可以使用以下语法访问存储的响应:</p>
|
|
<pre><code>{{ls.UUID>JSONPath}}
|
|
</code></pre>
|
|
<ul>
|
|
<li><code>UUID</code>: 在 <code>req-uuid</code> 标志中定义的唯一标识符(不含 <code>req-</code> 前缀)</li>
|
|
<li><code>JSONPath</code>: 你想要从响应中获取的特定数据的路径</li>
|
|
</ul>
|
|
<p><strong>示例:</strong>
|
|
如果你有一个带有 <code>req-uuid: user</code> 的请求,你可以这样访问用户的名字:</p>
|
|
<pre><code>{{ls.user>$.name}}
|
|
</code></pre>
|
|
<div class="admonition info">
|
|
<p class="admonition-title">安全说明</p>
|
|
<p>UUID 会自动清理。只允许字母数字字符、连字符和下划线。</p>
|
|
</div>
|
|
<hr />
|
|
<h3 id="_7">前置元数据变量</h3>
|
|
<p>你可以使用以下语法引用笔记<strong>前置元数据</strong>中定义的变量:</p>
|
|
<pre><code>{{this.variableName}}
|
|
</code></pre>
|
|
<p><strong>示例:</strong></p>
|
|
<p>前置元数据:</p>
|
|
<pre><code class="language-yaml">---
|
|
userId: 12345
|
|
title: "我的笔记"
|
|
---
|
|
</code></pre>
|
|
<p>在请求中使用:</p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.example.com/user/{{this.userId}}
|
|
```
|
|
</code></pre>
|
|
<div class="admonition warning">
|
|
<p class="admonition-title">安全警告</p>
|
|
<p>避免在前置元数据中存储敏感的 API 密钥。请改用全局变量。</p>
|
|
</div>
|
|
<hr />
|
|
<h3 id="_8">全局变量</h3>
|
|
<p>在插件设置中定义可重用的变量(设置 → APIRequest → 全局变量)。这些变量会被安全存储,可以通过以下方式访问:</p>
|
|
<pre><code>{{VARIABLE_NAME}}
|
|
</code></pre>
|
|
<p><strong>示例:</strong></p>
|
|
<ol>
|
|
<li>在插件设置中添加:</li>
|
|
<li>键: <code>API_KEY</code></li>
|
|
<li>
|
|
<p>值: <code>your-secret-key</code></p>
|
|
</li>
|
|
<li>
|
|
<p>在你的请求中:</p>
|
|
</li>
|
|
</ol>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.example.com/data
|
|
headers: {"Authorization": "Bearer {{API_KEY}}"}
|
|
```
|
|
</code></pre>
|
|
<div class="admonition tip">
|
|
<p class="admonition-title">最佳实践</p>
|
|
<p>将所有 API 密钥和令牌存储为全局变量,以保持笔记的安全性和可移植性。</p>
|
|
</div>
|
|
<hr />
|
|
<h3 id="_9">特殊变量</h3>
|
|
<ul>
|
|
<li><code>{{this.file.name}}</code> - 当前文件的基本名称(不含扩展名)</li>
|
|
</ul>
|
|
<hr />
|
|
<h2 id="_10">标志详情</h2>
|
|
<h3 id="url">url</h3>
|
|
<p>唯一<strong>必需</strong>的标志。它指定 API 请求的端点。</p>
|
|
<p><strong>语法:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.example.com/endpoint
|
|
```
|
|
</code></pre>
|
|
<p><strong>使用变量:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
# 这只是一个注释
|
|
url: https://jsonplaceholder.typicode.com/users/{{this.id}}
|
|
```
|
|
</code></pre>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">其中 <code>{{this.id}}</code> 是在前置元数据中定义的变量 (<code>id</code>)。</p>
|
|
</div>
|
|
<div class="admonition danger">
|
|
<p class="admonition-title">安全性</p>
|
|
<p>只允许 HTTPS 和 HTTP URL。出于安全考虑,其他协议(file://、javascript: 等)会被阻止。</p>
|
|
</div>
|
|
<hr />
|
|
<h3 id="method">method</h3>
|
|
<p>指定 HTTP 请求方法。默认值为 <code>GET</code>。</p>
|
|
<p><strong>可用方法:</strong>
|
|
- GET (默认)
|
|
- POST
|
|
- PUT
|
|
- DELETE
|
|
- PATCH
|
|
- HEAD
|
|
- OPTIONS</p>
|
|
<p><strong>示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/posts
|
|
method: post
|
|
```
|
|
</code></pre>
|
|
<hr />
|
|
<h3 id="body">body</h3>
|
|
<p>指定请求体。数据应为 JSON 格式。</p>
|
|
<p><strong>示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/posts
|
|
method: post
|
|
body: {"title": "{{this.filename}}", "body": "bar", "userId": 1}
|
|
```
|
|
</code></pre>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">其中 <code>{{this.filename}}</code> 是工作文件的名称。</p>
|
|
</div>
|
|
<p><strong>使用变量的高级用法:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.example.com/create
|
|
method: post
|
|
body: {"userId": {{this.userId}}, "token": "{{API_TOKEN}}"}
|
|
```
|
|
</code></pre>
|
|
<hr />
|
|
<h3 id="headers">headers</h3>
|
|
<p>指定请求头。数据应为 JSON 格式。</p>
|
|
<p><strong>示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/posts
|
|
method: post
|
|
headers: {"Content-type": "application/json; charset=UTF-8"}
|
|
```
|
|
</code></pre>
|
|
<p><strong>使用缓存响应作为请求头:</strong></p>
|
|
<p>你可以使用其他请求的响应作为 headers/body/url/show。例如,如果你有一个带有 <code>req-uuid: token</code> 的请求,你可以这样使用:</p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.todoist.com/rest/v2/tasks
|
|
headers: {"Authorization": "Bearer {{ls.token>$.access_token}}"}
|
|
show: $..content
|
|
format: - [ ] {}
|
|
req-uuid: todos
|
|
```
|
|
</code></pre>
|
|
<div class="admonition tip">
|
|
<p class="admonition-title">常用请求头</p>
|
|
<ul>
|
|
<li><code>Content-Type: application/json</code> - 用于 JSON 数据</li>
|
|
<li><code>Authorization: Bearer TOKEN</code> - 用于 API 认证</li>
|
|
<li><code>Accept: application/json</code> - 请求 JSON 响应</li>
|
|
</ul>
|
|
</div>
|
|
<hr />
|
|
<h3 id="show">show</h3>
|
|
<p>使用 JSONPath 表达式指定要显示响应中的哪些数据。查看 <a href="https://github.com/JSONPath-Plus/JSONPath?tab=readme-ov-file#syntax-through-examples">JSONPath 示例</a>,或尝试 <a href="https://jsonpath-plus.github.io/JSONPath/demo/">jsonpath-plus</a> 在线工具。</p>
|
|
<p><strong>简单示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.chess.com/pub/player/hikaru/stats
|
|
show: $['chess_daily']['last']['rating']
|
|
```
|
|
</code></pre>
|
|
<p><strong>使用方括号的多个输出:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.chess.com/pub/player/hikaru/stats
|
|
show: $.chess_daily[last,best].rating
|
|
```
|
|
</code></pre>
|
|
<p><strong>使用 + 的多个输出:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.chess.com/pub/player/hikaru/stats
|
|
show: $.chess_daily[last,best].rating + $.chess960_daily[last,best].rating
|
|
```
|
|
</code></pre>
|
|
<p><strong>循环遍历数组:</strong></p>
|
|
<p>获取所有用户的城市:</p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/users
|
|
show: $..address.city
|
|
```
|
|
</code></pre>
|
|
<p><strong>循环遍历前 N 个元素:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/users
|
|
show: $..[:3].address.city
|
|
```
|
|
</code></pre>
|
|
<p><strong>特定数组索引:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/users
|
|
show: $..[3,2,6].address.city
|
|
```
|
|
</code></pre>
|
|
<p><strong>最后一个元素:</strong></p>
|
|
<p>你可以使用 <code>(@.length-1)</code> 或只使用 <code>[-1:]</code> 访问最后一个元素:</p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.modrinth.com/v2/project/distanthorizons
|
|
show: $.game_versions[(@.length-1)]
|
|
```
|
|
</code></pre>
|
|
<p><strong>多个属性:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=rooyca&api_key={{API_KEY}}&format=json&limit=4
|
|
show: $..recenttracks.track[0:][streamable,name,artist]
|
|
```
|
|
</code></pre>
|
|
<div class="admonition info">
|
|
<p class="admonition-title">安全说明</p>
|
|
<p>JSONPath 表达式会被验证以防止脚本注入。恶意表达式将被阻止。</p>
|
|
</div>
|
|
<hr />
|
|
<h3 id="req-uuid">req-uuid</h3>
|
|
<p>指定用于在 <code>localStorage</code> 中缓存请求响应的唯一标识符。</p>
|
|
<p><strong>示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/users/1
|
|
show: $.name
|
|
req-uuid: test-{{this.username}}
|
|
```
|
|
</code></pre>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">其中 <code>{{this.username}}</code> 是在前置元数据中定义的变量 (<code>username</code>)。</p>
|
|
</div>
|
|
<p><strong>访问缓存响应:</strong></p>
|
|
<p>可以使用 <code>req-uuid</code> 访问存储的响应(这不会触发新请求):</p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/users/1
|
|
req-uuid: name
|
|
```
|
|
</code></pre>
|
|
<p><strong>与 Dataview 一起使用:</strong></p>
|
|
<p>也可以使用 <a href="https://blacksmithgu.github.io/obsidian-dataview/">dataview</a> 访问响应:</p>
|
|
<pre><code class="language-markdown">```dataviewjs
|
|
dv.paragraph(localStorage.getItem("req-UUID"))
|
|
```
|
|
</code></pre>
|
|
<div class="admonition info">
|
|
<p class="admonition-title">通过 localStorage 访问时始终使用 <code>req-</code> 前缀</p>
|
|
<p>通过 localStorage 直接访问时,使用: <code>localStorage.getItem("req-UUID")</code></p>
|
|
</div>
|
|
<p><strong>删除缓存响应:</strong></p>
|
|
<p>从代码中:</p>
|
|
<pre><code class="language-markdown">```dataviewjs
|
|
localStorage.removeItem("req-name")
|
|
```
|
|
</code></pre>
|
|
<p>从设置中:
|
|
转到 设置 → APIRequest → 已保存的 API 请求,然后点击你想删除的响应。</p>
|
|
<div class="admonition tip">
|
|
<p class="admonition-title">缓存管理</p>
|
|
<p>定期检查并清除旧的缓存响应以释放 localStorage 空间。</p>
|
|
</div>
|
|
<hr />
|
|
<h3 id="hidden">hidden</h3>
|
|
<p>执行代码块但不显示其输出。适用于缓存数据的后台请求。</p>
|
|
<p><strong>示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/users/1
|
|
req-uuid: name
|
|
hidden
|
|
```
|
|
</code></pre>
|
|
<div class="admonition tip">
|
|
<p class="admonition-title">用例</p>
|
|
<p>非常适合获取身份验证令牌或其他你想缓存但不显示的数据。</p>
|
|
</div>
|
|
<hr />
|
|
<h3 id="disabled">disabled</h3>
|
|
<p>禁用请求。代码块不会被执行。适用于临时禁用请求而不删除它们。</p>
|
|
<p><strong>示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/users/1
|
|
show: $.name
|
|
req-uuid: name
|
|
disabled
|
|
```
|
|
</code></pre>
|
|
<div class="admonition tip">
|
|
<p class="admonition-title">开发提示</p>
|
|
<p>在开发期间使用 <code>disabled</code> 以防止达到 API 速率限制。</p>
|
|
</div>
|
|
<hr />
|
|
<h3 id="save-as">save-as</h3>
|
|
<p>将整个响应保存到文件。需要文件扩展名。</p>
|
|
<p><strong>示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/posts/1
|
|
save-as: posts/1.json
|
|
```
|
|
</code></pre>
|
|
<div class="admonition warning">
|
|
<p class="admonition-title">重要</p>
|
|
<ul>
|
|
<li>文件路径会进行安全验证</li>
|
|
<li>阻止目录遍历 (<code>..</code>)</li>
|
|
<li>不允许绝对路径</li>
|
|
<li>文件路径相对于你的仓库根目录</li>
|
|
<li>不会自动创建目录</li>
|
|
</ul>
|
|
</div>
|
|
<div class="admonition tip">
|
|
<p class="admonition-title">文件管理</p>
|
|
<p>在使用 <code>save-as</code> 之前,在你的仓库中创建目标目录。</p>
|
|
</div>
|
|
<hr />
|
|
<h3 id="auto-update">auto-update</h3>
|
|
<p>强制代码块每次都获取新数据,忽略缓存响应。</p>
|
|
<p><strong>示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/posts/1
|
|
req-uuid: firstPost
|
|
auto-update
|
|
save-as: posts/1.json
|
|
```
|
|
</code></pre>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">何时使用</p>
|
|
<p>当你需要实时数据或缓存响应过时时使用 <code>auto-update</code>。</p>
|
|
</div>
|
|
<p><strong>不使用 <code>req-uuid</code>:</strong> 请求默认总是获取新数据。<br />
|
|
<strong>使用 <code>req-uuid</code>:</strong> 不使用 <code>auto-update</code> 时,会使用缓存响应。<br />
|
|
<strong>使用 <code>auto-update</code>:</strong> 忽略缓存并总是获取新数据。</p>
|
|
<hr />
|
|
<h3 id="format">format</h3>
|
|
<p>指定显示响应的自定义格式。支持 HTML 并使用 <code>{}</code> 作为占位符。</p>
|
|
<p><strong>示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/posts/1
|
|
show: $.[title,body]
|
|
format: <h1>{}</h1> <p>{}</p>
|
|
```
|
|
</code></pre>
|
|
<div class="admonition note">
|
|
<p class="admonition-title">在此示例中,第一个 <code>{}</code> 将被替换为 <em>title</em>,第二个 <code>{}</code> 将被替换为 <em>body</em>。</p>
|
|
</div>
|
|
<p><strong>高级格式化:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.example.com/user/1
|
|
show: $.[name,email,age]
|
|
format: **Name:** {} | **Email:** {} | **Age:** {}
|
|
```
|
|
</code></pre>
|
|
<p><strong>列表格式化:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.todoist.com/rest/v2/tasks
|
|
headers: {"Authorization": "Bearer {{TODOIST_TOKEN}}"}
|
|
show: $..content
|
|
format: - [ ] {}
|
|
```
|
|
</code></pre>
|
|
<div class="admonition danger">
|
|
<p class="admonition-title">安全警告</p>
|
|
<p>格式字符串会被清理以防止 XSS 攻击。脚本标签、事件处理程序和 javascript: URI 会被自动删除。</p>
|
|
</div>
|
|
<hr />
|
|
<h3 id="properties">properties</h3>
|
|
<p>使用响应数据更新前置元数据属性。需要 JSON 响应和 <code>show</code> 标志。</p>
|
|
<p><strong>语法:</strong>
|
|
数据应为用逗号分隔的属性名称。</p>
|
|
<p><strong>示例:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://jsonplaceholder.typicode.com/posts/1
|
|
show: $.[id,title]
|
|
properties: id, title
|
|
```
|
|
</code></pre>
|
|
<p><strong>对于内部链接,使用 <code>[[..]]</code> 语法:</strong></p>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.example.com/related
|
|
show: $.[id,name]
|
|
properties: relatedId, [[relatedNote]]
|
|
```
|
|
</code></pre>
|
|
<p>这将创建:</p>
|
|
<pre><code class="language-yaml">---
|
|
relatedId: 123
|
|
relatedNote: "[[Note Name]]"
|
|
---
|
|
</code></pre>
|
|
<div class="admonition tip">
|
|
<p class="admonition-title">用例</p>
|
|
<p>非常适合从 API 响应中自动填充元数据。</p>
|
|
</div>
|
|
<hr />
|
|
<h2 id="_11">💡 常见模式</h2>
|
|
<h3 id="_12">身份验证流程</h3>
|
|
<ol>
|
|
<li>获取身份验证令牌(隐藏):</li>
|
|
</ol>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.example.com/auth/login
|
|
method: post
|
|
body: {"username": "{{this.username}}", "password": "{{this.password}}"}
|
|
req-uuid: auth
|
|
hidden
|
|
```
|
|
</code></pre>
|
|
<ol>
|
|
<li>在后续请求中使用令牌:</li>
|
|
</ol>
|
|
<pre><code class="language-markdown">```req
|
|
url: https://api.example.com/user/data
|
|
headers: {"Authorization": "Bearer {{ls.auth>$.token}}"}
|
|
```
|
|
</code></pre>
|
|
<h3 id="_13">错误处理</h3>
|
|
<p>如果请求失败,将显示错误消息:</p>
|
|
<pre><code>Error: Failed to fetch
|
|
</code></pre>
|
|
<p>常见错误:
|
|
- <strong>网络错误</strong>: 检查你的互联网连接
|
|
- <strong>401 未授权</strong>: 检查你的 API 密钥/令牌
|
|
- <strong>404 未找到</strong>: 验证 URL 是否正确
|
|
- <strong>无效 JSONPath</strong>: 检查你的 <code>show:</code> 表达式</p>
|
|
<h3 id="_14">性能提示</h3>
|
|
<ol>
|
|
<li><strong>缓存响应</strong> - 对于不经常更改的数据使用 <code>req-uuid</code></li>
|
|
<li><strong>使用 <code>disabled</code></strong> - 在开发期间临时禁用昂贵的请求</li>
|
|
<li><strong>使用 <code>hidden</code></strong> - 隐藏后台数据获取的输出</li>
|
|
</ol>
|
|
<hr />
|
|
<h2 id="_15">📚 扩展阅读</h2>
|
|
<ul>
|
|
<li><a href="https://github.com/JSONPath-Plus/JSONPath?tab=readme-ov-file#syntax-through-examples">JSONPath 语法示例</a></li>
|
|
<li><a href="https://jsonpath-plus.github.io/JSONPath/demo/">JSONPath 在线测试工具</a></li>
|
|
<li><a href="../usecase/">用例</a> - 真实世界示例</li>
|
|
</ul>
|
|
<hr />
|
|
<h2 id="_16">❓ 故障排除</h2>
|
|
<p><strong>请求不工作?</strong></p>
|
|
<ul>
|
|
<li>检查控制台 (Ctrl+Shift+I) 查看详细错误消息</li>
|
|
<li>验证你的 URL 是否正确并使用 https://</li>
|
|
<li>检查是否存在所有必需的标志</li>
|
|
<li>确保你的 JSONPath 表达式有效</li>
|
|
</ul>
|
|
<p><strong>缓存数据未更新?</strong></p>
|
|
<ul>
|
|
<li>删除 <code>req-uuid</code> 以始终获取新数据</li>
|
|
<li>或添加 <code>auto-update</code> 标志以强制刷新</li>
|
|
<li>或在设置中手动清除缓存</li>
|
|
</ul>
|
|
<p><strong>变量未解析?</strong></p>
|
|
<ul>
|
|
<li>检查前置元数据语法是否正确</li>
|
|
<li>验证全局变量是否在设置中定义</li>
|
|
<li>确保你使用正确的变量语法</li>
|
|
</ul>
|
|
<hr />
|
|
<div class="admonition tip">
|
|
<p class="admonition-title">需要帮助?</p>
|
|
<p>如果你遇到问题或有疑问,请在 <a href="https://github.com/Rooyca/obsidian-api-request/issues">GitHub</a> 上提出问题。</p>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</article>
|
|
</div>
|
|
|
|
|
|
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
|
|
</div>
|
|
|
|
</main>
|
|
|
|
<footer class="md-footer">
|
|
|
|
<div class="md-footer-meta md-typeset">
|
|
<div class="md-footer-meta__inner md-grid">
|
|
<div class="md-copyright">
|
|
|
|
|
|
Made with
|
|
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
|
|
Material for MkDocs
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
|
|
</div>
|
|
<div class="md-dialog" data-md-component="dialog">
|
|
<div class="md-dialog__inner md-typeset"></div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script id="__config" type="application/json">{"annotate": null, "base": "../..", "features": ["content.code.copy"], "search": "../../assets/javascripts/workers/search.2c215733.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script>
|
|
|
|
|
|
<script src="../../assets/javascripts/bundle.79ae519e.min.js"></script>
|
|
|
|
|
|
</body>
|
|
</html> |