Initial /api page.

This commit is contained in:
pheralb 2023-12-13 23:42:40 +00:00
parent 927cbdca6d
commit 18d7fe7cca
2 changed files with 58 additions and 0 deletions

44
src/docs/api.md Normal file
View File

@ -0,0 +1,44 @@
---
title: API Reference
description: The API reference is a detailed documentation of all the endpoints available in the SVGL API.
---
<script>
import Endpoint from '../components/endpoints.svelte';
</script>
## Introduction
SVGL API is a RESTFul API that allows you to get all the information of the SVGs that are in the repository.
## Limitations
The API is currently open to everyone and does not require any authentication. However, there is a limit of **50** requests per day per IP address. If you exceed this limit, you will receive a _429_ error.
## Base URL
The base URL for the API is:
```bash
https://svgl.vercel.app/api/svgs
```
## Endpoints
<div class="flex flex-col space-y-2">
<Endpoint title="Get all SVGs" method="GET" description="Returns all the SVGs in the repository.">
```
https://svgl.vercel.app/api/svgs
```
</Endpoint>
<Endpoint title="Get a limited number of SVGs" method="GET" description="Returns a limited number of SVGs in the repository.">
```
https://svgl.vercel.app/api/svgs?limit=10
```
</Endpoint>
</div>

14
src/routes/api/+page.ts Normal file
View File

@ -0,0 +1,14 @@
import { error } from '@sveltejs/kit';
export async function load() {
try {
const documentTitle = 'api';
const post = await import(`../../docs/${documentTitle}.md`);
return {
content: post.default,
meta: post.metadata
};
} catch (e) {
throw error(404, `Could not find this page`);
}
}