btafoya / mixpost-api
REST API add-on for Mixpost - enables n8n and external integrations
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/btafoya/mixpost-api
Requires
- php: ^8.2
- illuminate/contracts: ^10.47|^11.0
- laravel/sanctum: ^3.0|^4.0
Requires (Dev)
- inovector/mixpost: ^1.0
- laravel/pint: ^1.0
- orchestra/testbench: ^8.0|^9.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-laravel: ^2.0
- phpunit/phpunit: ^10.5
README
REST API extension for Mixpost - Enable powerful automation with n8n and external integrations
๐ About
Mixpost REST API is a powerful Laravel package that extends Mixpost with comprehensive REST API capabilities. Built specifically to enable seamless integration with workflow automation tools like n8n, this add-on transforms Mixpost into a fully API-driven social media management platform.
๐ฏ Perfect For
- Workflow Automation: Integrate with n8n, Zapier, Make.com
- Custom Applications: Build your own social media management tools
- AI-Powered Content: Auto-generate and publish content with AI services
- Content Pipelines: Automate blog-to-social workflows
- Team Collaboration: External tools can interact with Mixpost programmatically
- Scheduled Automation: Time-based social media campaigns
โจ Features
๐ API Coverage (v1.0.0)
- โ Posts Management: Full CRUD operations, scheduling, and publishing
- โ Media Handling: Upload files, download from URLs, manage library
- โ Account Management: List and manage social media accounts
- โ Tags & Organization: Create, update, delete tags
๐ฎ Planned Features (Future Releases)
- ๐ Analytics & Reports: Dashboard metrics, account stats, post performance
- ๐ Calendar Integration: View and manage scheduled content
- ๐ System Monitoring: Check status, queue health, service configuration
๐ Security & Performance
- โ Laravel Sanctum Authentication: Secure token-based API access
- โ Rate Limiting: Configurable request throttling (default: 60/min)
- โ Permission System: Token abilities for granular access control
- โ HTTPS Enforcement: Production-ready security
- โ IP Whitelisting: Optional IP restriction
- โ Input Validation: Comprehensive server-side validation
๐จ Developer Experience
- โ RESTful Design: Clean, predictable API structure
- โ JSON Responses: Consistent response formats
- โ Pagination: Efficient data handling for large datasets
- โ Error Handling: Detailed, actionable error messages
- โ Comprehensive Documentation: Full API specification and examples
- โ n8n Ready: Pre-built workflow examples included
๐ Requirements
- PHP: ^8.2
- Laravel: ^10.47 | ^11.0
- Mixpost: ^1.0 (installed automatically as dev dependency)
- Laravel Sanctum: ^3.0 | ^4.0
๐ Installation
Step 1: Install via Composer
composer require inovector/mixpost-api
Step 2: Publish Configuration (Optional)
php artisan vendor:publish --tag=mixpost-api-config
This creates config/mixpost-api.php where you can customize:
- API prefix
- Rate limiting
- Token expiration
- Security settings
- Pagination defaults
Step 3: Run Migrations
php artisan migrate
This creates the personal_access_tokens table for Laravel Sanctum.
Step 4: Update User Model
Add the HasApiTokens trait to your User model:
<?php namespace App\Models; use Illuminate\Foundation\Auth\User as Authenticatable; use Laravel\Sanctum\HasApiTokens; class User extends Authenticatable { use HasApiTokens; // ... rest of your model }
Step 5: You're Ready! ๐
Your Mixpost installation now has REST API endpoints available at:
https://your-domain.com/api/mixpost/*
๐ง Configuration
Environment Variables
Add to your .env file:
# API Configuration MIXPOST_API_RATE_LIMIT=60 MIXPOST_API_HTTPS_ONLY=true # Token Configuration MIXPOST_API_TOKEN_EXPIRATION=null # null = never expire
Configuration File
Edit config/mixpost-api.php:
return [ 'prefix' => 'api/mixpost', 'rate_limit' => [ 'enabled' => true, 'max_attempts' => env('MIXPOST_API_RATE_LIMIT', 60), 'decay_minutes' => 1, ], 'token' => [ 'expiration' => env('MIXPOST_API_TOKEN_EXPIRATION'), 'abilities_enabled' => true, ], 'pagination' => [ 'default_per_page' => 20, 'max_per_page' => 100, ], 'security' => [ 'ip_whitelist_enabled' => false, 'ip_whitelist' => [], 'https_only' => env('MIXPOST_API_HTTPS_ONLY', true), ], ];
๐ Quick Start Guide
1. Generate API Token
Using cURL:
curl -X POST https://your-domain.com/api/mixpost/auth/tokens \ -H "Content-Type: application/json" \ -d '{ "email": "admin@example.com", "password": "your-password", "token_name": "n8n-integration" }'
Response:
{
"token": "1|abc123def456ghi789jkl012mno345pqr678stu901vwx234yz",
"token_type": "Bearer",
"expires_at": null
}
2. Use Token in Requests
curl -X GET https://your-domain.com/api/mixpost/posts \ -H "Authorization: Bearer 1|abc123def456..." \ -H "Accept: application/json"
3. Create a Post
curl -X POST https://your-domain.com/api/mixpost/posts \ -H "Authorization: Bearer 1|abc123def456..." \ -H "Content-Type: application/json" \ -d '{ "accounts": [1, 2, 3], "tags": [1], "date": "2025-10-24", "time": "10:00", "versions": [ { "is_original": true, "account_id": null, "content": [ { "body": "Check out our latest blog post! ๐", "media": [] } ] } ] }'
๐ฏ API Endpoints Overview
Authentication
POST /api/mixpost/auth/tokens- Generate API tokenGET /api/mixpost/auth/tokens- List user tokensDELETE /api/mixpost/auth/tokens/{id}- Revoke token
Posts
GET /api/mixpost/posts- List posts (with filtering & pagination)POST /api/mixpost/posts- Create postGET /api/mixpost/posts/{id}- Get post detailsPUT /api/mixpost/posts/{id}- Update postDELETE /api/mixpost/posts/{id}- Delete postPOST /api/mixpost/posts/{id}/schedule- Schedule postPOST /api/mixpost/posts/{id}/publish- Publish immediatelyPOST /api/mixpost/posts/{id}/duplicate- Duplicate postDELETE /api/mixpost/posts- Bulk delete posts
Media
GET /api/mixpost/media- List media filesPOST /api/mixpost/media- Upload media filePOST /api/mixpost/media/download- Download from URLGET /api/mixpost/media/{id}- Get media detailsDELETE /api/mixpost/media/{id}- Delete media fileDELETE /api/mixpost/media- Bulk delete media
Accounts
GET /api/mixpost/accounts- List social media accountsGET /api/mixpost/accounts/{id}- Get account detailsPUT /api/mixpost/accounts/{id}- Update accountDELETE /api/mixpost/accounts/{id}- Delete account
Tags
GET /api/mixpost/tags- List tagsPOST /api/mixpost/tags- Create tagPUT /api/mixpost/tags/{id}- Update tagDELETE /api/mixpost/tags/{id}- Delete tag
๐ Full API Documentation: API_SPECIFICATION.md
Planned Endpoints (Future Releases)
Reports & Analytics
GET /api/mixpost/reports/dashboard- Dashboard summaryGET /api/mixpost/reports/accounts/{id}- Account analyticsGET /api/mixpost/reports/posts/{id}- Post performance
Calendar
GET /api/mixpost/calendar- Get scheduled posts
System Monitoring
GET /api/mixpost/system/status- System health check
๐ n8n Integration
Quick Setup
-
Create n8n Credential
- Type:
Header Auth - Name:
Authorization - Value:
Bearer YOUR_TOKEN_HERE
- Type:
-
Use HTTP Request Node
- Method:
POST - URL:
https://your-domain.com/api/mixpost/posts - Authentication: Use the credential from step 1
- Body: JSON with post data
- Method:
Example Workflows
๐ Auto-Post from Blog Publication
Webhook (Blog Published)
โ
Upload Featured Image
โ
Create Social Post
โ
Publish Immediately
๐ค AI Content Generation
Schedule Trigger (Daily 9am)
โ
OpenAI (Generate Content)
โ
DALL-E (Generate Image)
โ
Upload to Mixpost
โ
Create Scheduled Post
๐ Performance Monitoring
Schedule Trigger (Daily 6pm)
โ
Get Dashboard Stats
โ
Check for Failed Posts
โ
Send Slack Notification
๐ Complete n8n Examples: N8N_INTEGRATION_EXAMPLES.md
๐ Documentation
Core Documentation
- API Specification - Complete endpoint reference
- Authentication Guide - Laravel Sanctum setup
- n8n Integration - Workflow examples
- Implementation Plan - Package architecture
Example Use Cases
Use Case 1: Blog to Social Media
Automatically create social media posts when new blog articles are published.
Use Case 2: AI-Powered Content
Generate content with OpenAI and schedule posts across multiple platforms.
Use Case 3: Content Curation
Monitor RSS feeds and share relevant content automatically.
Use Case 4: Bulk Scheduling
Schedule multiple posts from CSV files or spreadsheets.
Use Case 5: Emergency Announcements
Publish urgent content immediately across all platforms.
๐งช Testing
Run Tests
# Run all tests composer test # Run with coverage composer test-coverage # Run specific test vendor/bin/pest tests/Feature/PostsApiTest.php
Example Test
public function test_can_create_post_via_api() { Sanctum::actingAs($this->user, ['*']); $response = $this->postJson('/api/mixpost/posts', [ 'accounts' => [1, 2], 'versions' => [ [ 'is_original' => true, 'content' => [ ['body' => 'Test post', 'media' => []] ] ] ] ]); $response->assertStatus(201) ->assertJsonStructure(['data', 'message']); }
๐ค Contributing
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
composer test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines
- Follow PSR-12 coding standards
- Write tests for new features
- Update documentation for API changes
- Keep backward compatibility when possible
- Add changelog entries for notable changes
Code Style
# Format code composer format # Check code style ./vendor/bin/pint --test
๐ Security Vulnerabilities
If you discover a security vulnerability, please send an email to security@example.com. All security vulnerabilities will be promptly addressed.
Do not open public issues for security vulnerabilities.
๐ Changelog
Please see CHANGELOG.md for recent changes.
Recent Updates
v1.0.0 (2025-10-23)
- Initial release
- Complete REST API for Mixpost
- Laravel Sanctum authentication
- n8n integration support
- Comprehensive documentation
๐ Credits
- Mixpost - The amazing social media management platform this extends
- Laravel - The PHP framework
- Laravel Sanctum - API authentication
- n8n - Workflow automation platform
Built With
- Laravel - Web application framework
- Laravel Sanctum - API token authentication
- Pest PHP - Testing framework
- Laravel Pint - Code style fixer
๐ License
The MIT License (MIT). Please see LICENSE.md for more information.
MIT License
Copyright (c) 2025 Your Name
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software...
๐ฌ Support
- Documentation: docs/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Mixpost Discord: Join Community
๐ Star History
If you find this package useful, please consider giving it a โญ on GitHub!
๐ Links
- Mixpost: https://mixpost.app
- Mixpost GitHub: https://github.com/inovector/mixpost
- Mixpost Documentation: https://docs.mixpost.app
- n8n: https://n8n.io
- Laravel: https://laravel.com
Made with โค๏ธ for the Mixpost community
Transform your social media management with powerful API automation