No, the API must be deployed separately. It's not included in the default Militant installation.
Yes, create an /api/.env file with your Militant instance credentials:
API_DB_HOST=your-militant-db
API_DB_NAME=militant
API_DB_USER=militant
API_DB_PASS=your_password
See Installation for Docker or CasaOS guides.
curl -X POST https://your-instance.com/api/v1/auth.php \
-H "Content-Type: application/json" \
-d '{"username": "user", "password": "pass"}'
30 days. After expiration, login again to get a new one.
Yes, each login creates a new token. All remain valid until expiration.
curl -X POST https://your-instance.com/api/v1/auth.php?action=revoke \
-H "Content-Type: application/json" \
-d '{"token": "your_token"}'
100-200 requests per hour depending on the endpoint.
curl -X POST https://your-instance.com/api/v1/upload.php \
-H "Authorization: Bearer TOKEN" \
-F "media=@photo.jpg" \
-F "type=posts"
Add ?page=2&limit=20 to your GET requests.
Yes, CORS is enabled by default for all domains.
Your token has expired. Login again to get a new one.
You've exceeded the request limit. Wait 1 hour.
Check the configuration in /api/.env or MySQL credentials.
You're using the wrong HTTP method (GET instead of POST, etc.)
In the api_tokens table of the Militant database.
Yes, in api/config.php: 'token_lifetime' => 2592000 (in seconds)
Yes, in api/config.php: 'rate_limit_enabled' => false
Yes: SHA-256 tokens, rate limiting, data validation, CSRF protection.
Yes, strongly recommended to protect tokens in transit.
CREATE USER 'api_user'@'%' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE ON militant.* TO 'api_user'@'%';
Yes: Python and JavaScript SDKs are available.
Yes, use docker-compose.yml in the /api/ folder.
In /api/.env: API_DEBUG=true
docker logs militant-api -f
Not yet, but it's planned. Currently: simple Bearer tokens.
Yes, under AGPL-3.0 license.
See the GitLab repository: https://gitlab.com/militant1/millitant
On GitLab: https://gitlab.com/militant1/millitant/issues