Skip to content

DataDragonAPI: How to begin

Daniel Dolejška edited this page Feb 24, 2020 · 5 revisions

Version v3.0.0-rc.1

First, you need to initialize the library - there are a few ways to do that:

Whole point of the library's initialization is to set DataDragon version, which is required in most of asset URLs.

initialize by CDN version fetch

use RiotAPI\DataDragonAPI\DataDragonAPI;

DataDragonAPI::initByCdn($settings);
// or just
DataDragonAPI::initByCdn();

$settings is an array with custom library settings.

This method fetches list of versions from DataDragon API and selects the latest one.

This method makes file_get_contents request which consumes time.

initialize by region-specific CDN version fetch

use RiotAPI\DataDragonAPI\DataDragonAPI;

DataDragonAPI::initByRegion($region_name, $settings);
// or just
DataDragonAPI::initByRegion($region_name);

$region_name is a string constant from RiotAPI\Definitions\Region.

$settings is an array with custom library settings.

This method fetches region specific version data from DataDragon API and selects the latest one.

This method makes file_get_contents request which consumes time.

initialize by static version

use RiotAPI\DataDragonAPI\DataDragonAPI;

DataDragonAPI::initByVersion($version, $settings);
// or just
DataDragonAPI::initByVersion($version);

$version is a string containing required DataDragon CDN version. (eg. "8.2.1" or "7.23.1" ...)

$settings is an array with custom library settings.

This method saves provided version and makes no requests.

initialize by RiotAPI static-data call

use RiotAPI\DataDragonAPI\DataDragonAPI;

DataDragonAPI::initByApi($api, $settings);
// or just
DataDragonAPI::initByApi($api);

$api is an instance of RiotAPI\RiotAPI.

$settings is an array with custom library settings.

This method makes one static-data request through RiotAPI. Requires valid API key.

This method makes file_get_contents request which consumes time.

initialize by RiotAPI StaticRealmDto object

use RiotAPI\DataDragonAPI\DataDragonAPI;

DataDragonAPI::initByRealmObject($realm, $settings);
// or just
DataDragonAPI::initByRealmObject($realm);

$realm is an instance of RiotAPI\Objects\StaticData\StaticRealmDto.

$settings is an array with custom library settings.

This method uses an existing StaticRealmDto object to initialize version and CDN link. Makes no requests.

Library settings

Library settings key Value Description
DataDragonAPI::SET_ENDPOINT string default "http://ddragon.leagueoflegends.com/cdn/" DataDragon CDN URL. You can use local DD files.
DataDragonAPI::SET_VERSION string DataDragon CDN version.
DataDragonAPI::SET_CUSTOM_IMG_ATTRS array Array containing custom attributes for every created <img> tag.
DataDragonAPI::SET_DEFAULT_CLASS string default "dd-icon" Default class for all <img> tags.
DataDragonAPI::SET_PROFILE_ICON_CLASS string default "dd-icon-profile" Default class for profile icon <img> tags.
DataDragonAPI::SET_MASTERY_ICON_CLASS string default "dd-icon-mastery" Default class for mastery icon <img> tags.
DataDragonAPI::SET_RUNE_ICON_CLASS string default "dd-icon-rune" Default class for rune icon <img> tags.
DataDragonAPI::SET_CHAMP_SPLASH_CLASS string default "dd-splash" Default class for champion splash art <img> tags.
DataDragonAPI::SET_CHAMP_LOADING_CLASS string default "dd-loading" Default class for champion loading <img> tags.
DataDragonAPI::SET_CHAMP_ICON_CLASS string default "dd-icon-champ" Default class for champion icon <img> tags.
DataDragonAPI::SET_SPRITE_CLASS string default "dd-sprite" Default class for sprite <img> tags.
DataDragonAPI::SET_SPELL_ICON_CLASS string default "dd-icon-spell" Default class for spell icon <img> tags.
DataDragonAPI::SET_ITEM_ICON_CLASS string default "dd-icon-item" Default class for item icon <img> tags.
DataDragonAPI::SET_UI_ICON_CLASS string default "dd-icon-ui" Default class for UI icon <img> tags.
DataDragonAPI::SET_MINIMAP_CLASS string default "dd-minimap" Default class for minimap <img> tags.