Back

Mixpanel API Essential Guide

Aug 17, 20246 minute read

What type of API does Mixpanel provide?

Based on the search results, Mixpanel offers several types of APIs, but they are primarily REST APIs. The key points are:

  1. Mixpanel provides multiple API endpoints organized by function:

    • Query API
    • Ingestion API
    • Raw Data Export API
    • Data Pipelines API
    • Lexicon Schemas API
    • Connectors API
    • GDPR API
    • Warehouse Connectors API
  2. These APIs allow querying, exporting, and importing data, as well as manipulating Mixpanel metadata.

  3. The APIs use standard REST conventions, with endpoints like:

    mixpanel.com/api
    api.mixpanel.com
    data.mixpanel.com/api/2.0/export
    
  4. The structure and endpoints indicate these are REST APIs, not SOAP, GraphQL, or other types.

  5. REST APIs are widely used for web services and follow principles like statelessness, client-server architecture, and use of standard HTTP methods.

  6. Mixpanel does not appear to offer SOAP, GraphQL, or gRPC APIs based on the available information.

In summary, Mixpanel primarily uses REST APIs for its various services and data access points. The API structure and documentation align with typical REST API conventions and best practices.

Does the Mixpanel API have webhooks?

Webhook Support

Yes, the official Mixpanel API does support webhooks. Mixpanel allows syncing cohorts to a custom webhook URL that you provide via their Integrations UI.

Types of Events

The types of events you can subscribe to through Mixpanel webhooks are related to cohort changes:

  1. Full cohort sync: When a sync is first established, Mixpanel will sync the full contents of the cohort to the provided URL.

  2. Diff syncs: Subsequently, Mixpanel will sync diffs, which include:

    • Users who entered the cohort since the last sync
    • Users who exited the cohort since the last sync

Webhook Format

The webhook format has the following structure in the body of a POST request:

  • action: Defines the type of message being sent. It can be one of:

    • members: All members of the cohort (sent on first sync or to refresh the cohort)
    • add_members: Users that have entered the cohort since the last sync
    • remove_members: Users who have exited the cohort since the last sync
  • parameters: Include various details such as:

    • mixpanel_project_id
    • mixpanel_cohort_id
    • mixpanel_cohort_name
    • mixpanel_cohort_description
    • mixpanel_session_id
    • page_info
    • members: List of users being added or removed from the cohort

Key Considerations

  1. Webhooks are supported for paid Mixpanel plans.

  2. You need to set up a webhook server to receive the data from Mixpanel.

  3. Large cohorts may be sent over multiple messages, identified by a unique mixpanel_session_id.

  4. There can be failure scenarios where users might be synced again, which may require handling on the webhook server side to avoid duplicate actions.

  5. Actions triggered by the webhook are not automatically tracked in Mixpanel. Customers need to explicitly track events back to Mixpanel to use them on the Mixpanel platform.

In summary, while Mixpanel does offer webhook support, it's primarily focused on cohort syncing rather than a wide variety of event types. The webhooks allow you to receive updates about changes in cohort membership, which can be useful for integrating Mixpanel data with other systems or triggering actions based on cohort changes.

Rate Limits and other limitations

Here are the key API rate limits for the Mixpanel API:

Raw Data Export API

  • Maximum of 100 concurrent queries
  • 60 queries per hour
  • 3 queries per second [1][2]

Query API

  • Maximum of 5 concurrent queries
  • 60 queries per hour [5]

Ingestion API

  • 2GB of uncompressed JSON per minute
  • Approximately 30,000 events per second (measured on a rolling 1 minute basis) [2]

Lexicon Schemas API

  • 8MB body size limit
  • Request cannot take longer than 2 minutes [2]

User Profile API

  • Maximum of 2000 profile updates per request
  • Each individual update limited to 1MB [3]

Key Points

  • Exceeding rate limits will result in a 429 error response [1][2]
  • Rate limits are enforced to maintain system integrity and prevent monopolization of resources [2]
  • For the Raw Data Export API, queries are limited both per hour and per second [1][2]
  • The Ingestion API has a high throughput limit to handle large volumes of event data [2]
  • Some APIs like Lexicon Schemas have size and time limits in addition to request limits [2]

Best Practices

