Skip to content

A very simple little package that talks to the Superheros API (https://superheroapi.com/), created as part of my learning to create packages for Laravel.

Notifications You must be signed in to change notification settings

dstuchbury/laravel-superheros

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Superheros

A very simple little package that talks to the Superheros API (https://superheroapi.com/), created as part of my learning to create packages for Laravel.

Installation

Run composer require aschmelyun/quickmetrics-laravel from your Laravel application root. Once that's finished, you'll need to open up your .env file and add the following to the bottom:

SUPERHERO_API_KEY={your-api-key} Optionally: You can publish the config file from the package by running:

php artisan vendor:publish --provider="Danstuchbury\Superheros\SuperheroServiceProvider"

Usage

This packages exposes a superheros() method.

superhero()->search({'name'}) where name is a URL safe string.

This will return a JSON object as follows:

{
    "success": true,
    "count": 2,
    "result": [
        {
            "id": "195",
            "name": "Cyborg Superman"
        },
        {
            "id": "644",
            "name": "Superman"
        }
    ]
}

On error, the "success" will be false and there will be an "error" element containing the error as a string. You can handle this as you see fit.

Retrieve full details of a found superhero using superheros()->getById({id}).

Retieve Power Stats using superheros()->stats({id})

Contributing

Contributions are welcome. Feel free to submit a Pull Request.

About

A very simple little package that talks to the Superheros API (https://superheroapi.com/), created as part of my learning to create packages for Laravel.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages