You can use axios library to fetch the image and get the response url :
let randomURL = 'https://source.unsplash.com/random/1920x1080/?wallpaper,landscape';
axios.get(randomURL).then( data => {
// the url of the random img
console.log(data.request.responseURL);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.0/axios.min.js" integrity="sha256-S1J4GVHHDMiirir9qsXWc8ZWw74PHHafpsHp5PXtjTs=" crossorigin="anonymous"></script>
and with vanilla JS :
fetch("https://source.unsplash.com/random/1920x1080/?wallpaper,landscape").then( data => {
console.log(data.url);
});
and if you want to support old browsers :
request = new XMLHttpRequest();
request.open("GET", "https://source.unsplash.com/random/1920x1080/?wallpaper,landscape", true);
request.send(null);
request.onreadystatechange = function() {
if (request.readyState === 4) {
if (request.status === 200) {
console.log(request.responseURL);
}
}
}
Answer from Simon Dehaut on Stack OverflowUnsplash
unsplash.com › s › photos › html
Html Pictures | Download Free Images on Unsplash
Download the perfect html pictures. Find over 100+ of the best free html images. Free for commercial use ✓ No attribution required ✓ Copyright-free ✓
Get Unsplash+
Upgrade to Unsplash+ and start creating with exclusive, royalty-free images.
Wallpapers
See the best 17,316 free high-resolution photos of Wallpapers. These HD images are free to use for commercial projects.
Desktop Wallpapers
Choose from hundreds of free desktop wallpapers. Download HD wallpapers for free on Unsplash.
Log in
Login · Welcome back · Don’t have an account? Join
Unsplash
unsplash.com › s › photos › html-css
Html Css Pictures | Download Free Images on Unsplash
Download the perfect html css pictures. Find over 70 of the best free html css images. Free for commercial use ✓ No attribution required ✓ Copyright-free ✓
Bluegalaxy
bluegalaxy.info › codewalk › 2018 › 02 › 14 › html-get-random-stock-images-web-page-using-unsplash-com
HTML: How to get random stock images on your web page using unsplash.com | Chris Nielsen Code Walk
February 14, 2018 - The website https://unsplash.com provides a free service that allows web developers to use random images of any size on their websites. All you have to do is place a URL like this in your HTML img tag, with the size of the image listed at the end of the URL. For example, this will produce a ...
Unsplash
unsplash.com › developers
Unsplash Image API | Free HD Photo API
Everything you need to search, fetch, and insert beautiful Unsplash images directly into your application with a fully native UI. Available on Android and iOS. Every image URL returned by the API can easily be manipulated to dynamically adjust the dimensions, crop, and quality of the image in realtime. ... We maintain official libraries in JavaScript, PHP, and Ruby. Our community have also built popular libraries in Go, Python, Swift, and more.
Unsplash
unsplash.com
Beautiful Free Images & Pictures | Unsplash
Available on Unsplash+ –– –––– ––– ––– –– – –––. Supported by · Microsoft Copilot · Your AI Companion ↗ · Promoted · Download · Maria Louceiro · For Unsplash+ Download · Maximilian Bungart · Download · Louis Le Pessot ·
Unsplash
unsplash.com › s › photos › source
Source Pictures | Download Free Images on Unsplash
html · sources · nature · the source · random · source code · api · open source · url · water · coding · code · Dario Brönnimann · For Unsplash+ Download · Chastagner Thierry · Download · Arseny Togulev · Download · Artur Aldyrkhanov · Download · Casey Horner ·
Unsplash
unsplash.com › s › photos › html-code
Html Code Pictures | Download Free Images on Unsplash
Download the perfect html code pictures. Find over 100+ of the best free html code images. Free for commercial use ✓ No attribution required ✓ Copyright-free ✓
CodePen
codepen.io › traceofwind › pen › vRvdmz
Unsplash images API
View Compiled HTML · Analyze HTML · Maximize HTML Editor · Minimize HTML Editor · Fold All · Unfold All · <img src="https://source.unsplash.com/TCpfPxKPOvk/200x200" alt="scean"> <img src="https://source.unsplash.com/WLUHO9A_xik/200x200" alt="specific"> <img src="https://source.unsplash.com/random/200x200" alt="random"> <img src="https://source.unsplash.com/user/erondu/200x200" alt="user"> <img src="https://source.unsplash.com/200x200/?nature,water" alt="search terms"> <img src="https://source.unsplash.com/collection/190727/200x200" alt="collection"> <img src="https://source.unsplash.com/user/traceofwind/likes/200x200" alt="user likes"> !
Unsplash
unsplash.com › s › photos › html5
Html5 Pictures | Download Free Images on Unsplash
Download the perfect html5 pictures. Find over 21 of the best free html5 images. Free for commercial use ✓ No attribution required ✓ Copyright-free ✓
GitHub
github.com › unsplash › unsplash-source-js
GitHub - unsplash/unsplash-source-js: 🐮 A javascript wrapper for the Unsplash Source API
Starred by 174 users
Forked by 19 users
Languages JavaScript 100.0% | JavaScript 100.0%
Unsplash
unsplash.com › documentation
Unsplash API Documentation | Free HD Photo API | Unsplash
{ "id": "pXhwzz1JtQU", "updated_at": "2016-07-10T11:00:01-05:00", "username": "jimmyexample", "first_name": "James", "last_name": "Example", "twitter_username": "jimmy", "portfolio_url": null, "bio": "The user's bio", "location": "Montreal, Qc", "total_collections": 5, "downloads": 4321, "uploads_remaining": 4, "instagram_username": "james-example", "location": null, "email": "jim@example.com", "links": { "self": "https://api.unsplash.com/users/jimmyexample", "html": "https://unsplash.com/jimmyexample", "photos": "https://api.unsplash.com/users/jimmyexample/photos" } } PUT /me ·