Using the WordPress mShots Screenshot API
A few years ago, I wrote about Google's secret screenshot API - a slightly cumbersome way to take website screenshots for free.
There's another service which you may find simpler to use - mShots from WordPress.
Here's how it works:
- Take any website link:
https://twitter.com/JennyVass/status/1067855777040338944
-
URL Encode it:
https%3A%2F%2Ftwitter.com%2FJennyVass%2Fstatus%2F1067855777040338944
- Add it to the end of this URL:
https://s0.wordpress.com/mshots/v1/
- Add
?w=800
to the end:https://s0.wordpress.com/mshots/v1/https%3A%2F%2Ftwitter.com%2FJennyVass%2Fstatus%2F1067855777040338944?w=800
There are a few things to note. The first time you send a URL to the service it will reply with HTTP 307
(temporary redirect) and you'll get this image:
Wait a few seconds and request the URL again, you should now have the image.
You can change the height of the image with h=500
. For example: https://s0.wordpress.com/mshots/v1/https%3A%2F%2Fwww.whatsmyua.info?w=800&h=500
The user-agent can't be changed from Headless Chrome.
You can request different widths by changing the ?w=800
to something else. The maximum image size is 1280x960. Changing the width doesn't affect the viewport, just the size of the returned image. Although, at some widths, you'll get a centre crop.
There are no other options. You can't change the image quality, image format, the IP address, geolocation, or anything else. Images will be cached for an unspecified period, so you'll need to mangle the link if you want to regenerate it.
mShots looks like it is abandonware - no new updates to it in the last 2 years. That's a shame, but you get what you pay for.
Doug says:
From Automattic 😉 not WordPress
@edent says:
Tomato Potato.
Doug says:
Is that a "it's the same thing?" comment?
The mshot tool is under the Automattic organisation and the URLs you've tested this with are
WordPress.com
- it's using Automattic services to generate the screenshot. Calling it a WordPress tool doesn't help the confusion people have.Mike says:
Having a W for Wordpress logo as a placeholder hardly helps clarity that it's Automattic...
Matt says:
If it's used for commercial use please get in touch with Automattic about a license.
Shafi says:
Hello Matt, I'm using it on Personal Website - and I'm getting generate preview if it's first time, if i refresh second or third time, it shows perfectly fine. Is there a way to fix this ? the visitors doesn't refresh the website two or three times certainly.
Khayri says:
Bummer. mShots does not seem to update screenshots regardless if the page changed content.