API - compute the pixels width and remaining width of a title and/or description of page for Google SERP.
The goal of this tool is to optimize the writing of titles and descriptions of web pages. If the title or description of your page is too long, Google will automatically cut it to a certain length and add "..." at the end. This decreases the chance that a visitor will visit your site.
The source device used in this tool is a standard laptop with Chrome web browser (user agent) :
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36
In this configuration, the maximum width of the title is 554 pixels, and 1204 pixels for the description.
This search engine can be used with an UI : https://github.com/AnthonySigogne/seo-pixel-width-ui
A demo can be found here : http://pixelwidth.byprog.com/
This tool requires Python3.
git clone https://github.com/AnthonySigogne/seo-pixel-width.git
cd seo-pixel-width
pip install -r requirements.txt
Then, run the tool :
FLASK_APP=index.py flask run
To run in debug mode, prepend FLASK_DEBUG=1
to the command :
FLASK_DEBUG=1 ... flask run
To run the tool with Docker, you can use my DockerHub image : https://hub.docker.com/r/anthonysigogne/seo-pixel-width/
docker run -p 5000:5000 anthonysigogne/seo-pixel-width
Or, build yourself a Docker image :
git clone https://github.com/AnthonySigogne/seo-pixel-width.git
cd seo-pixel-width
docker build -t seo-pixel-width .
To list all services of API, type this endpoint in your web browser : http://localhost:5000/
Compute pixels width and remaining width of a title or/and description.
-
URL
/pixels
-
Method
POST
-
Form Data Params
Required (title and/or description):
title=[string]
, the title to analyze
description=[string]
, the description to analyze -
Success Response
- Code: 200
Content:{ "description": { "original_description": "Full-Stack Developer specialized in new technologies and innovative IT solutions.", "remaining": 558, "serp_description": "Full-Stack Developer specialized in new technologies and innovative IT solutions.", "width": 646 }, "title": { "original_title": "Anthony Sigogne / Freelance / Full-Stack Developer", "remaining": 141, "serp_title": "Anthony Sigogne / Freelance / Full-Stack Developer", "width": 413 } }
- Code: 200
-
Error Response
- Code: 400 INVALID USAGE
- Code: 400 INVALID USAGE
-
Sample Call (with cURL)
curl -X POST -F "description=Full-Stack Developer specialized in new technologies and innovative IT solutions." -F "title=Anthony Sigogne / Freelance / Full-Stack Developer" "http://localhost:5000/pixels"
Compute pixels width and remaining width of a page title and description.
-
URL
/pixels_url
-
Method
POST
-
Form Data Params
Required:
url=[string]
, the url to analyze -
Success Response
- Code: 200
Content:{ "description": { "original_description": "Full-Stack Developer specialized in new technologies and innovative IT solutions.", "remaining": 558, "serp_description": "Full-Stack Developer specialized in new technologies and innovative IT solutions.", "width": 646 }, "title": { "original_title": "Anthony Sigogne / Freelance / Full-Stack Developer", "remaining": 141, "serp_title": "Anthony Sigogne / Freelance / Full-Stack Developer", "width": 413 } }
- Code: 200
-
Error Response
- Code: 400 INVALID USAGE
- Code: 400 INVALID USAGE
-
Sample Call (with cURL)
curl -X POST -F "url=https://www.byprog.com/en" "http://localhost:5000/pixels_url"
- nothing ?
MIT