mirror of
https://github.com/pheralb/svgl.git
synced 2024-11-10 14:46:54 +08:00
✨ Initial /api page.
This commit is contained in:
parent
927cbdca6d
commit
18d7fe7cca
44
src/docs/api.md
Normal file
44
src/docs/api.md
Normal 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
14
src/routes/api/+page.ts
Normal 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`);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user