Drupal uses an externally-maintained repository the https://packagist.drupal-composer.org but this repo is scheduled to be deprecated in January 2017 by then we will be using https://packages.drupal.org/8 repo URL.
It is assumed that composer is already installed in your system. Make sure your composer version is 1.0.0 or higher, to check execute:
If it is lower than version 1.0.0, update it by:
Change directory to your Drupal root path.
Since we are getting our module in external composer repository, configure composer to look up to its repo URL:
composer config repositories.drupal composer https://packagist.drupal-composer.org
Note: on January 2017, you will want to change to new repo:
composer config repositories.drupal composer https://packages.drupal.org/8
Finally, to install a Drupal module (lets setup Smart IP) execute:
composer require "drupal/smart_ip ~8.3" -vvv
Smart IP module has two non-Drupal module dependencies: geoip2/geoip2 and ip2location/ip2location-php libraries. These two libraries should be downloaded automatically.
The module will be installed at [drupal root path]/module/smart_ip