To reduce rate-limiting errors, Mixpanel recommends:

  1. Spreading queries out over a longer period of time
  2. Consolidating multiple queries into a single query where possible (e.g. combining multiple property filters into one segmentation query) [2]

For APIs with size/update limits like User Profiles, breaking requests into smaller batches is recommended if hitting limits [3]

By understanding and working within these rate limits, developers can optimize their use of the Mixpanel API while avoiding errors and ensuring consistent access to data.

Latest API Version

Based on the search results provided, here are the key points regarding the most recent version of the Mixpanel API:

Current API Structure

The Mixpanel API is structured into several components:

  1. Ingestion API - For getting data into Mixpanel [1]
  2. Query API - For retrieving calculated data from Mixpanel [1]
  3. Raw Data Export API - For exporting raw event data [1]
  4. Data Pipelines API - For exporting data to your own data warehouse [1]
  5. Lexicon Schemas API - For managing data definitions [1]
  6. Connectors API - For batch importing large volumes of data [1]
  7. GDPR API - For GDPR and CCPA compliance [1]
  8. Warehouse Connectors API - For manually running warehouse imports [1]

Latest Version Information

The search results do not explicitly state a single "most recent version" number for the entire Mixpanel API. However, we can infer some version information:

  • The GDPR API is currently at version 3 (v3.0) [4]
  • The Raw Data Export API endpoint is at version 2.0 [1]
  • The Data Pipelines API endpoint is at version 2.0 [1]

Recent Updates

While not directly related to the API version, the most recent release of the Mixpanel Android SDK is v7.5.2, released on April 16, 2024 [3]. This may indicate ongoing updates to Mixpanel's systems and APIs.

Key Points

  1. Mixpanel's API is divided into several components, each serving different purposes.
  2. Different API components may have different version numbers.
  3. The GDPR API is at version 3, which is the highest explicitly mentioned version number.
  4. Mixpanel continues to update its systems, as evidenced by recent SDK releases.

It's important to note that API versions for different components may be updated independently. For the most up-to-date and accurate information on API versions, it's recommended to check the official Mixpanel documentation or contact Mixpanel support directly.

How to get a Mixpanel developer account and API Keys?

To get a developer account for Mixpanel to create an API integration, you can follow these steps:

Sign up for a Mixpanel account

  1. Sign up for a free Mixpanel account at mixpanel.com. This will serve as your sandbox for building and testing your integration.

Create an Integration ID

  1. Define your Integration ID, which should be a string representing your company's or solution's name.

  2. Always include your Integration ID when sending event data or calling Mixpanel's APIs. This helps customers understand the source of their event data in Mixpanel.

Use the Integration ID in API calls

  1. For event tracking, include your Integration ID as the $source property value in the Event Object when using the Ingestion API.

  2. For other API usage, pass your Integration ID with every API call as the X-Mixpanel-Integration-ID header value.

What can you do with the Mixpanel API?

Based on the information provided, here are the key data models you can interact with using the Mixpanel API, along with what is possible for each:

Events

  • Describe actions that take place within your product
  • Contain properties that describe the action
  • Can be joined with user profiles, group profiles, and lookup tables
  • Include metadata like event name, timestamp, user ID, IP address, etc.
  • Can be queried, exported, and imported

User Profiles

  • Key-value store that holds state about a user
  • Joined to events on distinct_id
  • Can be queried and updated

Group Profiles

  • Key-value store that holds state about members of a group
  • Joined to events on a custom group key (e.g. company_id)
  • Can be queried and updated

Lookup Tables

  • Key-value store that holds state about an entity
  • Joined to events on a custom join key
  • Can be used to enrich event data
  • Cannot be used for unique analysis like funnels

Funnels

  • Can be queried to analyze user flows through a series of events
  • Limited to 15 day time windows due to API rate limits

Cohorts

  • Can be queried to get lists of users matching certain criteria

Revenue

  • Can query revenue data associated with events

Annotations

  • Can query and create annotations on your data

Raw Event Data

  • Can export raw event data for external analysis

Lexicon Schemas

  • Can manage data definitions and metadata

Key points:

  • Events are the core data model, with other models enriching the event data
  • User and group profiles allow analyzing by user/account
  • Lookup tables provide additional context but can't be used for unique analysis
  • API has rate limits that may affect syncing large date ranges
  • Some models like funnels have specific time window limitations