https://github.com/letsjaam/mixpanel-data-export-api
PHP wrapper for the Mixpanel Data and Export APIs.
https://github.com/letsjaam/mixpanel-data-export-api
mixpanel mixpanel-api php silex
Last synced: 11 months ago
JSON representation
PHP wrapper for the Mixpanel Data and Export APIs.
- Host: GitHub
- URL: https://github.com/letsjaam/mixpanel-data-export-api
- Owner: letsjaam
- Created: 2016-12-20T13:24:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-08-16T14:12:14.000Z (almost 8 years ago)
- Last Synced: 2025-06-27T01:41:33.523Z (12 months ago)
- Topics: mixpanel, mixpanel-api, php, silex
- Language: PHP
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mixpanel Data Export API
This library wraps the [Mixpanel Data Export API](https://mixpanel.com/help/reference/data-export-api) for PHP.
To track events and update profiles please see the official [Mixpanel PHP Library](https://github.com/mixpanel/mixpanel-php).
## Installation
```bash
composer require jaam/mixpanel-data-export-api
```
## Usage
The `Jaam\Mixpanel\DataExportApi` class includes two public methods - `data` and `export` - one for each of the Data Export APIs.
Full documentation of every endpoint, their parameters and responses can be found in the [Mixpanel Data Export API documentation](https://mixpanel.com/help/reference/data-export-api).
#### Setup
```php
data('events', [
'event' => ['event_name'], // Array of event names
'type' => 'unique',
'unit' => 'day',
'from_date' => '2016-12-01',
'to_date' => '2016-12-31'
]);
// $data is an array
} catch ( DataExportApiException $e )
// Handle exception
}
```
#### Export API
See [Exporting Raw Data documentation](https://mixpanel.com/help/reference/exporting-raw-data) for parameters and response examples.
```php
// Perform setup, as above
try {
// Export raw data
$data = $mixpanel->export([
'from_date' => '2016-12-01',
'to_date' => '2016-12-31'
]);
// $data is an array
} catch ( DataExportApiException $e )
// Handle exception
}
```
## Silex Integration
A small integration with [Silex](http://silex.sensiolabs.org/) is provided via `Jaam\Mixpanel\Integration\Silex\MixpanelDataExportProvider`.
```php
// Bootstrap Silex app
use Jaam\Mixpanel\Integration\Silex\MixpanelDataExportProvider;
$app['mixpanel.api_secret'] = 'YOUR SECRET'; // Secret located in Mixpanel project settings
$app->register(new MixpanelDataExportProvider);
// Use via `mixpanel.api` server later in application
$data = $app['mixpanel.api']->export([
'from_date' => '2016-12-14',
'to_date' => '2016-12-18'
]);
```