Country Languages API - Ruby Gem

Country Languages is a simple tool for getting the list of official and commonly spoken languages in a specific country.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_countrylanguages'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_countrylanguages

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_countrylanguages'

# Initialize the client
client = APIVerve::Countrylanguages::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({ name: "ZW" })

# Print the response
puts response

Error Handling

begin
  response = client.execute({ name: "ZW" })
  puts response["data"]
rescue APIVerve::Countrylanguages::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Countrylanguages::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Countrylanguages::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "country": "ZW",
    "name": "Zimbabwe",
    "officialName": "Republic of Zimbabwe",
    "officialLanguages": [
      "Chibarwe",
      "English",
      "Kalanga",
      "Khoisan",
      "Ndau",
      "Northern Ndebele",
      "Chewa",
      "Shona",
      "Sotho",
      "Tonga",
      "Tswana",
      "Tsonga",
      "Venda",
      "Xhosa",
      "Zimbabwean Sign Language"
    ],
    "officialLanguageCount": 15
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.