0.0
No commit activity in last 3 years
No release in over 3 years
Lightweight interface to communicate with the Marvel Comics API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 10.0
~> 3.0

Runtime

~> 0.14.0
>= 3.5.7, ~> 3.5
 Project Readme

MarvelCrawler

Lightweight interface to communicate with the Marvel Comics API. It supports configurable pagination for all API.

Installation

Add this line to your application's Gemfile:

gem 'marvel_crawler'

And then execute:

$ bundle

Or install it yourself as:

$ gem install marvel_crawler

Configuration

You need to register on Marvel Developer Portal to get your public key and a private key. It requires to do the request on Marvel API.

@crawler = MarvelCrawler.client

@crawler.configure do |config|
  config.api_key = 'YOUR_API_KEY'
  config.private_key = 'YOUR_PRIVATE_KEY'
  config.record_per_page = 2 # Optional. By default its 5. You will get this much records per page.
end

OR

@crawler = MarvelCrawler.client

@crawler.api_key = 'YOUR_API_KEY'
@crawler.private_key = 'YOUR_PRIVATE_KEY'
@crawler.record_per_page = 2 # Optional. By default its 5. You will get this much records per page.

Usage

Below are the examples of supported resources. All the methods returns an object of MarvelCrawler::ApiResponse

Characters

@crawler.get_characters(page_num: 2) # Default page number is 1
@crawler.get_characters(name: 'A.I.M.', page_num: 2)
@crawler.get_characters(nameStartsWith: 'A', orderBy: 'modified')
@crawler.get_character(id: 1009144)

Comics

@crawler.get_comics(page_num: 2) # Default page number is 1
@crawler.get_comics(title: 'UNIVERSE X SPECIAL: CAP 1 (2001)')
@crawler.get_comics(format: 'magazine')

Creators

@crawler.get_creators(page_num: 2) # Default page number is 1

Events

@crawler.get_events(page_num: 2) # Default page number is 1

Series

@crawler.get_series(page_num: 2) # Default page number is 1

Stories

@crawler.get_stories(page_num: 2) # Default page number is 1

Response

All the methods returns an object of MarvelCrawler::ApiResponse The object contains following attributes:

response.code       => Http code returned from api
response.status     => Status returned from api
response.results    => Contains all the data for the resource
response.etag       => etag returned from api
response.offset     => offset returned from api
response.limit      => limit returned from api which we have used
response.total      => Total number of result available for this resource
response.count      => Total number of result set returned by this call
response.message    => Success OR Error message

Test cases

Execute rspec . from project directory to run the rspec tests.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ketandoshi/marvel-crawler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the MarvelCrawler project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.