Callcounter.eu Ruby gem
Add sinatra explanation
Add missing Net::HTTP require



You can also use your local clone with git send-email.

builds.sr.ht status

#Callcounter Ruby integration gem

This gem can be used to gather API request & response data from Rack based applications and send it to Callcounter.

Callcounter is an API analytics platform that collect information about requests (calls) to your API using so-called integrations. Integrations come in the form of a Ruby gem, a Nuget package, a Pip module, etcetera. The integrations can send the data to Callcounter using an API, which is described at: https://callcounter.eu/pages/api

After collection data, the web interface can then be used to view all kinds of metrics, giving you insight in the (mis)usage of your API.



When using bundler, simply add the following line to your Gemfile and run bundle:

gem 'callcounter'


Install the gem with: gem install callcounter. Next, add the following call to your entry file in order to activate the Rack middleware:

use Callcounter::Capturer

#Configure what to capture

Configure callcounter with the following code, this can be placed in a Rails initializer when using Ruby on Rails, for example config/initializers/callcounter.rb, or somewhere in your entry point file when using Sinatra or other Rack based frameworks:

Callcounter.configure do |config|
  config.project_token = '' # TODO: fill with your unique project token

This will capture any requests to the api subdomain and any request that has a path which starts with /api. After deploying you should start seeing data in Callcounter. Note that this might take some time because this gems only sends data every few requests or every few minutes.

If you API doesn't match with the default matching rules, you can add a lambda that will be called for every request to determine whether it was a request to your API. For example, you can custome the default lambda shown below:

Callcounter.configure do |config|
  config.project_token = '' # TODO: fill with your unique project token
  config.track = lambda { |request|
    request.hostname.start_with?('api') || request.path.start_with?('/api')

#Bug reporting

Bugs can be reported through the Sourcehut todo lists found at: https://todo.sr.ht/~webindie/callcounter-gem If you don't want to sign up for an account, you can also contact us through https://callcounter.eu/contact


  • Verify tests pass.
  • Increment version number in: lib/callcounter/version.rb
  • Run bundle install
  • Commit all changes
  • Create a git tag for the release.
  • Push the git tag.
  • Build the gem: gem build callcounter.gemspec
  • Push the gem to rubygems.org: gem push callcounter-?.?.?.gem

#About Callcounter

Callcounter is a service built by Webindie that helps API providers with debugging and optimising the usage of their APIs.