LinkPreview is an API that provides detailed info. of almost every website. It is built using FastAPI & Beautiful Soup
When you send us a link, we fetch it in our servers, format it and validate it, we will then send you back a preview of what's behind the link.
LinkPreview summarize the contents of the URL and display the name of the given website, an image and a description of the website's content.
It's difficult to undestand a string of undecipherable characters like https://youtu.be/dQw4w9WgXcQ
. LinkPreview provides you detailed website information - title, preview image, and short description in JSON format by default for any given URL
We provide both HTTP and HTTPS endpoints for our service:
Endpoint | HTTP Method |
---|---|
http://rinjo.herokuapp.com/link_preview/ | POST |
https://rinjo.herokuapp.com/link_preview/ | POST |
Name | Type | Description | Example Response |
---|---|---|---|
title | string / boolean | Website title | |
description | string / boolean | Description | Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for. |
image | bytes - base64 / boolean | Preview image URL | AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAA |
msg | string | Response of the URL | "Invalid URL" or "Can't process URL" or "Connection Time out" |
Example Response of bytes - base64 is just sample format of the image base64 encoded. If title, description or image return false then it means our API could not fetch the data from the URL.
$.ajax({
type: 'post',
contentType: "application/json",
url: "https://rinjo.herokuapp.com/link_preview/",
data: JSON.stringify({
url: "https://www.google.com"
}),
success: function(data) {
console.log(data);
},
error: function(data) {
console.log(data);
}
});
import requests
API_URL = "http://rinjo.herokuapp.com/link_preview/"
target = "https://www.google.com"
try:
response = requests.post(API_URL, json={'url': target}, timeout=60)
print(response.json())
except Exception as e:
print(e)
{
"title": "Google",
"description": "Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.",
"image": "AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAA"
}
Example Response of bytes - base64 is just sample format of the image base64 encoded
- Clone the repository using
git clone https://github.com/4akhilkumar/LinkPreview.git
- Install the Python 3.8 or above
- Install the Virtualenv using
pip install virtualenv
- Create a virtual environment using
python -m venv venv
- Activate the virtual environment using
venv\Scripts\activate
- Install the requirements using
python -m pip install -r requirements.txt
- Install the Virtualenv using
pip3 install virtualenv
- Create a virtual environment using
python3 -m venv venv
- Activate the virtual environment using
source venv/bin/activate
- Install the requirements using
python3 -m pip install -r requirements.txt
-
If requirements installation failed, try these commands as per your OS:
python -m pip install fastapi uvicorn[standard] beautifulsoup4 requests
-
Run the server using
uvicorn <file_name>:app --reload