Giter Site home page Giter Site logo

afuh / rick-and-morty-api Goto Github PK

View Code? Open in Web Editor NEW
955.0 21.0 113.0 29.48 MB

The Rick and Morty API

Home Page: https://rickandmortyapi.com/

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%
api rick-and-morty rickandmorty rest-api graphql-api graphql

rick-and-morty-api's Introduction

The Rick and Morty API

The Rick and Morty API

Tests Coveralls github branch Twitter Follow

The Rick and Morty API is a RESTful and GraphQL API based on the television show Rick and Morty. You will access to data about hundreds of characters, images, locations and episodes. The Rick and Morty API is filled with canonical information as seen on the TV show.

Getting Started

Check out the documentation to get started

JavaScript client

The Rick and Morty API JavaScript client is a fully typed client that gives you access to the API and its features.

Community libraries

API collections

Website

You can check the code of the website here

Support

Help to maintain The Rick and Morty API's infrastructure.

If you want to know more about The Rick and Morty API click here.

rick-and-morty-api's People

Contributors

dependabot[bot] avatar ey-jay avatar filfreire avatar nickbeen avatar yash-garg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rick-and-morty-api's Issues

Ability to give more than one option to filter option in graphql

I used your GraphQL api in my project and it worked well and was fun to work on.

I think it would be better if filter options when querying characters can be an array of Strings or a String (which is what is currently implemented in your API.) An array of Strings will return characters with either of the options. For instance { gender: ["Male", "Female"] } returns characters who are either male or female. Something like this:

screenshot

I'd love this because my filters currently done with JavaScript filtering more resembles that it than just a String. And I think it is overkill to have to use JavaScript filters to achieve it. Usually graphql apis allow arrays as option params in this way.

My implementation using your graphql API is live here: https://bit.ly/rick-and-morty-search

Excellent work 🍸 ✨

No result from graphql endpoint

Hello,

In case you didn't know already, graphql is returning nulls :'(

  "data": {
    "characters": {
      "info": {
        "count": null
      },
      "results": null
    },
    "episode": {
      "id": null
    }
  }
}

Feel free to close this issue, I just wanted to let you know about this.

CORS issue

I know this has happened before, but i cant even make a request both with Axios or Fetch.

I have read that this had been fixed before. I'm getting my requests blocked. Is there anything I am missing?

I am trying with

axios.get(`https://rickandmortyapi.com/api/`)

Cannot access pages

I tried to access pages from 2-9 but it returns the same Page-1 JSON objects

Mutations / Updates

I am new to GraphQL and would like to practice mutations, I understand how this may not be practical for the version of the app that you host, but it would be awesome if the source code would allow mutations if you wanted to self host it and practice using GraphQL?

Perhaps it could be configurable somewhere to allow mutations?

What are you thoughts on this?

CORS issue with GraphQL endpoint

hey @afuh , I'm trying to use the graphql endpoint but I'm getting rejected by CORS.

I tried with both ApolloLink and plain fetch:

Apollo

import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { HttpLink } from 'apollo-link-http';
import gql from 'graphql-tag';

const cache = new InMemoryCache();
const link = new HttpLink({
    uri: 'https://rickandmortyapi.com/graphql/',
});

const client = new ApolloClient({
    cache,
    link,
});

    client.query({
        query: gql`
            query {
                characters(page: 1) {
                    results {
                        name
                    }
                }
            }
        `,
    })

Vainilla

fetch('https://rickandmortyapi.com/graphql/', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        query: `
            characters(page: 1) {
                results {
                    name
                }
            }
        `,
    }),
});

Both are running in a minimal, parcel server, localhost:3000, and the response is:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://rickandmortyapi.com/graphql/. (Reason: CORS request did not succeed).

Expected Iterable, but did not find one for field Character.episode error

Greetings!

I am trying to create a GraphQL client application for this cool API. Nearly everything is going as it should be but when I try to query some of the characters with episode field, I got an error. One of the example queries that I tried on the GraphQL Playground is like this;

query { character(id: 8) { id name episode { id name air_date } } }

