unsplash api documentation code example
Example 1: unsplash api javascript example
// set image source to a random image
img.src = "https://source.unsplash.com/random";
// get a random image with the size 800x600
img.src = "https://source.unsplash.com/random/800x600"
// Apply search terms
img.src = "https://source.unsplash.com/1600x900/?nature,water"
// More info: https://source.unsplash.com
Example 2: fake api images
Just add your desired image size (width & height) after our URL, and you'll get a random image.
https://picsum.photos/200/300
To get a square image, just add the size.
https://picsum.photos/200