DEV Community

Jay Gander
Jay Gander

Posted on

Link Preview API

I'm a coding beginner so I made a simple link preview API in Python. The idea is that if you give the API any web page address it will return some metadata such as the web page title, description, preview image and favicon in JSON format. This can be used in chat applications and bookmarking tools to show a card with the link information.

How it works:
Python, using FastAPI and BeautifulSoup to scrape the Open Graph meta tags from the page. It blocks private and local addresses so nobody can use it to scan the servers network. It is hosted using the free plan on Render and can be found on RapidAPI.

Sample request:
GET /preview?url=https://github.com
Sample response:

{ "url": "https://github.com", "title": "GitHub", "description": "...", "image": "https://...", "site_name": "GitHub", "favicon": "https://..." }

It has a free plan with 100 requests per month, you can try it out here: https://rapidapi.com/JayGander/api/link-preview-api14

As it is my first API I would love any feedback. What could I improve to make it more useful for you?

Top comments (0)