Supporting pages, examples and technical details in a cleaner layout.
Guide to make your first call to the Militant API.
curl https://your-instance.com/api/v1/
You should see the list of endpoints in JSON.
curl -X POST https://your-instance.com/api/v1/auth.php \
-H "Content-Type: application/json" \
-d '{
"username": "your_username",
"password": "your_password"
}'
Response:
{
"success": true,
"token": "abc123def456...",
"expires_at": "2026-03-04 12:00:00",
"user_id": 1
}
Copy the token, you'll need it for all following calls.
curl https://your-instance.com/api/v1/posts.php \
-H "Authorization: Bearer YOUR_TOKEN"
curl -X POST https://your-instance.com/api/v1/posts.php \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "My first post via the API!"
}'
curl https://your-instance.com/api/v1/users.php?username=your_username \
-H "Authorization: Bearer YOUR_TOKEN"
{
"success": false,
"error": "Invalid or expired token"
}
Solution: Login again to get a new token.
{
"success": false,
"error": "Rate limit exceeded"
}
Solution: Wait 1 hour or reduce the number of requests.