And it throws this error;
Expected Iterable, but did not find one for field Character.episode error

Even though some characters cause this error, some of them don't. For example when the id is 1 or 2 there is no problem.

It is really fun to work with this API and if you can fix this error any time, it would be really cool.

Cheers

api down after http request

im not an expert, but i made a sample vue app using this api, and i do not have https certificate on my production servers, and after first request api is down.

this also can be caused due to my programming skills ;)

rmdb.flipendo.pl

you can test it here..

Status standars

En los diferentes status esta Alive con A, Dead con D pero Unknown con "u" unknown en la respueta de la API.

Deprecate the `episode` field in Episode model.

Deprecate the episode field in favor of code in the Episode model.

// Episode schema
{
  id: Number,
  name: String,
  code: String,  // deprecate episode
  air_date: String,
  characters: [String],
  url: String,
  created: Date,
}

Update list

  • Episode schema, structure and static query.
  • Episode filter query params
  • Allowed filters
  • TypeDefs deprecation directives in field and input definitions.
  • Database $rename
  • Docs
  • Tests and mock data.

Season 6 characters

So now that season 6 is going on, can you add the new characters to the API?

If you need help adding them I can help.

Possible typo?

This character's data appears to have a typo in the name of the character:

{"id":408,"name":"Quick Mistery Presenter","status":"Alive","species":"Human","type":"","gender":"Male","origin":{"name":"Interdimensional Cable","url":"https://rickandmortyapi.com/api/location/6"},"location":{"name":"Interdimensional Cable","url":"https://rickandmortyapi.com/api/location/6"},"image":"https://rickandmortyapi.com/api/character/avatar/408.jpeg","episode":["https://rickandmortyapi.com/api/episode/8"],"url":"https://rickandmortyapi.com/api/character/408","created":"2018-04-15T20:51:47.778Z"}

Possibly it was meant to be "Quick Mystery Presenter"?

Season 4 November 10th!

There is going to be a new season, and (probably) new characters to add to this awesome API !!!

OpenAPI schema

It would be nice to have an OpenAPI definition for this API

Replace empty string with null

Hi, great API for me to discover swift Decodable and JSON parsing. But, I just realized that when a field is empty, you return "" instead of a null object.
For exemple, if I get the characters base url https://rickandmortyapi.com/api/character/, the field prev will have for value "" instead of a more logical null value.
It's not a very big problem, but when API parsing, have a null value instand of empty is more convenient.

{"info":{"count":493,"pages":25,"next":"https://rickandmortyapi.com/api/character/?page=2","prev":""}

will be:

{"info":{"count":493,"pages":25,"next":"https://rickandmortyapi.com/api/character/?page=2","prev":null}

Thanks for your work,

error because of requests limit

Hello!

I wanted to use your api in a study project to realize an Android app using some technologies which are new for me, but already reached requests limit and my app doesn't work :(( it seems that I will need to switch to use other api, but I wanted an app devoted to Rick and Morty :(( can we do anything about the limit? Thank you for consideration!

Translate data

It would be nice if you had the data in other languages. For example, here in Brazil I haven't found any apps with the same data types in Portuguese.

GraphQL: Characters nullable filter fields fails when null is passed

query {
  characters(filter: { name: null }) {
    results {
      name
    }
  }
}
{
  "errors": [
    {
      "message": "404: Not Found",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "characters"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "response": {
          "url": "http://localhost:8080/api/character/?name=null&page=undefined",
          "status": 404,
          "statusText": "Not Found",
          "body": {
            "error": "There is nothing here"
          }
        }
      }
    }
  ],
  "data": {
    "characters": null
  }
}

Expected behaviour

The filter field being ignored.

Current behaviour

The null filter field value is being converted to a string and it's being sent to the REST API.

http://localhost:8080/api/character/?name=null&page=undefined

Note that the same thing happens with the page parameter, but it doesn't fail in this case.

Bad structure of HTTP GET request for episodes

On the documentation page, I found this issue to get a single episode.

https://rickandmortyapi.com/api/location/episode/28

The API for episodes doesn´t work with /location when it should be:

https://rickandmortyapi.com/api/episode/28

i wish i had a episode filter in character api.

first of all perfect api. really cool.

if i want to get all of a specific episode's characters' details, ill have to either use character urls one by one in episode response (which can be 20 api call and is not wise), or split the episode ids from the end of urls and call Multiple Character api with their IDs (which is an ugly code).

i wish you had a episode filter in character api or you had a list of character IDs instead of list of URLs in episode response.

Filter characters based on location or origin

Hi Team,

I was going through the graphql schema and found that we can not filter characters based on location or origin currently.

Also, the schema doesn't support sorting currently.

If that can be added to the schema it will be great.

Thanks,
Sid

CORS problem

Hi:) Thanks for the great API! But now I have a little problem with CORS. I do the API call from the localhost and have this error:

