
Unsplash Has a Free API — Get Professional Photos for Any Project (50 Requests/Hour)
Stop Using Lorem Picsum Unsplash has 4M+ high-resolution photos from professional photographers, all free for commercial use. Their API gives you programmatic access with 50 requests per hour on the free tier. Setup Register at unsplash.com/developers. Create an app to get your access key. import requests ACCESS_KEY = " your_unsplash_access_key " BASE = " https://api.unsplash.com " HEADERS = { " Authorization " : f " Client-ID { ACCESS_KEY } " } Search Photos def search_photos ( query , count = 5 ): r = requests . get ( f " { BASE } /search/photos " , headers = HEADERS , params = { " query " : query , " per_page " : count }) return [{ " id " : p [ " id " ], " url " : p [ " urls " ][ " regular " ], " thumb " : p [ " urls " ][ " thumb " ], " author " : p [ " user " ][ " name " ], " description " : p . get ( " alt_description " , "" )} for p in r . json ()[ " results " ]] photos = search_photos ( " mountain landscape " ) for p in photos : print ( f " { p [ author ] } : { p [ description ]
Continue reading on Dev.to Beginners
Opens in a new tab




