Files
newznab-tmux/resources/views/api/apidesc.blade.php
T
2025-10-06 19:43:28 +02:00

211 lines
12 KiB
PHP

@extends('layouts.main')
@section('content')
<div class="card card-default shadow-sm mb-4">
<div class="card-header bg-light">
<h3 class="mb-0"><i class="fa fa-code me-2 text-primary"></i>{{ $title }}</h3>
</div>
<div class="card-body">
<p class="lead">
Here lives the documentation for the API for accessing NZB and index data. API functions can be called by either
logged in users, or by providing an API key.
</p>
@if($loggedin ?? false)
<div class="card card-body bg-light mb-4">
<h4 class="mb-3"><i class="fa fa-key me-2 text-secondary"></i>Your API Credentials</h4>
<div class="input-group">
<input type="text" class="form-control font-monospace" value="apikey={{ $userdata->api_token }}" readonly id="apikeyInput">
<button class="btn btn-outline-secondary" type="button" id="copyApiKey" title="Copy to clipboard">
<i class="fa fa-copy"></i>
</button>
</div>
</div>
@endif
<h4 class="mb-3"><i class="fa fa-plug me-2 text-secondary"></i>Available Functions</h4>
<p>Use the parameter <code>?t=</code> to specify the function being called.</p>
<div class="table-responsive">
<table class="table table-striped table-hover" style="table-layout: fixed;">
<thead class="table-light">
<tr>
<th style="width: 15%; padding-right: 2rem;">Function</th>
<th style="width: 50%; padding-left: 2rem; padding-right: 2rem;">Description</th>
<th style="width: 35%; padding-left: 2rem;">Example</th>
</tr>
</thead>
<tbody>
<tr>
<td style="padding-right: 2rem;"><strong>Capabilities</strong></td>
<td style="padding-left: 2rem; padding-right: 2rem;">
Reports the capabilities of the server. Includes information about the server name,
available search categories and version number of the newznab protocol being used.
<div class="text-muted small mt-1">
<i class="fa fa-info-circle me-1"></i>No credentials required
</div>
</td>
<td style="padding-left: 2rem;">
<a href="{{ url('/api/v1/api?t=caps') }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-external-link-alt me-1"></i>
<code>?t=caps</code>
</a>
</td>
</tr>
<tr>
<td style="padding-right: 2rem;"><strong>Search</strong></td>
<td style="padding-left: 2rem; padding-right: 2rem;">
Returns a list of NZBs matching a query. You can filter by site category by including
a comma separated list of categories.
<div class="mt-2">
<span class="badge bg-info text-white">OPTIONS</span>
<div class="mt-1 ms-2">
<code>extended=1</code> - Return extended information in results
</div>
</div>
</td>
<td style="padding-left: 2rem;">
<div class="d-flex flex-column gap-2">
@if($loggedin ?? false)
<a href="{{ url('/api/v1/api?t=search&q=linux&apikey=' . $userdata->api_token) }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-external-link-alt me-1"></i>
<code>?t=search&amp;q=linux</code>
</a>
<a href="{{ url('/api/v1/api?t=search&cat=' . $catClass::GAME_ROOT . ',' . $catClass::MOVIE_ROOT . '&apikey=' . $userdata->api_token) }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-external-link-alt me-1"></i>
<code>?t=search&amp;cat={{ $catClass::GAME_ROOT }},{{ $catClass::MOVIE_ROOT }}</code>
</a>
@endif
</div>
</td>
</tr>
<tr>
<td style="padding-right: 2rem;"><strong>TV Search</strong></td>
<td style="padding-left: 2rem; padding-right: 2rem;">
Returns a list of NZBs matching a query, category, or TV ID. Filter by season, episode, or various database IDs.
<div class="mt-2">
<span class="badge bg-info text-white">ID OPTIONS</span>
<div class="mt-1 ms-2">
<code>rid=25056</code> - TVRage<br>
<code>tvdbid=153021</code> - TVDB<br>
<code>traktid=1393</code> - Trakt<br>
<code>tvmazeid=73</code> - TVMaze<br>
<code>imdbid=1520211</code> - IMDB<br>
<code>tmdbid=1402</code> - TMDB
</div>
</div>
</td>
<td style="padding-left: 2rem;">
@if($loggedin ?? false)
<a href="{{ url('/api/v1/api?t=tvsearch&q=law%20and%20order&season=7&ep=12&apikey=' . $userdata->api_token) }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-external-link-alt me-1"></i>
<code>?t=tvsearch&amp;q=law and order&amp;season=7&amp;ep=12</code>
</a>
@endif
</td>
</tr>
<tr>
<td style="padding-right: 2rem;"><strong>Movies</strong></td>
<td style="padding-left: 2rem; padding-right: 2rem;">
Returns a list of NZBs matching a query, an IMDB ID and optionally a category.
<div class="mt-2">
<span class="badge bg-info text-white">OPTIONS</span>
<div class="mt-1 ms-2">
<code>extended=1</code> - Return extended information in results
</div>
</div>
</td>
<td style="padding-left: 2rem;">
@if($loggedin ?? false)
<a href="{{ url('/api/v1/api?t=movie&imdbid=1418646&apikey=' . $userdata->api_token) }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-external-link-alt me-1"></i>
<code>?t=movie&amp;imdbid=1418646</code>
</a>
@endif
</td>
</tr>
<tr>
<td style="padding-right: 2rem;"><strong>Details</strong></td>
<td style="padding-left: 2rem; padding-right: 2rem;">Returns detailed information about an NZB.</td>
<td style="padding-left: 2rem;">
@if($loggedin ?? false)
<a href="{{ url('/api/v1/api?t=details&id=9ca52909ba9b9e5e6758d815fef4ecda&apikey=' . $userdata->api_token) }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-external-link-alt me-1"></i>
<code>?t=details&amp;id=9ca52909ba9b9e5e6758d815fef4ecda</code>
</a>
@endif
</td>
</tr>
<tr>
<td style="padding-right: 2rem;"><strong>Info</strong></td>
<td style="padding-left: 2rem; padding-right: 2rem;">
Returns NFO contents for an NZB. Retrieve the NFO as file by specifying o=file in the request URI.
</td>
<td style="padding-left: 2rem;">
@if($loggedin ?? false)
<a href="{{ url('/api/v1/api?t=info&id=9ca52909ba9b9e5e6758d815fef4ecda&apikey=' . $userdata->api_token) }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-external-link-alt me-1"></i>
<code>?t=info&amp;id=9ca52909ba9b9e5e6758d815fef4ecda</code>
</a>
@endif
</td>
</tr>
<tr>
<td style="padding-right: 2rem;"><strong>Get</strong></td>
<td style="padding-left: 2rem; padding-right: 2rem;">Downloads the NZB file associated with an ID.</td>
<td style="padding-left: 2rem;">
@if($loggedin ?? false)
<a href="{{ url('/api/v1/api?t=get&id=9ca52909ba9b9e5e6758d815fef4ecda&apikey=' . $userdata->api_token) }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-external-link-alt me-1"></i>
<code>?t=get&amp;id=9ca52909ba9b9e5e6758d815fef4ecda</code>
</a>
@endif
</td>
</tr>
</tbody>
</table>
</div>
<h4 class="mt-4 mb-3"><i class="fa fa-file-code me-2 text-secondary"></i>Output Format</h4>
<p>Select your preferred output format (not applicable to functions which return an NZB/NFO file).</p>
<div class="row">
<div class="col-md-6 mb-3">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title"><i class="fa fa-code me-2 text-primary"></i>XML (default)</h5>
<p class="card-text">Returns the data in an XML document.</p>
<code class="d-block bg-light p-2 rounded">?t=search&amp;q=linux&amp;o=xml</code>
</div>
</div>
</div>
<div class="col-md-6 mb-3">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title"><i class="fa fa-brackets-curly me-2 text-primary"></i>JSON</h5>
<p class="card-text">Returns the data in a JSON object.</p>
<code class="d-block bg-light p-2 rounded">?t=search&amp;q=linux&amp;o=json</code>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const copyBtn = document.getElementById('copyApiKey');
if (copyBtn) {
copyBtn.addEventListener('click', function() {
const apiKeyInput = document.getElementById('apikeyInput');
apiKeyInput.select();
apiKeyInput.setSelectionRange(0, 99999);
navigator.clipboard.writeText(apiKeyInput.value);
const originalText = copyBtn.innerHTML;
copyBtn.innerHTML = '<i class="fa fa-check"></i>';
copyBtn.classList.add('btn-success');
copyBtn.classList.remove('btn-outline-secondary');
setTimeout(function() {
copyBtn.innerHTML = originalText;
copyBtn.classList.remove('btn-success');
copyBtn.classList.add('btn-outline-secondary');
}, 2000);
});
}
});
</script>
@endsection