Download the PHP package automattic/akismet-sdk without Composer
On this page you can find all versions of the php package automattic/akismet-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download automattic/akismet-sdk
More information about automattic/akismet-sdk
Files in automattic/akismet-sdk
Package akismet-sdk
Short Description Official PHP SDK for the Akismet spam protection service
License GPL-2.0-or-later
Homepage https://akismet.com
Informations about the package akismet-sdk
Akismet PHP SDK
Official PHP SDK for the Akismet spam protection service by Automattic.
Note: This SDK is for non-WordPress PHP applications. WordPress sites should use the official Akismet plugin.
Requirements
- PHP 8.1 or higher
- A PSR-18 HTTP client (e.g., Guzzle, Symfony HttpClient)
Installation
If you don't have a PSR-18 HTTP client installed, add one:
Quick Start
How It Works
Features
- Full support for Akismet API 1.1 and 1.2 endpoints
- PSR-18 HTTP client compatibility (works with Guzzle, Symfony, etc.)
- Immutable, type-safe DTOs
- Native PHP 8.1 enums for content types and verdicts
- Built-in test mode for development
API Methods
| Method | Description |
|---|---|
verifyKey() |
Verify your API key is valid |
check($content) |
Check if content is spam |
submitSpam($content) |
Report missed spam (false negative) |
submitHam($content) |
Report false positive |
getSubscription() |
Get subscription / account plan information |
getStats($interval) |
Get historical spam/ham statistics and breakdown |
getUsageLimit() |
Get API usage stats and limits |
getExtendedUsageLimit() |
Get usage stats with notice level and upgrade recommendation |
getKeySites() |
Get sites using your API key (JSON format only; CSV is not supported) |
getAccessToken() |
Exchange API key for a scoped access token (stats pages only, not for API calls) |
Integration Identification
If you're building a framework integration (Drupal, Laravel, Symfony, etc.), identify your integration via applicationUserAgent. This is prepended to the SDK's User-Agent header so Akismet can track compatibility and usage:
Framework Integration
Use ContentFactory to create Content objects from PSR-7 requests with automatic IP and user agent extraction:
Trusted Proxies
By default, ContentFactory::fromRequest() uses REMOTE_ADDR as the client IP. If your application runs behind a reverse proxy or load balancer, pass the proxy IPs to trust forwarded headers (X-Forwarded-For, X-Real-IP, CF-Connecting-IP, True-Client-IP):
Submitting Feedback
Help improve Akismet's accuracy by reporting mistakes:
Error Handling
All SDK exceptions implement AkismetException, so you can catch everything with a single type:
| Exception | When |
|---|---|
InvalidApiKeyException |
API key is invalid or revoked |
ValidationException |
Invalid input (e.g., bad IP address, malformed month format) |
ClientErrorException |
HTTP 4xx client errors (excluding 429) |
RateLimitException |
HTTP 429 — too many requests |
NetworkException |
Connection failures or DNS resolution errors |
ServerException |
HTTP 5xx or unexpected API response body |
API keys are automatically redacted from exception messages to prevent credential leakage in logs.
Testing
Use test mode during development to avoid affecting your accuracy metrics:
In test mode:
[email protected]as author email returns spamakismet-guaranteed-spamas author name returns spam- Normal content returns ham
Documentation
License
GPL-2.0-or-later
All versions of akismet-sdk with dependencies
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
php-http/discovery Version ^1.14