# Wallpapers App

## 📋 Overview

The Wallpapers app fetches images from the Pexels API, which provides access to over 4.5 million high-quality images, illustrations, and vectors. To use this feature, you'll need to obtain a free API key from Pexels.

## 🔑 Getting Your Pexels API Key

### Step 1: Create a Pexels Account

1. Visit [Pexels.com](https://www.pexels.com/api/key/)
2. Sign up using your email or social media/google accounts.
3. Verify your email address if required.

### Step 2: Access the API Documentation

1. Once logged in, go to [Pexels API Form ](https://www.pexels.com/api/key/)
2. Fill in the form and Confirm

### Step 3: Get Your API Key

1. On the next page, you'll see your API key displayed
2. It will look something like: `twP5l3YSdChS27hMOTdTMgW7Pkv0e25idvSnj1oPC3nh2Wlttz91AfW5`
3. Copy this key - you'll need it for the next step

## ⚙️ Server Configuration

### Using server.cfg (Recommended)

Add the following line to your `server.cfg` file:

```cfg
# Pexels API Key for YSeries Wallpapers App
set yseriesPexelsApiKey "YOUR_API_KEY_HERE"
```

**Example:**

```cfg
set yseriesPexelsApiKey "twP5l3YSdChS27hMOTdTMgW7Pkv0e25idvSnj1oPC3nh2Wlttz91AfW5"
```

## 🧪 Testing the Setup

1. **Start your server** with the new configuration
2. **Join the server** and open the YSeries phone
3. **Navigate to the Wallpapers app**
4. **Check if images load** - you should see wallpapers
5. **Test search functionality** by searching for different terms

## 🚨 Troubleshooting

### Common Issues:

**❌ No images loading / "API Key Missing" error**

* Verify your API key is correctly set in `server.cfg`
* Ensure there are no extra spaces or quotes in the convar
* Restart your server after making changes

**❌ "Rate Limited" error**

* Pexels free accounts have rate limits (200 requests/hour)
* Wait for the rate limit to reset or consider upgrading your Pexels account

**❌ Images load but downloads fail**

* Check server console for error messages
* Ensure the server has internet connectivity
* Verify write permissions for the resource directory

## 📊 API Limits

### Free Account Limits:

* **200 API requests per hour**
* **Access to all image types** (photos, illustrations, vectors)
* We have added caching to reduce the number of direct requests to the API.

### Rate Limit Information:

* Limits reset every hour
* The app will show appropriate error messages when limits are exceeded

## 🎨 App Features

Once properly configured, the Wallpapers app provides:

* **Browse by categories** (Nature, Architecture, Abstract, Cars, etc.)
* **Search functionality** with real-time results
* **High-quality image previews**
* **Set as wallpaper** (lock screen, home screen, or both)
* **Download images** to device storage
* **Infinite scroll** for seamless browsing
* **Author attribution** for all images

## 📞 Support

If you encounter issues:

1. **Check server console** for error messages
2. **Verify API key format**
3. **Test with a fresh API key** from Pexels

***
