# Yalla Hack Blog API Documentation
**Version:** 1.0
**Base URL:** `https://yalla-hack.ae/api`
**Last Updated:** October 26, 2025
---
## Table of Contents
1. [Overview](#overview)
2. [Authentication](#authentication)
3. [API Endpoints](#api-endpoints)
- [Blog Webhook (n8n Integration)](#blog-webhook-n8n-integration)
- [Add Blog](#add-blog)
- [Get Blogs](#get-blogs)
- [Get Single Blog](#get-single-blog)
- [View Submissions](#view-submissions)
4. [Request & Response Format](#request--response-format)
5. [Error Handling](#error-handling)
6. [Rate Limiting](#rate-limiting)
7. [Examples](#examples)
8. [Integration Guides](#integration-guides)
- [n8n Form Integration](#n8n-form-integration)
9. [Troubleshooting](#troubleshooting)
10. [Support](#support)
---
## Overview
The Yalla Hack Blog API provides a RESTful interface for managing blog posts. It supports creating, reading, and retrieving blog content with full HTML support, author attribution, and reading time estimates.
### Key Features
- ✅ **RESTful Architecture** - Standard HTTP methods (GET, POST)
- ✅ **JSON Responses** - All responses in JSON format
- ✅ **HTML Content Support** - Rich text formatting with full HTML
- ✅ **Security** - Authentication protected, SQL injection prevention
- ✅ **CORS Enabled** - Cross-origin requests supported
- ✅ **UTF-8 Encoding** - Full international character support
- ✅ **Auto-slugification** - Automatic URL-friendly slug generation
- ✅ **Timestamps** - Automatic creation and update timestamps
### Base URL
```
https://yalla-hack.ae/api
```
All API requests should be made to this base URL followed by the endpoint path.
---
## Authentication
### Authentication Method
The API uses **header-based authentication** for protected endpoints.
**Authentication Header:**
```
admin: 11aa22ss
```
### Protected Endpoints
Only the following endpoint requires authentication:
- `POST /add_blog.php` - Create new blog post
### Public Endpoints
These endpoints are publicly accessible without authentication:
- `GET /get_blogs.php` - Retrieve all blog posts
- `GET /get_blog.php` - Retrieve single blog post
- `GET /test.php` - Health check endpoint
- `GET /rss.php` - RSS 2.0 feed of latest blog posts
### Authentication Example
```bash
curl -X POST https://yalla-hack.ae/api/add_blog.php \
-H "Content-Type: application/json" \
-H "admin: 11aa22ss" \
-d '{"title":"Test Post","content":"Content here"}'
```
### Security Notes
⚠️ **Important:**
- Keep the authentication key secure
- Never expose the key in client-side code
- Use HTTPS for all requests
- Rotate the key periodically for security
- Monitor API usage for suspicious activity
---
## API Endpoints
---
### 1. Blog Webhook (n8n Integration)
**NEW!** Public webhook endpoint for n8n form integration. Receives blog submissions from external forms and forwards to the authenticated API.
**Endpoint:** `POST /blog-webhook.php`
**Authentication:** None required (internally forwards with authentication)
**Description:** Accepts blog submissions from n8n forms or external sources. Validates data, logs submissions, and forwards to the authenticated add_blog.php endpoint.
**Content-Type:**
- `application/json` (Recommended)
- `application/x-www-form-urlencoded` (Form data)
**Request (JSON):**
```http
POST /api/blog-webhook.php
Content-Type: application/json
{
"title": "Understanding Modern Cybersecurity Threats",
"content": "
Introduction
Cybersecurity is evolving...
",
"author": "John Doe",
"image_url": "https://example.com/image.jpg",
"time_read": "7 min read"
}
```
**Request (Form Data):**
```http
POST /api/blog-webhook.php
Content-Type: application/x-www-form-urlencoded
blog_title=Understanding Modern Cybersecurity Threats
blog_content=
Introduction
Cybersecurity is evolving...
blog_author=John Doe
image_url=https://example.com/image.jpg
time_read=7 min read
```
**Success Response:**
```json
{
"success": true,
"message": "Blog post submitted successfully",
"id": 42,
"slug": "understanding-modern-cybersecurity-threats",
"url": "https://yalla-hack.ae/blog-post.html?slug=understanding-modern-cybersecurity-threats"
}
```
**Error Response:**
```json
{
"success": false,
"error": "Missing required fields: title and content"
}
```
**Required Fields:**
- `title` or `blog_title` - Blog post title
- `content` or `blog_content` - Blog content (HTML supported)
**Optional Fields:**
- `author` or `blog_author` - Author name (defaults to "Yalla Hack Team")
- `image_url` - Featured image URL
- `time_read` - Reading time estimate (defaults to "5 min read")
**Features:**
- ✅ Automatic authentication handling
- ✅ Submission logging for tracking
- ✅ Support for both JSON and form data
- ✅ IP and user agent tracking
- ✅ Automatic URL generation
**Use Cases:**
- n8n form submissions
- External blog submission forms
- Automated content publishing
- Third-party integrations
**See Also:** [N8N-BLOG-INTEGRATION.md](./N8N-BLOG-INTEGRATION.md) for complete setup guide
---
### 2. Health Check
Check API availability and database connectivity.
**Endpoint:** `GET /test.php`
**Authentication:** None required (optional)
**Description:** Returns the status of the database connection and authentication.
**Request:**
```http
GET /api/test.php
```
**Response:**
```json
{
"db": true,
"auth": false
}
```
**Response with Authentication:**
```bash
curl -H "admin: 11aa22ss" https://yalla-hack.ae/api/test.php
```
```json
{
"db": true,
"auth": true
}
```
**Response Fields:**
- `db` (boolean) - Database connection status
- `auth` (boolean) - Authentication status
---
### 2. Get All Blog Posts
Retrieve all blog posts ordered by creation date (newest first).
**Endpoint:** `GET /get_blogs.php`
**Authentication:** None required
**Description:** Returns an array of all blog posts with complete metadata.
**Request:**
```http
GET /api/get_blogs.php
```
**Response:**
```json
[
{
"id": "1",
"title": "Welcome to Yalla Hack Blog",
"slug": "welcome-to-yalla-hack-blog",
"content": "Welcome to the official Yalla Hack blog...",
"image_url": "https://images.unsplash.com/photo-1550751827-4bd374c3f58b?w=800",
"author": "Yalla Hack Team",
"time_read": "5 min read",
"created_at": "2025-10-26 23:27:25"
},
{
"id": "2",
"title": "Advanced Penetration Testing",
"slug": "advanced-penetration-testing",
"content": "Learn advanced pentesting techniques...",
"image_url": "https://example.com/image2.jpg",
"author": "Mohammed Ahmed",
"time_read": "12 min read",
"created_at": "2025-10-27 10:15:30"
}
]
```
**Response Fields:**
- `id` (string) - Unique blog post identifier
- `title` (string) - Blog post title
- `slug` (string) - URL-friendly identifier
- `content` (string) - Full blog content (HTML or plain text)
- `image_url` (string|null) - Featured image URL
- `author` (string) - Author name
- `time_read` (string) - Estimated reading time
- `created_at` (string) - Creation timestamp (YYYY-MM-DD HH:MM:SS)
**Empty Response:**
```json
[]
```
---
### 3. Get Single Blog Post
Retrieve a specific blog post by its slug.
**Endpoint:** `GET /get_blog.php?slug={slug}`
**Authentication:** None required
**Description:** Returns a single blog post matching the provided slug.
**Parameters:**
- `slug` (required, string) - The URL-friendly identifier of the blog post
**Request:**
```http
GET /api/get_blog.php?slug=welcome-to-yalla-hack-blog
```
**Response (Success):**
```json
{
"id": 1,
"title": "Welcome to Yalla Hack Blog",
"slug": "welcome-to-yalla-hack-blog",
"content": "Welcome to the official Yalla Hack blog...",
"image_url": "https://images.unsplash.com/photo-1550751827-4bd374c3f58b?w=800",
"author": "Yalla Hack Team",
"time_read": "5 min read",
"created_at": "2025-10-26 23:27:25"
}
```
**Response (Not Found):**
```json
{
"error": "Not found"
}
```
HTTP Status: `404`
**Error Response (Missing Slug):**
```json
{
"error": "Missing slug"
}
```
---
### 5. View Blog Submissions
**NEW!** View and track blog submissions from the n8n webhook. Protected endpoint for monitoring form submissions.
**Endpoint:** `GET /view-submissions.php`
**Authentication:** Required (`admin: 11aa22ss`)
**Description:** Returns logged blog submissions with statistics and filtering options.
**Headers:**
```
admin: 11aa22ss
```
**Query Parameters:**
- `status` (optional) - Filter by status: `success`, `error`, `api_error`, `exception`
- `limit` (optional) - Maximum number of results (default: 50)
- `search` (optional) - Search by title or author
**Request Examples:**
```http
# Get all submissions
GET /api/view-submissions.php
# Get only successful submissions
GET /api/view-submissions.php?status=success
# Get only errors
GET /api/view-submissions.php?status=error
# Search for specific blog
GET /api/view-submissions.php?search=cybersecurity
# Limit results
GET /api/view-submissions.php?limit=10
```
**Response:**
```json
{
"success": true,
"count": 15,
"total_submissions": 23,
"statistics": {
"success": 20,
"errors": 3,
"success_rate": 86.96
},
"submissions": [
{
"timestamp": "2026-01-05 14:30:00",
"ip": "192.168.1.1",
"user_agent": "n8n-webhook/1.0",
"input_type": "json",
"blog_title": "Understanding Modern Threats",
"blog_author": "John Doe",
"status": "success",
"blog_id": 42,
"blog_slug": "understanding-modern-threats"
},
{
"timestamp": "2026-01-05 13:15:00",
"ip": "192.168.1.2",
"user_agent": "PostmanRuntime/7.26.8",
"input_type": "json",
"blog_title": "Test Blog",
"blog_author": "Test User",
"status": "error",
"error": "Missing required fields: content"
}
]
}
```
**Response Fields:**
- `success` (boolean) - Request status
- `count` (number) - Number of submissions returned
- `total_submissions` (number) - Total submissions in log
- `statistics` (object) - Submission statistics
- `success` (number) - Successful submissions
- `errors` (number) - Failed submissions
- `success_rate` (number) - Percentage of successful submissions
- `submissions` (array) - List of submission records
**Submission Record Fields:**
- `timestamp` - Submission date/time
- `ip` - Client IP address
- `user_agent` - Client user agent
- `input_type` - Input format (`json` or `form`)
- `blog_title` - Submitted blog title
- `blog_author` - Submitted author name
- `status` - Submission status
- `blog_id` - Created blog ID (success only)
- `blog_slug` - Generated slug (success only)
- `error` - Error message (errors only)
**Use Cases:**
- Monitor form submissions
- Track success rates
- Debug integration issues
- Audit blog creation
- Generate reports
---
### 6. RSS Feed
Create a new blog post with optional HTML content.
**Endpoint:** `POST /add_blog.php`
**Authentication:** Required (`admin: 11aa22ss`)
**Description:** Creates a new blog post and automatically generates a URL-friendly slug.
**Headers:**
```
Content-Type: application/json
admin: 11aa22ss
```
---
### 7. Create Blog Post
Create a new blog post with optional HTML content.
**Endpoint:** `POST /add_blog.php`
**Authentication:** Required (`admin: 11aa22ss`)
**Description:** Creates a new blog post and automatically generates a URL-friendly slug. This is the internal API - for public submissions use `/blog-webhook.php` instead.
**Headers:**
```
Content-Type: application/json
admin: 11aa22ss
```
**Request Body:**
```json
{
"title": "Blog Post Title",
"content": "Blog post content (HTML or plain text)",
"image_url": "https://example.com/image.jpg",
"author": "Author Name",
"time_read": "10 min read"
}
```
**Request Fields:**
| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `title` | string | ✅ Yes | - | Blog post title (max 255 chars) |
| `content` | string | ✅ Yes | - | Blog content (supports HTML) |
| `image_url` | string | ❌ No | `null` | Featured image URL (max 500 chars) |
| `author` | string | ❌ No | `"Yalla Hack Team"` | Author name (max 255 chars) |
| `time_read` | string | ❌ No | `"5 min read"` | Reading time estimate (max 50 chars) |
**Complete Request Example:**
```bash
curl -X POST https://yalla-hack.ae/api/add_blog.php \
-H "Content-Type: application/json" \
-H "admin: 11aa22ss" \
-d '{
"title": "Advanced Penetration Testing Techniques",
"content": "
Introduction
Learn advanced pentesting...
",
"image_url": "https://images.unsplash.com/photo-1550751827-4bd374c3f58b?w=800",
"author": "Mohammed Ahmed",
"time_read": "12 min read"
}'
```
**Minimal Request Example:**
```bash
curl -X POST https://yalla-hack.ae/api/add_blog.php \
-H "Content-Type: application/json" \
-H "admin: 11aa22ss" \
-d '{
"title": "Quick Security Tip",
"content": "Always use strong passwords!"
}'
```
**Response (Success):**
```json
{
"success": true,
"id": 3,
"slug": "advanced-penetration-testing-techniques"
}
```
HTTP Status: `200`
**Response Fields:**
- `success` (boolean) - Operation status
- `id` (integer) - ID of the newly created blog post
- `slug` (string) - Auto-generated URL-friendly slug
---
### 5. RSS Feed (Public)
Consume the 20 most recent blog posts in RSS 2.0 format for syndication platforms.
**Endpoint:** `GET /rss.php`
**Authentication:** None required
**Description:** Returns an XML feed containing metadata for the latest published blog posts. Ideal for newsletter automation, LinkedIn content ingestion, and RSS readers.
**Headers:**
```
Content-Type: application/rss+xml; charset=UTF-8
```
**Request:**
```http
GET /rss.php
```
**Response (Truncated):**
```xml
Yalla-Hack Cybersecurity Blog
https://yalla-hack.com/
Latest cybersecurity insights, threat intelligence, and best practices from the Yalla-Hack team.Mon, 03 Nov 2025 09:00:00 +0000Welcome to Yalla Hack Blog
https://yalla-hack.com/blog-post.html?slug=welcome-to-yalla-hack-blog
https://yalla-hack.com/blog-post.html?slug=welcome-to-yalla-hack-blogWelcome to the official Yalla Hack blog...Mon, 03 Nov 2025 08:30:00 +0000
```
**Notes:**
- Feed is cached for five minutes to reduce database load.
- All XML characters are escaped to remain validator-friendly.
- Only published posts with timestamps are included.
- `pubDate` is formatted using RFC 822 (`DATE_RSS`).
---
## Request & Response Format
### Content Type
All API responses use JSON format unless noted otherwise. The RSS feed (`/rss.php`) delivers XML syndication data.
```
Content-Type: application/json
```
```
Content-Type: application/rss+xml; charset=UTF-8
```
### Character Encoding
All data is encoded in UTF-8:
```
Charset: UTF-8
```
### Slug Generation
Slugs are automatically generated from the title:
**Rules:**
1. Convert to lowercase
2. Replace spaces with hyphens
3. Remove special characters
4. Trim leading/trailing hyphens
**Examples:**
- `"Hello World"` → `"hello-world"`
- `"Top 10 Security Tips!"` → `"top-10-security-tips"`
- `"What is XSS?"` → `"what-is-xss"`
If the title results in an empty slug, a unique identifier is generated: `post-{uniqid}`
### Date Format
All timestamps use MySQL datetime format:
```
YYYY-MM-DD HH:MM:SS
Example: 2025-10-26 23:27:25
```
### Boolean Values
Booleans are represented as:
- `true` (JSON boolean)
- `false` (JSON boolean)
### Null Values
Null values are represented as:
- `null` (JSON null)
---
## Error Handling
### HTTP Status Codes
| Status Code | Meaning | Description |
|------------|---------|-------------|
| `200` | OK | Request succeeded |
| `400` | Bad Request | Invalid request format or missing required fields |
| `401` | Unauthorized | Missing or invalid authentication |
| `404` | Not Found | Resource not found |
| `405` | Method Not Allowed | Invalid HTTP method |
| `500` | Internal Server Error | Server or database error |
### Error Response Format
All errors return a JSON object with an `error` field:
```json
{
"error": "Error message description"
}
```
### Common Errors
#### 1. Unauthorized (401)
**Cause:** Missing or incorrect authentication header
**Request:**
```bash
curl -X POST https://yalla-hack.ae/api/add_blog.php \
-H "Content-Type: application/json" \
-d '{"title":"Test","content":"Test"}'
```
**Response:**
```json
{
"error": "Unauthorized"
}
```
**Solution:** Add the authentication header: `admin: 11aa22ss`
---
#### 2. Missing Required Fields (400)
**Cause:** Missing `title` or `content` in request body
**Request:**
```bash
curl -X POST https://yalla-hack.ae/api/add_blog.php \
-H "Content-Type: application/json" \
-H "admin: 11aa22ss" \
-d '{"title":"Test"}'
```
**Response:**
```json
{
"error": "Missing required fields: title and content"
}
```
**Solution:** Include both `title` and `content` in request body
---
#### 3. Method Not Allowed (405)
**Cause:** Using wrong HTTP method
**Request:**
```bash
curl -X GET https://yalla-hack.ae/api/add_blog.php
```
**Response:**
```json
{
"error": "Only POST allowed"
}
```
**Solution:** Use correct HTTP method (POST for `add_blog.php`)
---
#### 4. Not Found (404)
**Cause:** Blog post with specified slug doesn't exist
**Request:**
```bash
curl https://yalla-hack.ae/api/get_blog.php?slug=non-existent-post
```
**Response:**
```json
{
"error": "Not found"
}
```
**Solution:** Verify the slug is correct
---
#### 5. Database Connection Failed (500)
**Cause:** Cannot connect to database
**Response:**
```json
{
"error": "Database connection failed"
}
```
**Solution:** Contact system administrator
---
## Rate Limiting
### Current Status
⚠️ **No rate limiting currently implemented**
The API does not currently enforce rate limits. However, please use the API responsibly:
- Avoid excessive requests
- Implement client-side caching
- Use appropriate delays between requests
- Don't perform bulk operations without planning
### Best Practices
**Recommended:**
- Cache `get_blogs.php` responses for 5-10 minutes
- Implement exponential backoff for failed requests
- Don't poll the API continuously
- Batch operations when possible
---
## Examples
### Example 1: Creating a Simple Blog Post
**Scenario:** Create a basic blog post with minimal fields
```bash
curl -X POST https://yalla-hack.ae/api/add_blog.php \
-H "Content-Type: application/json" \
-H "admin: 11aa22ss" \
-d '{
"title": "5 Essential Security Tips",
"content": "Here are 5 essential security tips every organization should follow:\n\n1. Use strong passwords\n2. Enable 2FA\n3. Keep software updated\n4. Regular backups\n5. Security training"
}'
```
**Response:**
```json
{
"success": true,
"id": 10,
"slug": "5-essential-security-tips"
}
```
---
### Example 2: Creating a Blog Post with HTML
**Scenario:** Create a rich blog post with HTML formatting
```bash
curl -X POST https://yalla-hack.ae/api/add_blog.php \
-H "Content-Type: application/json" \
-H "admin: 11aa22ss" \
-d '{
"title": "Understanding Zero-Day Vulnerabilities",
"content": "
What is a Zero-Day?
A zero-day vulnerability is a security flaw that is unknown to the software vendor...
Immediate threat
No patch available
High-value targets
",
"image_url": "https://images.unsplash.com/photo-1555949963-ff9fe0c870eb?w=800",
"author": "Dr. Sarah Ahmed",
"time_read": "15 min read"
}'
```
**Response:**
```json
{
"success": true,
"id": 11,
"slug": "understanding-zero-day-vulnerabilities"
}
```
---
### Example 3: Retrieving All Posts
**Scenario:** Get all blog posts for display on blog listing page
```bash
curl https://yalla-hack.ae/api/get_blogs.php
```
**Response:**
```json
[
{
"id": "11",
"title": "Understanding Zero-Day Vulnerabilities",
"slug": "understanding-zero-day-vulnerabilities",
"content": "