Introduction

This documentation will help you get familiar with the resources of the Rick and Morty API and show you how to make different queries, so that you can get the most out of it.

GraphQL

https://therickandmortyapi.vercel.app/graphql

query {
  episodes(page: 1, filter: { name: "Pickle" }) {
    info {
      prev
      next
      count
    }
    results {
      air_date
    }
  }
  location(id: 44) {
    dimension
    residents {
      name
    }
  }
  charactersByIds(ids: [118, 636]) {
    name
  }
}

New to GraphQL? read the docs

REST

Base url: https://therickandmortyapi.vercel.app/api

The base url contains information about all available API’s resources. All requests are GET requests and go over https. All responses will return data in json.

GET https://therickandmortyapi.vercel.app/api
{
  "character": "https://therickandmortyapi.vercel.app/api/character",
  "location": "https://therickandmortyapi.vercel.app/api/location",
  "episode": "https://therickandmortyapi.vercel.app/api/episode"
}

There are currently three available resources:

  • Character: used to get all the characters.
  • Location: used to get all the locations.
  • Episode: used to get all the episodes.

Query Filters

You can also include filters in the URL by including additional query parameters. To start filtering add a ? followed by the query <query>=<value>. If you want to chain several queries in the same call, use & followed by the query.

For example, in the Characters resource if you want to check how many alive Ricks exist, just add ?name=rick&status=alive to the URL.

GET https://therickandmortyapi.vercel.app/api/character?name=rick&status=alive
{
  "info": {
    "count": 29,
    "pages": 2,
    "next": "https://therickandmortyapi.vercel.app/api/character?name=rick&status=alive&page=2",
    "prev": null
  },
  "results": [
    {
      "id": 1,
      "name": "Rick Sanchez",
      "status": "Alive",
      "species": "Human",
      "type": "",
      "gender": "Male",
      "location": {
        "name": "Citadel of Ricks",
        "url": "https://therickandmortyapi.vercel.app/api/location/3"
      },
      "origin": {
        "name": "Earth (C-137)",
        "url": "https://therickandmortyapi.vercel.app/api/location/1"
      },
      "image": "https://therickandmortyapi.vercel.app/api/character/avatar/1.jpeg",
      "episode": [
        "https://therickandmortyapi.vercel.app/api/episode/1"
        // ...
      ],
      "url": "https://therickandmortyapi.vercel.app/api/character/1",
      "created": "2017-11-04T13:48:46.250Z"
    }
    // ...
  ]
}

Check the available parameters and their accepted values for every API resource:

Info and Pagination

The API will automatically paginate the responses. You will receive up to 20 documents per page.

Each resource contains an info object with information about the response.

KeyTypeDescription
countintThe length of the response
pagesintThe amount of pages
nextstring (url)Link to the next page (if it exists)
prevstring (url)Link to the previous page (if it exists)
GET https://therickandmortyapi.vercel.app/api/character
{
  "info": {
    "count": 826,
    "pages": 42,
    "next": "https://therickandmortyapi.vercel.app/api/character?page=2",
    "prev": null
  },
  "results": [
    // ...
  ]
}

You can access different pages with the page parameter. If you don’t specify any page, the first page will be shown. For example, in order to access page 2, add ?page=2 to the end of the URL.

GET https://therickandmortyapi.vercel.app/api/character?page=40
{
  "info": {
    "count": 826,
    "pages": 42,
    "next": "https://therickandmortyapi.vercel.app/api/character?page=41",
    "prev": "https://therickandmortyapi.vercel.app/api/character?page=39"
  },
  "results": [
    {
      "id": 781,
      "name": "Rick's Garage",
      "status": "Alive",
      "species": "Robot",
      "type": "Artificial Intelligence",
      "gender": "Female",
      "location": {
        "name": "Earth (Replacement Dimension)",
        "url": "https://therickandmortyapi.vercel.app/api/location/20"
      },
      "origin": {
        "name": "Earth (Replacement Dimension)",
        "url": "https://therickandmortyapi.vercel.app/api/location/20"
      },
      "image": "https://therickandmortyapi.vercel.app/api/character/avatar/781.jpeg",
      "episode": ["https://therickandmortyapi.vercel.app/api/episode/49"],
      "url": "https://therickandmortyapi.vercel.app/api/character/781",
      "created": "2021-10-25T04:18:48.188Z"
    }
    // ...
  ]
}