Socket
Socket
Sign inDemoInstall

rickmortyapi

Package Overview
Dependencies
1
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rickmortyapi

A Rick and Morty API Node wrapper


Version published
Weekly downloads
47
decreased by-16.07%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Build Status Coverage Status npm version npm downloads

The Rick and Morty API JavaScript client

Hey, did you ever want to hold a terry fold?, I got one right here, grab my terry flap.

This is a Node wrapper to use the The Rick and Morty API in your favourite JavaScript project.

To get started check the documentation on rickandmortyapi.com

Installation

npm i rickmortyapi or yarn add rickmortyapi

Usage

import { getCharacter } from 'rickmortyapi' // getCharacter()
// or
import shlaami from 'rickmortyapi' // shlaami.getCharacter()
// or
const tinyRick = require('rickmortyapi')
// You can use the name that you desire,
// You could name it Plumbus for instance,
// because a Plumbus will provide you with a lifetime of better living and happiness.

All methods return a promise.

  • getCharacter()
  • getEpisode()
  • getLocation()

All the methods work in the same way. The only exception is the queries that you can pass as ab object to each method.

To know more about the schema of each response, please check here

Get by ID

const rick = await getCharacter(1)
const earth = await getLocation(1)
const episodeOne = await getEpisode(1)

// You can also use an array of IDs.
const theSmiths = await getCharacter([ 2, 3, 4, 5 ])
const [ earth, citadel ] = await getLocation([ 1, 3 ])
const s01 = await getEpisode(Array.from({ length: 11 }, (v, i) => i + 1))

Filter

Pass an object with the queries. To know more about filtering check the docs.

const aliveRicks = await getCharacter({
  name: 'rick',
  status: 'alive'
})

// You can pass page number inside the object
const planets = await getLocation({
  type: 'planet',
  page: 2
})

const seasonOne = await getEpisodes({
  episode: 's01'
})

Get all

const chars = await getCharacter()
const locations = await getLocation()
const episodes = await getEpisode()

// You can pass a page number to access all the pages inside the info objecy
// To know more about the info object and pagination, check
// https://rickandmortyapi.com/documentation/#info-and-pagination
const moreChars = await getCharacter({ page: 2})
  • getEndpoints()

This method will response with the available endpoints, you can use it to ping the server status.

Keywords

FAQs

Last updated on 30 Apr 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc