"""
Unsplash — Search Photos Demo
==============================
A minimal, ready-to-run example of searching free stock photos.

Get an API key (free):
    1. Create an account at https://unsplash.com/join
    2. Go to https://unsplash.com/oauth/applications and click
       "New Application" (accept the API terms).
    3. Copy the application's "Access Key".

Setup:
    pip install requests
    export UNSPLASH_ACCESS_KEY="..."

Run:
    python unsplash_demo.py
"""

import os
import requests


def search_photos(query: str) -> list:
    """Return image URLs for photos matching the query."""
    response = requests.get(
        "https://api.unsplash.com/search/photos",
        params={"query": query, "per_page": 5},
        headers={"Authorization": f"Client-ID {os.environ.get('UNSPLASH_ACCESS_KEY')}"},
    )
    response.raise_for_status()
    return [p["urls"]["regular"] for p in response.json()["results"]]


if __name__ == "__main__":
    for url in search_photos("Chiang Mai temple"):
        print(url)
