Skip to content
Related Articles

Related Articles

Find comics of marvel superhero using marvel API in Python

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 17 May, 2022

In this article, we will find the comic of marvel by using python and marvel api. Marvel has provided an API that provides a look into their database consisting of various comics, movies, etc. We will be using that to find out your favorite marvel superhero comic books.

The Marvel Comics API is a tool to help developers everywhere create amazing, uncanny, and incredible websites and applications using data from the 70-plus years of the Marvel age of comics.

The Marvel Comics API is a RESTful service that provides methods for accessing specific resources at canonical URLs and for searching and filtering sets of resources by various criteria. All representations are encoded as JSON objects.

You can access six resource types using the API:

  • Comics: individual print and digital comic issues, collections, and graphic novels. For example: Amazing Fantasy #15.
  • Comic series: sequentially numbered (well, mostly sequentially numbered) groups comics with the same title. For example, Uncanny X-Men.
  • Comic stories: indivisible, reusable components of comics. For example, the cover from Amazing Fantasy #15 or the origin of the Spider-Man story from that comic.
  • Comic events and crossovers: big, universe-altering storylines. For example, Infinity
  • Creators: women, men, and organizations who create comics. For example, Jack Kirby.
  • Characters: the women, men, organizations, alien species, deities, animals, non-corporeal entities, trans-dimensional manifestations, abstract personifications, and green amorphous blobs which occupy the Marvel Universe (and various alternate universes, timelines, and altered realities therein). For example, Spider-Man.

In this article, we will try to fetch a particular character from the marvel API, and then we will generate the comics in which that particular character appeared.

Installation of marvel package

pip install marvel

Getting the api key:

Step 1: First go their website, Now click on to top left “SIGN IN | JOIN” option and then click on to the “CREATE AN ACCOUNT” and now give your details and then click “CREATE ACCOUNT” option, which will look like this

Step 2: After signing in you will be redirected to their home page where it will show that your account is now logged in, but in order to get the API key first, you’ve to confirm the mail which marvel has sent you on your specified email address in order to verify it. Check your mailbox there will be a mail sent by marvel. Open it and then click “Confirm” option

Step 3: After that, you’ve to come back to your marvel developer portal where you’ve just created your account, and now on the top left side it will show your username instead of the sign-in option otherwise please refer to the steps again. After that in the middle center portion of the website, you will find an option “Get a Key”, click on that

Step 4: After that, you will be redirected to their terms of use page for the API. Just scroll down to the bottom (or you can give it a read if you want) and click on accept. Now, there we go, finally we will arrive at the page where it will show you the two most important keys and other important information. Just copy the Private and the public keys and store them in a secured folder on your computer. The page will look like this

Note: Keep these keys in a private folder and don’t share them with anyone else. 


  • First import marvel from Marvel package
from marvel import Marvel
  • After that type your public and private keys like this

characters = m.characters comics = m.comics creators = m.creators events = series = m.series stories = m.stories

  • Each of the above objects returns the appropriate response (JSON), but from here we are only interested in getting the characters object which is the first one.
  • Now every superhero has a serial number associated with it, find out about a rare superhero named “3-D Man” and discover his comics.
  • For getting the comics we have syntax like this
# where x is the serial code of your 
# superhero
comics = characters.comics(1011334)
  • We will store this comics dictionary as all_characters dictionary in our code

Below is the implementation:


# importing the marvel module
from marvel import Marvel 
m = Marvel("8e6845d48fcb5b7dbec2bc3784b9d2be",
# getting the characters object
characters = m.characters 
# serial code of your favourite character
# this can be different according to your preference
x = 1011334 
for n in range (0, 6): 
      # serach for comics of this character
    x = x+1 
    for i in range (1,12):


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!