SwapiDev
A Ruby wrapper for the Star Wars API
RubyGem
https://rubygems.org/gems/swapi_dev
Api documentation
here is the documentation of The Star War API
Installation
Add this line to your application's Gemfile:
gem 'swapi_dev'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install swapi_dev
Usage
First you need to require the gem
require "swapi_dev"
Methods
You will find methods for 6 diferent Resources, all of them with the same behavior:
- Planets
- Starships
- Vehicles
- People
- Films
- Species
Example using People
SwapiDev.people # accepts: format, page, search
SwapiDev.people_id(some_id) # accepts: format
Searching
All searches will use case-insensitive partial matches on the set of search fields.
# people search
SwapiDev.people(search: "Luke Skywalker")
# vehicle search
SwapiDev.vehicle(search: "Sand Crawler")
To see the set of search fields for each resource, check the table below:
Resource | Fields |
People | name |
Films | title |
Starships | name, model |
Vehicles | name, model |
Species | name |
Planets | name |
Pagination
You can pass a page
argument if you want to get specific page.
SwapiDev.people(page: 2)
Format
This encoding is identical to JSON except with wookiee translations. All methods accept wookiee format keyword.
SwapiDev.people(format: :wookie)
SwapiDev.people(search: "Luke", format: :wookie)
SwapiDev.people_id(1, format: :wookie)
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/Eduardo-Lpz/swapi_dev. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the 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 SwapiDev project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.