mcu-sdk
v1.0.5
Published
MCU-SDK provides a set of methods to access the data provided by the Marvel Comics API.
Downloads
6
Maintainers
Readme
mcu-sdk
Introduction
mcu-sdk
provides a set of methods to access the data provided by the Marvel Comics API. Marvel Comics data is freely available on the Marvel Developer Portal.
You can use mcu-sdk
to access that data and use it in your own fun projects. All you need to do is to sign up for a developer account on the Marvel Developer Portal and get your API keys.
Prerequisites
Node.js v18.x LTS
or higher is required to use mcu-sdk
.
Note: Latest LTS version of Node.js is recommended.
Installation
npm i mcu-sdk
Usage
Initialize the API
const { MarvelAPI } = require("mcu-sdk");
const api = MarvelAPI.init("PRIVATE_KEY", "PUBLIC_KEY");
Replace
PRIVATE_KEY
andPUBLIC_KEY
with your own Marvel API keys. You can get them from the Marvel Developer Portal.
Call any of the available methods
api.{METHOD}({PARAMETERS})
Replace
{METHOD}
with any of the available methods and{PARAMETERS}
with the query parameters you want to pass to the method.
Available Methods
getAllCharacters()
getCharacterById(characterId)
getCharacterComics(characterId)
getCharacterEvents(characterId)
getCharacterSeries(characterId)
getCharacterStories(characterId)
getAllComics()
getComicById(comicId)
getComicCharacters(comicId)
getComicCreators(comicId)
getComicEvents(comicId)
getComicStories(comicId)
getAllCreators()
getCreatorById(creatorId)
getCreatorComics(creatorId)
getCreatorEvents(creatorId)
getCreatorSeries(creatorId)
getCreatorStories(creatorId)
getAllEvents()
getEventById(eventId)
getEventCharacters(eventId)
getEventComics(eventId)
getEventCreators(eventId)
getEventSeries(eventId)
getEventStories(eventId)
getAllSeries()
getSeriesById(seriesId)
getSeriesCharacters(seriesId)
getSeriesComics(seriesId)
getSeriesCreators(seriesId)
getSeriesEvents(seriesId)
getSeriesStories(seriesId)
getAllStories()
getStoryById(storyId)
getStoryCharacters(storyId)
getStoryComics(storyId)
getStoryCreators(storyId)
getStoryEvents(storyId)
getStorySeries(storyId)
Example
const { MarvelAPI } = require("mcu-sdk");
const api = MarvelAPI.init("PRIVATE_KEY", "PUBLIC_KEY");
api.getAllCharacters()
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error);
});
Query Parameters
You can pass query parameters to the methods to filter the results. For example:
api.getAllCharacters({
limit: "10",
offset: "10",
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error);
});
You can find the list of available query parameters for each method in the Marvel API documentation.
Terms of Use
By using mcu-sdk
, you agree to comply with the Marvel API Terms of Use.
You must attribute Marvel as the source of data whenever you display any results from the Marvel Comics API. Please use the following text on every application screen or web page which displays the API result:
"Data provided by Marvel. © 2014 Marvel"