Project

random_api

0.0
No commit activity in last 3 years
No release in over 3 years
Provide a ruby interface for pulling data from the Random API, fetching random user data.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 0.10
~> 10.0
~> 3.1

Runtime

~> 0.13.3
 Project Readme

RandomAPI

Interface with the RandomAPI at https://randomuser.me and provide a ruby wrapper for the responses. Interact with response as a Ruby object with helper methods for fetching all important data.

Installation

Add this line to your application's Gemfile:

gem 'random_api'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install random_api

Usage

Using RandomAPI is simple, you can use it anonymously or use your API Key to make requests.

# Create a RandomAPI service with anonymous access to the API
service = RandomApi::Service.new

# Fetch a single random user
user = service.user

# Fetch a male user
user = service.user(gender: "male")

# Fetch a list of users
user = service.users(10)

# Fetch 10 male users
user = service.users(10, gender: "male")

# If you have an API Key, pass it to service
service = RandomApi::Service.new(api_key)

# Then make requests as per the norm

The object returned by the call to RandomApi::Service#user and RandomApi::Service#users is of the type RandomApi::User.

user = service.user

user.gender # => "female"
user.name # => "Ms. Lois Williams"
user.title # => "Ms."
user.first_name # => "Lois"
user.last_name # => "Williams"
user.street # => "1969 Elgin St"
user.city # => "Frederick"
user.state # => "Delaware"
user.zip # => "56298"
user.email # => "lois.williams50@example.com"
user.username # => "heavybutterfly920"
user.password # => "enterprise"
user.salt # => ">egEn6YsO"
user.md5 # => "2dd1894ea9d19bf5479992da95713a3a",
user.sha1 # => "ba230bc400723f470b68e9609ab7d0e6cf123b59",
user.sha256 # => "f4f52bf8c5ad7fc759d1d4156b25a4c7b3d1e2eec6c92d80e508aa0b7946d4ba",
user.registered # => "1288182167",
user.dob # => "146582153",
user.phone # => "(555)-942-1322",
user.cell # => "(178)-341-1520",
user.ssn # => "137-37-8866",
user.large_picture # => "http://api.randomuser.me/portraits/women/55.jpg",
user.medium_picture # => "http://api.randomuser.me/portraits/med/women/55.jpg",
user.thumbnail # => "http://api.randomuser.me/portraits/thumb/women/55.jpg",
user.api_version # => "0.4.1"
user.seed # => "graywolf"

Contributing

  1. Fork it ( https://github.com/[my-github-username]/random_api/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request