Class craft\services\Api
- Inheritance
- craft\services\Api » yii\base\Component » yii\base\BaseObject
- Implements
- yii\base\Configurable
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/services/Api.php
The API service provides APIs for calling the Craft API (api.craftcms.com).
An instance of the API service is globally accessible in Craft via Craft::$app->api
.
Property | Type | Description | Defined By |
---|---|---|---|
$client |
\GuzzleHttp\Client | craft\services\Api |
Method | Description | Defined By |
---|---|---|
__call() |
Calls the named method which is not a class method. | yii\base\BaseObject |
__clone() |
This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() |
Constructor. | yii\base\BaseObject |
__get() |
Returns the value of an object property. | yii\base\BaseObject |
__isset() |
Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() |
Sets value of an object property. | yii\base\BaseObject |
__unset() |
Sets an object property to null. | yii\base\BaseObject |
attachBehavior() |
Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() |
Attaches a list of behaviors to the component. | yii\base\Component |
behaviors() |
Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() |
Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() |
Returns a value indicating whether a property can be set. | yii\base\BaseObject |
checkout() |
Order checkout. | craft\services\Api |
className() |
Returns the fully qualified name of this class. | yii\base\BaseObject |
detachBehavior() |
Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() |
Detaches all behaviors from the component. | yii\base\Component |
ensureBehaviors() |
Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
getBehavior() |
Returns the named behavior object. | yii\base\Component |
getBehaviors() |
Returns all behaviors attached to this component. | yii\base\Component |
getCountries() |
Returns all country data. | craft\services\Api |
getDeveloper() |
Returns the developer details. | craft\services\Api |
getLicenseInfo() |
Returns info about the current Craft license. | craft\services\Api |
getOptimizedComposerRequirements() |
Returns optimized Composer requirements based on what’s currently installed, and the package requirements that should be installed. | craft\services\Api |
getPluginDetails() |
Returns the plugin details. | craft\services\Api |
getPluginStoreData() |
Returns plugins data for the Plugin Store. | craft\services\Api |
getUpdates() |
Checks for Craft and plugin updates. | craft\services\Api |
hasEventHandlers() |
Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() |
Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() |
Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() |
Initializes the object. | craft\services\Api |
off() |
Detaches an existing event handler from this component. | yii\base\Component |
on() |
Attaches an event handler to an event. | yii\base\Component |
request() |
craft\services\Api | |
trigger() |
Triggers an event. | yii\base\Component |
Method | Description | Defined By |
---|---|---|
cmsLicenseKey() |
craft\services\Api | |
headers() |
Returns the headers that should be sent with API requests. | craft\services\Api |
platformVersions() |
Returns platform info. | craft\services\Api |
Property Details
$client
public property
#
public \GuzzleHttp\Client $client = null
Method Details
checkout()
public method
#
Order checkout.
public array checkout ( array $order )
$order |
array | |
throws | \GuzzleHttp\Exception\RequestException | if the API gave a non-2xx response |
---|
cmsLicenseKey()
protected method
#
protected string, null cmsLicenseKey ( )
getCountries()
public method
#
Returns all country data.
public array getCountries ( )
throws | \GuzzleHttp\Exception\RequestException | if the API gave a non-2xx response |
---|
getDeveloper()
public method
#
Returns the developer details.
public array getDeveloper ( \craft\services\int $developerId )
$developerId |
integer | |
throws | \GuzzleHttp\Exception\RequestException | if the API gave a non-2xx response |
---|
getLicenseInfo()
public method
#
Returns info about the current Craft license.
public array getLicenseInfo ( )
throws | \GuzzleHttp\Exception\RequestException | if the API gave a non-2xx response |
---|
getOptimizedComposerRequirements()
public method
#
Returns optimized Composer requirements based on what’s currently installed, and the package requirements that should be installed.
public array getOptimizedComposerRequirements ( array $install )
$install |
array | Package name/version pairs to be installed |
throws | \GuzzleHttp\Exception\RequestException | if the API gave a non-2xx response |
---|---|---|
throws | yii\base\Exception | if composer.json can't be located |
getPluginDetails()
public method
#
Returns the plugin details.
public array getPluginDetails ( \craft\services\int $pluginId )
$pluginId |
integer | |
throws | \GuzzleHttp\Exception\RequestException | if the API gave a non-2xx response |
---|
getPluginStoreData()
public method
#
Returns plugins data for the Plugin Store.
public array getPluginStoreData ( )
throws | \GuzzleHttp\Exception\RequestException | if the API gave a non-2xx response |
---|
getUpdates()
public method
#
Checks for Craft and plugin updates.
public array getUpdates ( )
throws | \GuzzleHttp\Exception\RequestException | if the API gave a non-2xx response |
---|
headers()
protected method
#
Returns the headers that should be sent with API requests.
protected array headers ( )
init()
public method
#
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
public void init ( )
platformVersions()
protected method
#
Returns platform info.
protected array platformVersions ( \craft\services\bool $useComposerOverrides = false )
$useComposerOverrides |
boolean | Whether to factor in any config.platform overrides
|
request()
public method
#
public \Psr\Http\Message\ResponseInterface request ( \craft\services\string $method, \craft\services\string $uri, array $options = [] )
$method |
string | |
$uri |
string | |
$options |
array | |
throws | \GuzzleHttp\Exception\RequestException |
---|