dant89 / smite-api-php-client
A lightweight PHP client for Smite API
Installs: 58
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 1
pkg:composer/dant89/smite-api-php-client
Requires
- symfony/http-client: ^5.0
Requires (Dev)
- phpmd/phpmd: ^2.7
- phpunit/phpunit: ^8.4
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2025-11-13 18:41:45 UTC
README
Smite API PHP Client
A lightweight PHP client for the Smite developer API.
Installation
To install, run composer require dant89/smite-api-php-client in the root of your project or add dant89/smite-api-php-client to your composer.json.
"require": { "dant89/smite-api-php-client": REPLACE_WITH_VERSION }
Smite developer API Documentation
To read more about how the Smite developer API functions, please read the official documentation.
Smite developer API Access
The Smite developer API requires that you first complete this form to apply for credentials.
If your application is accepted you will receive custom credentials to access the API.
- Smite
Usage
Use your provided DevId and AuthKey upon instantiation of this client.
use Dant89\SmiteApiClient\Client; // Create base client $smiteClient = new Client(SMITE_DEV_ID, SMITE_AUTH_KEY);
To begin using the API, you will first need to establish a valid Session. To do so you will start a session (via the createsession method) and receive a SessionId. Sessions are used for authentication, security, monitoring, and throttling. Once you obtain a SessionId, you will pass it to other methods for authentication. Each session only lasts for 15 minutes and must be recreated afterward.
- Smite
// Get a session_id from a signed authentication request $authClient = $smiteClient->getHttpClient('auth'); $timestamp = date('omdHis'); $response = $authClient->createSession($timestamp); // Check for valid response status if ($response->getStatus() === 200) { $sessionId = $response->getContent()['session_id']; }
Now that you have a $sessionId you are free to make calls to the other client methods. This client takes care of signing the requests so you don't need to worry about that and can now make calls to other methods, for example to get a teams (clans) players, you would use:
$clanId = 123; $teamClient = $smiteClient->getHttpClient('team'); $response = $teamClient->getTeamPlayers($clanId, $sessionId, $timestamp); $teamPlayers = []; if ($response->getStatus() === 200) { $teamPlayers = $response->getContent(); }
Rate Limiting / Caching Suggestion
I recommend that you implement some sort of caching of your $sessionId and / or returned data, the Smite developer API has rate limits so caching will help you avoid going over those limits:
Default limits:
concurrent_sessions: 50
sessions_per_day: 500
session_time_limit: 15 minutes
request_day_limit: 7500
Helpers
languageCode values:
1English2German3French5Chinese7Spanish9Spanish (Latin America)10Portuguese11Russian12Polish13Turkish
Tests
You can test your API key by running the PHPUnit tests included in this client.
At present there is no rate limiting or caching so a run through will use 7 of your daily sessions (this is not ideal).
PHPUnit tests:
- Add your
devIdandauthKeytotests/Helper/ClientTestCase.php php vendor/phpunit/phpunit/phpunit tests
PHP CodeSniffer:
php vendor/squizlabs/php_codesniffer/bin/phpcs src --standard=PSR2 --severity=5 --extensions=php
PHP MessDetector
php vendor/phpmd/phpmd/src/bin/phpmd src text controversial,unusedcode,design
Contributions
Contributions to the client are welcome, to contribute please:
- Fork this repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new pull request
