<commit_before># Mixpanel Data API Client

[![Gem Version](https://badge.fury.io/rb/mixpanel_client.svg)](http://badge.fury.io/rb/mixpanel_client)
[![Code Climate](https://codeclimate.com/github/keolo/mixpanel_client/badges/gpa.svg)](https://codeclimate.com/github/keolo/mixpanel_client)
[ ![Codeship Status for keolo/mixpanel_client](https://codeship.com/projects/4d247060-1ad9-0134-e1c3-0e8ad2af7d49/status?branch=master)](https://codeship.com/projects/159479)

Ruby access to the [Mixpanel](http://mixpanel.com/) web analytics tool.

[Mixpanel Data API Reference](https://mixpanel.com/docs/api-documentation/data-export-api)

## Installation

    gem install mixpanel_client

or if you use a Gemfile

    gem 'mixpanel_client'

## Usage

    require 'rubygems'
    require 'mixpanel_client'

    client = Mixpanel::Client.new(
      api_secret: 'changeme'
    )

    data = client.request(
      'events/properties',
      event:     'splash features',
      name:      'feature',
      values:    '["uno", "dos"]',
      type:      'unique',
      unit:      'day',
      from_date: '2013-12-1',
      to_date:   '2014-3-1',
      limit:     5
    )

    puts data.inspect

    # The API also supports passing a time interval rather than an explicit date range
    data = client.request(
      'events/properties',
      event:    'splash features',
      name:     'feature',
      values:   '["uno", "dos"]',
      type:     'unique',
      unit:     'day',
      interval: 7,
      limit:    5
    )
<commit_msg>Document the "timeout" option<commit_after># Mixpanel Data API Client

[![Gem Version](https://badge.fury.io/rb/mixpanel_client.svg)](http://badge.fury.io/rb/mixpanel_client)
[![Code Climate](https://codeclimate.com/github/keolo/mixpanel_client/badges/gpa.svg)](https://codeclimate.com/github/keolo/mixpanel_client)
[ ![Codeship Status for keolo/mixpanel_client](https://codeship.com/projects/4d247060-1ad9-0134-e1c3-0e8ad2af7d49/status?branch=master)](https://codeship.com/projects/159479)

Ruby access to the [Mixpanel](http://mixpanel.com/) web analytics tool.

[Mixpanel Data API Reference](https://mixpanel.com/docs/api-documentation/data-export-api)

## Installation

    gem install mixpanel_client

or if you use a Gemfile

    gem 'mixpanel_client'

## Usage

    require 'rubygems'
    require 'mixpanel_client'

    client = Mixpanel::Client.new(
      api_secret: 'changeme'
      timeout: 240    # Default is 60 seconds, increase if you get frequent Net::ReadTimeout errors.
    )

    data = client.request(
      'events/properties',
      event:     'splash features',
      name:      'feature',
      values:    '["uno", "dos"]',
      type:      'unique',
      unit:      'day',
      from_date: '2013-12-1',
      to_date:   '2014-3-1',
      limit:     5
    )

    puts data.inspect

    # The API also supports passing a time interval rather than an explicit date range
    data = client.request(
      'events/properties',
      event:    'splash features',
      name:     'feature',
      values:   '["uno", "dos"]',
      type:     'unique',
      unit:     'day',
      interval: 7,
      limit:    5
    )

{'fraction_non_alphanumeric': 0.13819334389857368, 'fraction_numerical': 0.02884310618066561, 'mean_word_length': 2.8394160583941606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4382173', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1040, 'n_words': 220}