The project is in a healthy, maintained state
Official Ruby SDK for the Phone Number Validation & Formatter API by GenderAPI.io. Features: - Validate phone numbers from 240+ countries - Format numbers to E.164 or national format - Detect number type (mobile, landline, VoIP, etc.) - Retrieve region, area code, and country metadata Built using HTTParty for robust HTTP requests.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 3.0

Runtime

~> 0.18
~> 2.0
 Project Readme

๐Ÿ“ž Phone Number Validation & Formatter API (Ruby SDK)

The genderapi-phone-validator gem uses the official GenderAPI Phone Number Validation & Formatter API to validate and format phone numbers from over 240 countries and territories.

Whether your users enter phone numbers in various formats (e.g., 12128675309, +1 212 867 5309, 001-212-867-5309), this library will intelligently detect, validate, and convert the input into a standardized E.164 format (e.g., +12128675309).


โœ… Features

  • Converts phone numbers to E.164 format
  • Validates if the number is real and structurally possible
  • Detects number type: mobile, landline, VoIP, etc.
  • Identifies region/city based on area code
  • Returns country-level metadata (e.g., ISO code)
  • Built with Ruby, uses HTTParty for HTTP requests

๐Ÿ“ฆ Installation

Add the gem to your project:

gem install genderapi-phone-validator

Or in your Gemfile:

gem 'genderapi-phone-validator'

๐Ÿ” Authentication

You need an API key from www.genderapi.io.
Sign up and get your key from your dashboard.


๐Ÿš€ Usage

require 'genderapi-phone-validator'

client = PhoneValidator::Client.new(api_key: "YOUR_API_KEY")

response = client.validate(
  number: "+1 212 867 5309",   # Required
  address: "US"                # Optional, helps with local formats
)

puts response

๐Ÿงพ Input Parameters

validate(number:, address: nil) โ†’ Hash
Parameter Type Required Description
number String โœ… Yes Phone number in any format
address String Optional ISO country code (US), full country name (Turkey), or city name (Berlin) โ€“ improves local number detection

Example:

client.validate(number: "2128675309", address: "US")

๐Ÿ“ฌ API Response Example

{
  "status": true,
  "remaining_credits": 15709,
  "expires": 0,
  "duration": "18ms",
  "regionCode": "US",
  "country": "United States",
  "national": "(212) 867-5309",
  "international": "+1 212-867-5309",
  "e164": "+12128675309",
  "isValid": true,
  "isPossible": true,
  "numberType": "FIXED_LINE_OR_MOBILE",
  "nationalSignificantNumber": "2128675309",
  "rawInput": "+1 212 867 5309",
  "isGeographical": true,
  "areaCode": "212",
  "location": "New York City (Manhattan)"
}

๐Ÿง  Response Field Reference

Field Type Description
status Boolean Was the request successful
remaining_credits Integer Remaining API credits
regionCode String ISO 3166-1 alpha-2 code (e.g., US)
country String Country name
e164 String Number formatted to E.164
isValid Boolean Is number valid according to rules
isPossible Boolean Is number structurally possible
numberType String Number type (MOBILE, FIXED_LINE, etc.)
areaCode String Area code from input
location String City/region matched from area code

๐Ÿ”ข Number Type Values

Value Description
FIXED_LINE Landline
MOBILE Mobile phone
FIXED_LINE_OR_MOBILE Ambiguous, could be both
TOLL_FREE e.g., 800 numbers
PREMIUM_RATE Expensive premium numbers
SHARED_COST Cost shared between parties
VOIP Internet-based phone
PERSONAL_NUMBER Forwarding number
PAGER Obsolete pager number
VOICEMAIL Voicemail access
UNKNOWN Cannot be determined

โ„น๏ธ More Information


๐Ÿ“ License

MIT License ยฉ GenderAPI