Download the PHP package nickbeen/rick-and-morty-api-php without Composer

On this page you can find all versions of the php package nickbeen/rick-and-morty-api-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package rick-and-morty-api-php

The Rick and Morty API - PHP Client

Latest version Build status Total downloads PHP Version License

An API wrapper written in PHP for the Rick and Morty API at https://rickandmortyapi.com.

Get all the information about characters, episodes and locations of Rick and Morty with this PHP client without messing around with Curl calls and JSON responses. This library does not return the same JSON provided by the API, but wraps everything in convenient PHP class objects. The Rick and Morty API is made by Axel Fuhrmann.

Requirements

Installation

Install the library into your project with Composer.

Usage

Initiate a Character, Episode or Location model and use the available tools to list, retrieve or search within that model. The library returns a NotFoundException when using invalid arguments, retrieving nonexistent models or if the Rick and Morty API is not available. Implement a try block to handle the exception in your application in the best possible way.

Collections

Requests for all characters, episodes and locations as well as queries with search parameters will return a Collection object containing an array with results.

Collection object

Field Type Description
info Info Information about the collection
results Location[] Array containing characters, episodes or locations

Info object

Field Type Description
count integer The length of the response
pages integer The amount of pages
next ?string Link to the next page (if it exists)
prev ?string Link to the previous page (if it exists)

Usage

For instructions for the usage of collections, check the sections Locations for more details and examples.

Api

This library contains a useful method to return all the endpoints of the Rick and Morty API in an Api object.

Api object

Field Type Description
characters string Endpoint used for retrieving characters
episodes string Endpoint used for retrieving episodes
locations string Endpoint used for retrieving locations

Usage

Retrieve an Api object containing the endpoints for retrieving characters, episodes and locations.

Characters

Retrieve any character from Rick and Morty, browse through all the characters or use search parameters to find a specific character.

Character object

Field Type Description
id integer The id of the character
name string The name of the character
status string The status of the character
species string The species of the character
type string The type or subspecies of the character
gender string The gender of the character
origin Origin Name and link to the character's origin location endpoint
location Location Name and link to the character's last known location endpoint
image string Link to the character's image
episode string[] List of episodes in which this character appeared
url string Link to the character's own URL endpoint
created string Time at which the character was created in the database

Origin object

Field Type Description
name string The name of the character
url string Url to the character's last known location endpoint

Location object

Field Type Description
name string The name of the character's origin location
url string Url to the character's origin location endpoint

List characters

Retrieve a Collection object with next 20 characters from the first page.

Retrieve a Collection object with next 20 characters from the second page.

Get character

Retrieve a Character object with id 1.

Get multiple characters

Retrieve an array containing Character objects with id 1 and 2.

Search characters

It is possible to search for characters based on search parameters such as species and name. For gender and status you can use a Gender enum object and Status enum object for auto-completion in an IDE.

Method Type Description
withGender Gender Filter by given gender
withName string Filter by given name
withSpecies string Filter by given species
withStatus Status Filter by given status
withType string Filter by given type

Gender object

Field Type Description
Gender::Female string Female
Gender::Genderless string Genderless
Gender::Male string Male
Gender::Unknown string Unknown

Status object

Field Type Description
Status::Alive string Alive
Status::Dead string Dead
Status::Unknown string Unknown

Retrieve a Collection with all alive male Ricks.

Episodes

Retrieve any episode from Rick and Morty, browse through all the episodes or use search parameters to find a specific episode.

Episode object

Field Type Description
id integer The id of the episode
name string The name of the episode
air_date string The air date of the episode
episode string The code of the episode
characters string[] List of characters who have been seen in the episode
url string Link to the episode's own URL endpoint
created string Time at which the episode was created in the database

List episodes

Retrieve a Collection object with first 20 episodes from the first page.

Retrieve a Collection object with next 20 episodes from the second page.

Get episode

Retrieve an Episode object with id 1.

Get multiple episodes

Retrieve an array containing Episode objects with id 1 and 2.

Search episodes

It is possible to search for episodes based on search parameters such as episode code (e.g. S01E01) and name.

Method Type Description
withEpisode string Filter by given episode code
withName string Filter by given name

Retrieve a Collection object with all episodes from season 1.

Locations

Retrieve any location from Rick and Morty, browse through all the featured locations or use search parameters to find a specific location.

Location object

Field Type Description
id integer The id of the location
name string The name of the location
type string The type of the episode
dimension string The dimension in which the location is located
residents string[] List of characters who have been seen in the location
url string Link to the location's own URL endpoint
created string Time at which the location was created in the database

List locations

Retrieve a Collection object with first 20 locations from the first page.

Retrieve a Collection object with next 20 locations from the second page.

Get location

Retrieve a Location object with id 1.

Get multiple locations

Retrieve an array containing Location objects with id 1 and 2.

Search locations

It is possible to search for locations based on search parameters such as dimension and name.

Method Type Description
withDimension string Filter by given dimension
withName string Filter by given name
withType string Filter by the given type

Retrieve a Collection object with all locations within dimension C-137.

FAQ

What are the limits of the API?

The API is open and requires no authentication. According to the R implementation Mortyr, the API allows 10.000 requests per IP address per day after which any request will result in a 429 (Too Many Requests) response.

Can I get more than 20 results per page in a Collection?

The API returns 20 results per page by design and this cannot be adjusted. It is however possible to return more than 20 results by manually inserting more than 20 ids in the get() method.

How about extra filters?

Not possible, this library already offers all the available filters currently provided by the API.

Why is the code of the episode called episode in the Episode model?

It looks like an oopsie from the creator of the Rick And Morty API. There is an unresolved pull request to rename the field to code.

License

This library is licensed under the MIT License (MIT). See the LICENSE for more details.


All versions of rick-and-morty-api-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
guzzlehttp/guzzle Version ^7.4
netresearch/jsonmapper Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nickbeen/rick-and-morty-api-php contains the following files

Loading the files please wait ....