A simple API for shortening and retrieving links.
-
Shorten a Link:
- Endpoint:
/shorten
- Method: POST
- Example Request using
fetch
:fetch("{{BASEURL}}/shorten", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ url: "https://example.com" }), }) .then((response) => response.json()) .then((data) => console.log(data)) .catch((error) => console.error("Error:", error));
- Example Response:
{ "id": "abc123", "shortUrl": "{{baseurl}}/abc123", "expireAt": "12/04/2025" }
- Endpoint:
-
Use Shortened Link:
- Endpoint:
{{BASEURL}}/:id
- Open the link in your browser
- Endpoint:
-
Clone the repository:
git clone https://github.com/Timi-Leyin/shortner-api.git
-
Install dependencies:
cd shortner-api npm install
-
Start the API:
npm start
The API will be accessible at http://localhost:your-port.
If you'd like to contribute, please fork the repository and create a pull request. Make sure to follow the Contributing Guidelines.
This project is licensed under the MIT License.