The Marvel Comics API allows developers everywhere to access information about Marvel's vast library of comics—from what's coming up, to 70 years ago. This Marvel API client helps you explore the Marvel universe with great ease.
- PHP 7.0.0
- Marvel API key
- Love for Marvel
Add the API client as a dependency to your project using Composer.
composer require ikoene/marvel-api-client
<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use ikoene\Marvel\Client;
$client = new Client('your_public_api_key', 'your_private_api_key');
$response = $client->getCharacter(1009610);
var_dump($response);
You can call every endpoint with an explicitly defined method. So if you, for example, want a list of comics containing a specific character, you can call getComicsForCharacter()
.
$response = $client->getComicsForCharacter(1009610);
It's also possible to add optional filters to the calls. Let's get all comics for 'Spider-Man' which title starts with 'Age of Ultron' and order the results by 'title'.
$comicFilter = new \ikoene\Marvel\Entity\ComicFilter();
$comicFilter->setTitleStartsWith('Age of Ultron');
$comicFilter->setOrderBy('title');
$response = $client->getComicsForCharacter(1009610, $comicFilter);
Pretty easy, right?
You can find some more examples here.