momtr / url-preview

☁️ API for previewing urls in a text body

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

url-preview

☁️🌍 An API for previewing links/urls within a large text body.

Endpoints

Get meta data for links within text body

GET /api/v1/text/urls/meta?q={base64_encoded_text_body}

Params:

- q {base64_string} base64 encoded text

200 Success:

- obj {Object} object containing meta data for url(s)

Example/Request:

// define text (e.g. user input)
let text = 'hello https://orf.at';
// convert text into a base64 string
let base64_text = btoa(text);
// call endpoint with text
let response = await fetch(`/api/v1/text/urls/meta?q=${base64_text}`);
// get JSON response
let jsonResponse = await response.json();

Example/Response:

{
    "message": "🚀 links given",
    "data": [
        {
            "url": "https://orf.at",
            "title": "news.ORF.at",
            "favicon": "https://orf.at/mojo/1_4_1/storyserver//common/images/favicons/favicon-32x32.png",
            "description": "news.ORF.at: Die aktuellsten Nachrichten auf einen Blick - aus Österreich und der ganzen Welt. In Text, Bild und Video.",
            "image": "https://ibs.orf.at/news?image=https%3A%2F%2Forf.at%2Fmojo%2F1_4_1%2Fstoryserver%2Fnews%2Fcommon%2Fimages%2Fog-fallback-news.png%3Fs%3D6fd0304156999f5fb116dbe1800653666b242a18",
            "author": null
        }
    ]
}

Install

Clone this repo

$ git clone https://github.com/moritzmitterdorfer/url-preview.git

Install NPM packages

$ npm install

Start app

$ npm run dev

About

☁️ API for previewing urls in a text body

License:MIT License


Languages

Language:JavaScript 51.3%Language:HTML 48.5%Language:Shell 0.2%