From f411ffef8a2b0dbce438dacb70061b312df4814c Mon Sep 17 00:00:00 2001 From: pheralb Date: Tue, 16 Sep 2025 13:24:13 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20Refactor=20API=20docume?= =?UTF-8?q?ntation=20for=20clarity=20and=20consistency;=20update=20URLs=20?= =?UTF-8?q?and=20TypeScript=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/api.md | 105 +++++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/src/docs/api.md b/src/docs/api.md index 16ff811..2f1a676 100644 --- a/src/docs/api.md +++ b/src/docs/api.md @@ -11,30 +11,25 @@ SVGL API is a RESTFul API that allows you to get all the information of the SVGs The API is currently open to everyone and does not require any authentication. However, to prevent abusive use of the API, there is a limit to the number of requests. -Don't use the API for create the same product as SVGL. The API is intended to be used for extensions, plugins, or other tools that can help the community. +> Don't use the API for create the same product as SVGL. The API is intended to be used for extensions, plugins, or other tools that can help the community. -## Base URL +## Base URLs -The base URL for the API is: +SVGs URL: ```bash https://api.svgl.app -# or +``` + +Categories URL: + +```bash https://api.svgl.app/categories ``` -## Typescript usage +## Typescript -- For categories: - -```ts -export interface Category { - category: string; - total: number; -} -``` - -- For SVGs: +You can use the following types for the SVG responses: ```ts export type ThemeOptions = { @@ -42,27 +37,27 @@ export type ThemeOptions = { light: string; }; -export interface iSVG { - id?: number; +export interface SVG { + id: number; title: string; - category: tCategory | tCategory[]; + category: string | string[]; route: string | ThemeOptions; + url: string; wordmark?: string | ThemeOptions; brandUrl?: string; - url: string; } ``` -- `tCategory` is a large list of categories that can be found [here](https://github.com/pheralb/svgl/blob/main/src/types/categories.ts#L1). +> If you need types for the `category`, you can find them [here](https://github.com/pheralb/svgl/blob/main/src/types/categories.ts). Change the type of `category` to `Category | Category[]`. ## Endpoints +### Get all SVGs + ```bash https://api.svgl.app ``` -

- ```json // Returns: [ @@ -77,12 +72,12 @@ https://api.svgl.app ] ``` +### Get all SVGs with limit + ```bash https://api.svgl.app?limit=10 ``` -

- ```json // Returns: [ @@ -97,12 +92,12 @@ https://api.svgl.app?limit=10 ] ``` +### Get SVGs by category + ```bash https://api.svgl.app/category/software ``` -

- ```json // Returns: [ @@ -117,16 +112,24 @@ https://api.svgl.app/category/software ] ``` -The list of categories is available [here](https://github.com/pheralb/svgl/blob/main/src/types/categories.ts) (except for the _all_ category). +> The list of categories is available [here](https://github.com/pheralb/svgl/blob/main/src/types/categories.ts). + +### Get the SVG code + +Optimized SVG using [svgo](https://github.com/svg/svgo): ```bash https://api.svgl.app/svg/adobe.svg ``` -

+No optimized SVG: + +```bash +https://api.svgl.app/svg/adobe.svg?no-optimize +``` ```html -// Returns: + ``` -```bash -https://api.svgl.app/categories -``` - -

- -```json -// Returns: -[ - { - "category": "Software", - "total": 97 - }, - { - "category": "Library", - "total": 25 - }, - ... -] -``` +### Search SVG by title ```bash https://api.svgl.app?search=axiom ``` -

- ```json // Returns: [ @@ -192,3 +174,24 @@ https://api.svgl.app?search=axiom } ] ``` + +### Get the list of categories + +```bash +https://api.svgl.app/categories +``` + +```json +// Returns: +[ + { + "category": "Software", + "total": 97 + }, + { + "category": "Library", + "total": 25 + } + //... +] +```