# HAVEPX API
The HAVEPX API allows developers to access photos, videos, categories, creators, and search data from HAVEPX programmatically.
Base URL:
```txt
https://havepx.com/api/
```
---
# Authentication
Some endpoints are public, while others require an API key.
Example:
```http
Authorization: Bearer YOUR_API_KEY
```
---
# Response Format
All responses are returned in JSON format.
Example:
```json
{
"success": true,
"data": []
}
```
---
# Photos API
## Get Latest Photos
```http
GET /api/photos.php
```
Example:
```txt
https://havepx.com/api/photos.php
```
Response:
```json
{
"success": true,
"data": [
{
"id": 1,
"title": "Mountain Sunset",
"image": "https://havepx.com/uploads/2026/05/photo.jpg",
"views": 1200
}
]
}
```
---
## Get Single Photo
```http
GET /api/photo.php?id=1
```
Example:
```txt
https://havepx.com/api/photo.php?id=1
```
---
## Search Photos
```http
GET /api/search.php?q=nature
```
Example:
```txt
https://havepx.com/api/search.php?q=car
```
---
# Videos API
## Get Videos
```http
GET /api/videos.php
```
---
## Get Single Video
```http
GET /api/video.php?id=5
```
---
# Categories API
## Get Categories
```http
GET /api/categories.php
```
Response:
```json
{
"success": true,
"data": [
{
"id": 1,
"name": "Nature"
}
]
}
```
---
# Users API
## Get User Profile
```http
GET /api/user.php?id=1
```
Response:
```json
{
"success": true,
"user": {
"id": 1,
"username": "john",
"avatar": "https://havepx.com/uploads/avatar.jpg"
}
}
```
---
# Trending API
## Get Trending Content
```http
GET /api/trending.php
```
---
# Random API
## Get Random Photo
```http
GET /api/random.php
```
---
# Upload API
Requires authentication.
## Upload Photo
```http
POST /api/upload.php
```
Parameters:
| Name | Type | Required |
| ----------- | ------- | -------- |
| image | file | Yes |
| title | string | Yes |
| description | string | No |
| category_id | integer | No |
---
# Example PHP Request
```php
$json = file_get_contents(
'https://havepx.com/api/photos.php'
);
$data = json_decode($json, true);
print_r($data);
?>
```
---
# Example JavaScript Fetch
```javascript
fetch('https://havepx.com/api/photos.php')
.then(response => response.json())
.then(data => {
console.log(data);
});
```
---
# Rate Limits
To prevent abuse:
* 100 requests per minute for public endpoints
* Higher limits available for approved apps
---
# Error Responses
Example:
```json
{
"success": false,
"message": "Invalid API key"
}
```
---
# Status Codes
| Code | Description |
| ---- | ------------------- |
| 200 | Success |
| 400 | Bad Request |
| 401 | Unauthorized |
| 404 | Not Found |
| 429 | Rate Limit Exceeded |
| 500 | Server Error |
---
# Terms
By using the HAVEPX API you agree not to:
* Abuse the service
* Scrape aggressively
* Upload illegal content
* Violate copyright laws
---
# Contact
For API access, partnerships, or higher rate limits, contact the HAVEPX team through the contact page.