UNPKG

mcu-sdk

Version:

MCU-SDK provides a set of methods to access the data provided by the Marvel Comics API.

130 lines (99 loc) 3.96 kB
# mcu-sdk ![dt](https://img.shields.io/npm/dt/mcu-sdk.svg?style=for-the-badge) ![l](https://img.shields.io/npm/l/mcu-sdk.svg?style=for-the-badge) ![min](https://img.shields.io/bundlephobia/min/mcu-sdk.svg?style=for-the-badge) ![types](https://img.shields.io/npm/types/mcu-sdk.svg?style=for-the-badge) ![v](https://img.shields.io/npm/v/mcu-sdk.svg?style=for-the-badge) ![npm](https://nodei.co/npm/mcu-sdk.png?downloadRank=true&downloads=true) ## 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](https://developer.marvel.com). 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](https://developer.marvel.com/account) 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 ```bash npm install mcu-sdk ``` ## Usage ### Initialize the API ```javascript const { MarvelAPI } = require("mcu-sdk"); const api = MarvelAPI.init("PRIVATE_KEY", "PUBLIC_KEY"); ``` > Replace `PRIVATE_KEY` and `PUBLIC_KEY` with your own Marvel API keys. You can get them from the [Marvel Developer Portal](https://developer.marvel.com/account). ### Call any of the available methods ```text 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 ```javascript 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: ```javascript 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](https://developer.marvel.com/docs). ## Terms of Use By using `mcu-sdk`, you agree to comply with the [Marvel API Terms of Use](https://developer.marvel.com/terms). > 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"`