Marvel API Docs

The Marvel API allows developers to retrieve information about Marvel's vast universe of comic book characters, stories, and events. This API provides a wealth of data, including comics, characters, events, series, and more.

Getting Started

To use the Marvel API, developers must first create an account through the Marvel Developer Portal. Once an account is created, developers can access the API keys needed to make requests.

Authentication

All Marvel API requests require authentication via an API key and a secret key. These keys must be included in the API request as query parameters. Here's an example:

const publicKey = 'your-public-key';
const privateKey = 'your-private-key';
const timestamp = new Date().getTime().toString();
const hash = md5(timestamp + privateKey + publicKey);

const apiUrl = `http://gateway.marvel.com/v1/public/characters?ts=${timestamp}&apikey=${publicKey}&hash=${hash}`;

fetch(apiUrl)
  .then(response => response.json())
  .then(data => console.log(data));

Endpoints

The Marvel API provides a variety of endpoints for accessing different types of data. Here are some examples:

Characters

To retrieve information about a specific character, developers can make a GET request to the characters/{characterId} endpoint. Here's an example:

const apiUrl = `http://gateway.marvel.com/v1/public/characters/1009368?ts=${timestamp}&apikey=${publicKey}&hash=${hash}`;

fetch(apiUrl)
  .then(response => response.json())
  .then(data => console.log(data));

Comics

To retrieve information about a specific comic book, developers can make a GET request to the comics/{comicId} endpoint. Here's an example:

const apiUrl = `http://gateway.marvel.com/v1/public/comics/82967?ts=${timestamp}&apikey=${publicKey}&hash=${hash}`;

fetch(apiUrl)
  .then(response => response.json())
  .then(data => console.log(data));

Events

To retrieve information about a specific event, developers can make a GET request to the events/{eventId} endpoint. Here's an example:

const apiUrl = `http://gateway.marvel.com/v1/public/events/336?ts=${timestamp}&apikey=${publicKey}&hash=${hash}`;

fetch(apiUrl)
  .then(response => response.json())
  .then(data => console.log(data));

Series

To retrieve information about a specific comic book series, developers can make a GET request to the series/{seriesId} endpoint. Here's an example:

const apiUrl = `http://gateway.marvel.com/v1/public/series/24229?ts=${timestamp}&apikey=${publicKey}&hash=${hash}`;

fetch(apiUrl)
  .then(response => response.json())
  .then(data => console.log(data));

Conclusion

The Marvel API provides a wealth of data for developers looking to build their own Marvel-themed apps and websites. With a little bit of JavaScript and knowledge of the API endpoints, developers can easily retrieve information about their favorite characters, comics, events, and more.

Related APIs

Public APIs — A directory of free and public apis

Built by @mddanishyusuf