Access to XMLHttpRequest at 'https://rickandmortyapi.com/api/character?page=1' from origin 'http://localhost:3000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed.

Could it be from my side?

Add Postman collection to docs

@afuh - do you mind if I create a Postman collection of your API and add it to your GH repo and/or documentation website? I'm happy to submit a pull request if this is welcome.

Character fields in GraphQL schema should not be nullable

In the schema of Character (and other types) there is currently this:

type Character {
    id: ID
    name: String
   ....
}

What this means is that there are characters like this: { id: null, name: null }

Expected: Use ! to specify which fields won't be null, for example the name, id, image, etc.

type Character {
    id: ID!
    name: String!
   ....
}

Other types should also be fixed, for example:

type Characters {
    info: Info
    results: [Character]   #this means results can be null, or can be an array of nulls, or an array of Character
  }

Should probably be

type Characters {
    info: Info!
    results: [Character!]!    # this means this will be an array of Characters, or an empty array
  }

Enhancement for better pagination in Front-end applications

So now i am sending a GET request on https://rickandmortyapi.com/api/episode/ which gives me the result

{
    "info": {
        "count": 41,
        "pages": 3,
        "next": "https://rickandmortyapi.com/api/episode/?page=2",
        "prev": null
    },
    "results": [.........//20 results here]
}

This response is just as the documentation said it would be!, I am implementing pagination and there is a issue

here response.data.info.next contains only information about the next page

Lets say i am displaying 20 items per page,

So when i am on Page 1 the next property holds only information about items in page 2

But what if i directly want to jump into items of page 3 ? I would have to call the API two times to get the correct response i want

So what i am suggesting is an enhancement of the response by adding a new property called listOfNextPages or any name of your choosing the response should ideally be something like this :

{
    "info": {
        "count": 41,
        "pages": 3,
        "next": "https://rickandmortyapi.com/api/episode/?page=2",
        "listOfNextPages" : [
          https://rickandmortyapi.com/api/episode/?page=2,
          https://rickandmortyapi.com/api/episode/?page=3
]
        "prev": null
    },
    "results": [.........//20 results here]
}

Same should be applied for search API aswell

Possible wrong Data

Hi, I don't know if this is the properly place to put this but, the data from character 343 seems wrong

{
  "id": 343,
  "name": "Tammy Guetermann"*,
  "status": "Alive",
  "species": "Cronenberg"*,
  "type": "",
  "gender": "Male"*,
  "origin": {
    "name": "Earth (C-137)",
    "url": "https://rickandmortyapi.com/api/location/1"
  },
  "location": {
    "name": "Earth (C-137)",
    "url": "https://rickandmortyapi.com/api/location/1"
  },
  "image": "https://rickandmortyapi.com/api/character/avatar/343.jpeg",
  "episode": [
    "https://rickandmortyapi.com/api/episode/5",
    "https://rickandmortyapi.com/api/episode/6"
  ],
  "url": "https://rickandmortyapi.com/api/character/343",
  "created": "2018-01-10T17:27:04.773Z"
}

I checked the 344 and looks like that are the correct data from Tammy

Sorry if I'm wrong, and thanks for the great API 😄

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.