From 2b4724f39cf0b04e58e458e342dbb660a730d204 Mon Sep 17 00:00:00 2001 From: Tom Collis <22452596+tomcollis@users.noreply.github.com> Date: Tue, 11 Jun 2024 16:39:24 +0100 Subject: [PATCH] Add simple API documentation --- docs/api.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 docs/api.md diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..f00efc2 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,51 @@ +# Sink API + +Sink has a basic API implementation but it is not stable written yet. + +## API Reference + +### Create Short Link + +```http + POST /api/link/create +``` + +| Header | Description | +| :----- | :------------------------- | +| `authorization` | `Bearer SinkCool` | +| `content-type` | `application/json` | + + +#### Example + +```http + POST /api/link/create + HEADER authorization:Bearer SinkCool, content-type:application/json + BODY { + "url": "https://github.com/ccbikai/Sink/issues/14", + "slug": issue14 + } +``` + +The BODY data must be JSON. + +```http + RESPONSE 201 + BODY { + "link": { + "id": "xpqhaurv5q", + "url": "https://github.com/ccbikai/Sink/issues/14", + slug": "issue14", + "createdAt": 1718119809, + "updatedAt": 1718119809 + } + } +``` + +| Parameter | Type | Description | +| :-------- | :------- | :------------------------- | +| `id` | `string` | This is automatically generated by Sink | +| `url` | `string` | This is confirmation of the submitted URL and is required. | +| `slug` | `string` | This is slug generated by the system, either automatically or from the input (if provided) | +| `createdAt` | `timestamp` | This is automatically generated with a UNIX Timestamp. | +| `updatedAt` | `timestamp` | This is automatically generated with a UNIX Timestamp. | \ No newline at end of file