Files
enstrayedapi/website/posts/20240409-API-Documentation.html
Enstrayed 1cab7e9869 bruh
2025-07-16 16:20:35 -07:00

153 lines
6.8 KiB
HTML

<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/newposts.css">
<meta property="og:site_name" content="enstrayed.com">
<meta property="og:url" content="https://enstrayed.com/posts/20240409-API-Documentation.html">
<title>Enstrayed: API Documentation</title>
<meta property="og:title" content="Enstrayed: API Documentation">
<meta name="description" content="List of all endpoints and associated information for my web API">
<meta property="og:description" content="List of all endpoints and associated information for my web API">
</head>
<body>
<a href="/">Return to enstrayed.com</a>
<h1>API Documentation</h1>
<p>This page was last updated 2025-07-08.</p>
<p>Source Code & Issue Tracker: <a href="https://github.com/enstrayed/enstrayedapi">github.com/enstrayed/enstrayedapi</a></p>
<hr>
<div class="inlineheader">
<h2>/api/nowplaying</h2>
<a href="https://github.com/Enstrayed/enstrayedapi/blob/main/routes/nowplaying.js">nowplaying.js</a>
<div>
<span>GET</span>
</div>
</div>
<p>Returns whatever I'm listening to via the Last.fm API in JSON. If <code>?format=html</code> is used in the URL it will return the same but in HTML. If nothing is playing the JSON response will just have <code>"playing": false</code>.</p>
<div class="inlineheader">
<h2>/api/nowplayingbeta</h2>
<a href="https://github.com/Enstrayed/enstrayedapi/blob/main/routes/nowplaying.js">nowplaying.js</a>
<div>
<span>GET</span>
</div>
</div>
<p>Beta verison of the /nowplaying endpoint. This version will change frequently but presently queries my Jellyfin for what I'm listening to and will return that as JSON. If <code>?format=html</code> is appended to the URL it will return the same but in HTML. Each line in the HTML response has a class <code>nowPlayingLine[1-4]</code> that can be used to style the text using CSS. See <a href="https://github.com/Enstrayed/enstrayedapi/blob/main/liberals/libnowplaying.js#L63">libnowplaying.js:63</a> for the format of the result.</p>
<div class="inlineheader">
<h2>/api/etyd/*</h2>
<a href="https://github.com/Enstrayed/enstrayedapi/blob/main/routes/etyd.js">etyd.js</a>
<div>
<span>GET</span>
<span>POST</span>
<span>DELETE</span>
</div>
</div>
<p>Retrieves, creates or deletes entries for the etyd.cc URL shortener. Replace * in the URL for the target of the request.</p>
<span>Required Headers (POST, DELETE):</span>
<ul>
<li><code>Authorization</code>: A token with the <code>etyd</code> scope</li>
</ul>
<span>Required Body (POST):</span>
<pre><code>{
"url": "urlValue"
}</code></pre>
<div class="inlineheader">
<h2>/api/sendemail</h2>
<a href="https://github.com/Enstrayed/enstrayedapi/blob/main/routes/mailjet.js#L3">mailjet.js</a>
<div>
<span>POST</span>
</div>
</div>
<p>Sends an email to the specified recipient, intended for application & automation use.</p>
<span>Required Headers:</span>
<ul>
<li><code>Authorization</code>: A token with the <code>mailjet</code> scope</li>
</ul>
<span>Required Body:</span>
<pre><code>{
"recipient": "recipientEmailHere",
"subject": "emailSubjectHere",
"message": "emailBodyHere"
}</code></pre>
<div class="inlineheader">
<h2>/api/ip</h2>
<a href="https://github.com/Enstrayed/enstrayedapi/blob/main/routes/ip.js">ip.js</a>
<div><span>GET</span></div>
</div>
<p>Returns the IP, country and Cloudflare ray of the request in JSON.</p>
<div class="inlineheader">
<h2>/api/headers</h2>
<a href="https://github.com/Enstrayed/enstrayedapi/blob/main/routes/ip.js">ip.js</a>
<div><span>GET</span></div>
</div>
<p>Returns all request headers in JSON.</p>
<div class="inlineheader">
<h2>/api/auth/whoami</h2>
<a href="https://github.com/Enstrayed/enstrayedapi/blob/new-db/routes/auth.js">auth.js:6</a>
<div><span>GET</span></div>
</div>
<p>Returns JSON with the username of the token owner as well as what scopes the token has access to.</p>
<div class="inlineheader">
<h2 id="jumplink_authlogin">/api/auth/login</h2>
<a href="https://github.com/Enstrayed/enstrayedapi/blob/new-db/routes/auth.js">auth.js:23</a>
<div><span>GET</span></div>
</div>
<p>Redirects the user to ECLS to login. The <code>state</code> parameter can be used to specify how the login flow will behave. The accepted "states" are:</p>
<ul>
<li><code>redirect</code> - Redirects the user to a page after logging in. This paramter requires the <code>destination</code> paramter to also be set with the URL the user will be redirected to.</li>
<li><code>display</code> - Displays the generated token to the user after login. Currently, this still writes the new token to the <code>APIToken</code> cookie, though this is planned to change.</li>
<li><code>close</code> - This will close the page after logging in. This requires the page to be opened with JavaScript otherwise it will not automatically close.</li>
</ul>
<div class="inlineheader">
<h2>/api/auth/logout</h2>
<a href="https://github.com/Enstrayed/enstrayedapi/blob/new-db/routes/auth.js">auth.js:40</a>
<div><span>GET</span></div>
</div>
<p>Invalidates the token used to access the endpoint.</p>
<div class="inlineheader">
<h2>/api/auth/callback</h2>
<a href="https://github.com/Enstrayed/enstrayedapi/blob/new-db/routes/auth.js">auth.js:57</a>
<div><span>GET</span></div>
</div>
<p><b>Internal Use Only. </b>This is the endpoint used by ECLS to finish the login flow. It will write the newly created token to the <code>APIToken</code> cookie as well as performing the action set by <code>state</code>, see <a href="#jumplink_authlogin">login endpoint</a>.</p>
<div class="inlineheader">
<h2>/api/helpdesk/forms/*</h2>
<a>helpdesk.js:15</a>
<div><span>GET</span></div>
</div>
<p><b>Internal Use Only. </b>Serves all files in the <code>website/helpdesk/forms</code> directory for use in the Helpdesk frontend.</p>
<!-- <div class="inlineheader">
<h2>/dynamic/icon/*</h2>
<a>dynamic.js:3</a>
<div><span>GET</span></div>
</div>
<p><b>Internal Use Only. </b>Returns the requested icon (stored in <code>website/dynamic/icons</code>) in any color (hex) specified in the URL. Example: <code>/dynamic/icon/github/00ff00</code> will return the GitHub logo in neon green.</p> -->
</body>
</html>