### List Pipeline Logs - Ruby Example Source: https://developer.mixpanel.com/reference/list-warehouse-pipeline-sync-dates This Ruby script shows how to make a GET request to the 'List Pipeline Logs' endpoint. It handles authentication and parameter inclusion for the API call. ```ruby require 'httparty' server = 'data' # or 'data-eu', 'data-in' project_id = 12345 pipeline_name = 'my-pipeline' api_key = 'YOUR_API_KEY' # Replace with your API key url = "https://#{server}.mixpanel.com/api/2.0/nessie/pipeline/timeline" options = { query: { project_id: project_id, name: pipeline_name }, headers: { 'Authorization' => "Basic #{Base64.strict_encode64(api_key)}" } } response = HTTParty.get(url, options) if response.success? puts response.parsed_response else puts "Error fetching pipeline logs: #{response.code} - #{response.message}" end ``` -------------------------------- ### Export Data with Ruby Source: https://developer.mixpanel.com/reference/export This Ruby example demonstrates fetching data from the Mixpanel export API using the 'httparty' gem. It covers setting up the GET request with the necessary URL, parameters, and headers. ```ruby require 'httparty' url = "https://{server}.mixpanel.com/api/2.0/export" options = { query: { from_date: "2023-01-01", to_date: "2023-01-31" }, headers: { "accept" => "text/plain" } } response = HTTParty.get(url, options) if response.code == 200 puts response.body else puts "Error: #{response.code}" puts response.body end ``` -------------------------------- ### List Pipeline Logs - JavaScript Example Source: https://developer.mixpanel.com/reference/list-warehouse-pipeline-sync-dates A JavaScript example using the `fetch` API to call the 'List Pipeline Logs' endpoint. It demonstrates constructing the URL, setting headers for authentication, and handling the JSON response. ```javascript async function listPipelineLogs() { const server = 'data'; // or 'data-eu', 'data-in' const projectId = 12345; const pipelineName = 'my-pipeline'; const apiKey = 'YOUR_API_KEY'; // Replace with your API key const url = `${server}.mixpanel.com/api/2.0/nessie/pipeline/timeline?project_id=${projectId}&name=${pipelineName}`; const encodedApiKey = btoa(apiKey); try { const response = await fetch(`https://${url}`, { method: 'GET', headers: { 'Authorization': `Basic ${encodedApiKey}` } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); console.log(data); } catch (error) { console.error('Error fetching pipeline logs:', error); } } listPipelineLogs(); ``` -------------------------------- ### List Pipeline Logs - Node.js Example Source: https://developer.mixpanel.com/reference/list-warehouse-pipeline-sync-dates This Node.js example illustrates how to fetch pipeline logs using the Mixpanel API. It includes setting up the request with relevant headers and query parameters. ```javascript const axios = require('axios'); const server = 'data'; // or 'data-eu', 'data-in' const projectId = 12345; const pipelineName = 'my-pipeline'; const apiKey = 'YOUR_API_KEY'; // Replace with your API key axios.get(`https://${server}.mixpanel.com/api/2.0/nessie/pipeline/timeline`, { params: { project_id: projectId, name: pipelineName }, headers: { 'Authorization': `Basic ${Buffer.from(apiKey).toString('base64')}` } }) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error fetching pipeline logs:', error); }); ``` -------------------------------- ### Fetch Profile Event Activity (Node.js) Source: https://developer.mixpanel.com/reference/activity-feed Example using Node.js to fetch the activity feed for specified users. Demonstrates making a GET request to the Profile Event Activity API endpoint. ```javascript // Node.js example (using fetch API) const options = { method: 'GET', headers: { 'accept': 'application/json' } }; fetch('https://mixpanel.com/api/query/stream/query?distinct_ids=%5B%2212a34aa567eb8d-9ab1c26f345b67-89123c45-6aeaa7-89f12af345f678%22%5D&from_date=2023-01-01&to_date=2023-01-31', options) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err)); ``` -------------------------------- ### Get Website Details Source: https://developer.mixpanel.com/reference/get-service-account Retrieves detailed information about a specific website project. ```APIDOC ## GET /websites/developer_mixpanel ### Description Retrieves detailed information about a specific website project, identified by its project path. ### Method GET ### Endpoint /websites/developer_mixpanel ### Parameters #### Path Parameters - **project** (string) - Required - The unique identifier for the website project. ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **websiteId** (string) - The unique identifier of the website. - **websiteName** (string) - The name of the website. - **projectId** (string) - The identifier of the project the website belongs to. - **createdAt** (string) - The timestamp when the website was created. #### Response Example ```json { "websiteId": "507f1f77bcf86cd799439011", "websiteName": "Developer Mixpanel", "projectId": "dev-project-123", "createdAt": "2023-10-27T10:00:00Z" } ``` #### Error Response (404) - **error** (string) - Details about the error that occurred. - **status** (string) - "error" #### Response Example (404) ```json { "error": "Website not found.", "status": "error" } ``` ``` -------------------------------- ### Get Annotation Tags API Request (Node.js) Source: https://developer.mixpanel.com/reference/get-annotation-tags This snippet shows how to fetch annotation tags using Node.js with the 'got' library. It makes a GET request to the API endpoint and expects a JSON response. Ensure you have 'got' installed (`npm install got`). ```javascript import got from 'got'; (async () => { try { const response = await got('https://mixpanel.com/api/app/projects/projectId/annotations/tags', { headers: { 'accept': 'application/json' } }); const data = JSON.parse(response.body); console.log(data); } catch (error) { console.error(error); } })(); ``` -------------------------------- ### Get Annotation Tags API Request (Python) Source: https://developer.mixpanel.com/reference/get-annotation-tags This snippet illustrates how to fetch annotation tags using Python's 'requests' library. It sends a GET request to the API endpoint and handles the JSON response. Make sure to install 'requests' (`pip install requests`). ```python import requests url = "https://mixpanel.com/api/app/projects/projectId/annotations/tags" headers = { "accept": "application/json" } try: response = requests.get(url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes data = response.json() print(data) except requests.exceptions.RequestException as e: print(f"Error: {e}") ``` -------------------------------- ### Project Websites API Source: https://developer.mixpanel.com/reference/profile-set-property-once This section details the API endpoints for managing project websites. ```APIDOC ## POST /websites/developer_mixpanel ### Description Creates a new project website. ### Method POST ### Endpoint /websites/developer_mixpanel ### Parameters #### Request Body - **name** (string) - Required - The name of the project website. - **url** (string) - Required - The URL of the project website. ### Request Example ```json { "name": "My Awesome Website", "url": "https://example.com" } ``` ### Response #### Success Response (201) - **id** (string) - The unique identifier of the created project website. - **name** (string) - The name of the project website. - **url** (string) - The URL of the project website. #### Response Example ```json { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "name": "My Awesome Website", "url": "https://example.com" } ``` ## GET /websites/developer_mixpanel/{websiteId} ### Description Retrieves a specific project website by its ID. ### Method GET ### Endpoint /websites/developer_mixpanel/{websiteId} ### Parameters #### Path Parameters - **websiteId** (string) - Required - The ID of the project website to retrieve. ### Response #### Success Response (200) - **id** (string) - The unique identifier of the project website. - **name** (string) - The name of the project website. - **url** (string) - The URL of the project website. #### Response Example ```json { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "name": "My Awesome Website", "url": "https://example.com" } ``` ## PUT /websites/developer_mixpanel/{websiteId} ### Description Updates an existing project website. ### Method PUT ### Endpoint /websites/developer_mixpanel/{websiteId} ### Parameters #### Path Parameters - **websiteId** (string) - Required - The ID of the project website to update. #### Request Body - **name** (string) - Optional - The updated name of the project website. - **url** (string) - Optional - The updated URL of the project website. ### Request Example ```json { "name": "Updated Website Name" } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the updated project website. - **name** (string) - The updated name of the project website. - **url** (string) - The updated URL of the project website. #### Response Example ```json { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "name": "Updated Website Name", "url": "https://example.com" } ``` ## DELETE /websites/developer_mixpanel/{websiteId} ### Description Deletes a project website by its ID. ### Method DELETE ### Endpoint /websites/developer_mixpanel/{websiteId} ### Parameters #### Path Parameters - **websiteId** (string) - Required - The ID of the project website to delete. ### Response #### Success Response (204) No content is returned upon successful deletion. ``` -------------------------------- ### Fetch Profile Event Activity (Python) Source: https://developer.mixpanel.com/reference/activity-feed Example using Python to fetch the activity feed for specified users. Utilizes the 'requests' library for making HTTP GET requests. ```python # Python example (using requests library) import requests url = "https://mixpanel.com/api/query/stream/query" params = { "distinct_ids": '["12a34aa567eb8d-9ab1c26f345b67-89123c45-6aeaa7-89f12af345f678"]', "from_date": "2023-01-01", "to_date": "2023-01-31" } headers = { "accept": "application/json" } response = requests.get(url, params=params, headers=headers) print(response.json()) ``` -------------------------------- ### List Pipeline Logs - Python Example Source: https://developer.mixpanel.com/reference/list-warehouse-pipeline-sync-dates This Python script utilizes the `requests` library to interact with the 'List Pipeline Logs' endpoint. It shows how to authenticate using Basic Auth and pass query parameters. ```python import requests import base64 server = 'data' # or 'data-eu', 'data-in' project_id = 12345 pipeline_name = 'my-pipeline' api_key = 'YOUR_API_KEY' # Replace with your API key url = f"https://{server}.mixpanel.com/api/2.0/nessie/pipeline/timeline" params = { 'project_id': project_id, 'name': pipeline_name } headers = { 'Authorization': f"Basic {base64.b64encode(api_key.encode()).decode()}" } try: response = requests.get(url, params=params, headers=headers) response.raise_for_status() # Raise an exception for bad status codes print(response.json()) except requests.exceptions.RequestException as e: print(f"Error fetching pipeline logs: {e}") ``` -------------------------------- ### Create Data Retrieval Job - cURL Source: https://developer.mixpanel.com/reference/create-a-retrieval Example of how to create a data retrieval job using cURL. This demonstrates the POST request to the Mixpanel API endpoint, including necessary headers. ```shell curl --request POST \ --url https://mixpanel.com/api/app/data-retrievals/v3.0 \ --header 'accept: application/json' \ --header 'content-type: application/json' ``` -------------------------------- ### Mixpanel Retention Report API cURL Request Source: https://developer.mixpanel.com/reference/retention A cURL command to make a GET request to the Mixpanel Retention Report API. This example shows how to specify the unbounded_retention parameter and accept JSON responses. ```shell curl --request GET \ --url 'https://mixpanel.com/api/query/retention?unbounded_retention=false' \ --header 'accept: application/json' ``` -------------------------------- ### POST /websites/developer_mixpanel/run_import Source: https://developer.mixpanel.com/reference/run-an-import-1 This API endpoint triggers an immediate sync for a given warehouse import. ```APIDOC ## POST /websites/developer_mixpanel/run_import ### Description This API endpoint triggers an immediate sync for a given warehouse import. ### Method POST ### Endpoint /websites/developer_mixpanel/run_import ### Parameters #### Query Parameters - **project_id** (string) - Required - The ID of the project to run the import for. ### Request Body None ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **message** (string) - A confirmation message. #### Response Example { "status": "success", "message": "Import sync triggered successfully." } ``` -------------------------------- ### Delete Annotation using Node.js Source: https://developer.mixpanel.com/reference/delete-annotation This Node.js example shows how to delete a Mixpanel annotation using the 'mixpanel' SDK. It assumes the SDK is installed and authenticated, and focuses on the function call to remove an annotation by its project and annotation IDs. ```javascript const Mixpanel = require('mixpanel'); const mixpanel = Mixpanel.init('YOUR_MIXPANEL_API_SECRET'); mixpanel.annotations.delete(projectId, annotationId).then(response => { console.log('Annotation deleted successfully:', response); }).catch(error => { console.error('Error deleting annotation:', error); }); ``` -------------------------------- ### Query Segmentation Report using cURL Source: https://developer.mixpanel.com/reference/segmentation Example of how to make a GET request to the Mixpanel Query API's segmentation endpoint using cURL. This demonstrates the basic structure of the request, including the URL and accepted header. ```shell curl --request GET \ --url https://mixpanel.com/api/query/segmentation \ --header 'accept: application/json' ``` -------------------------------- ### Warehouse Connectors API Source: https://developer.mixpanel.com/reference Use the Warehouse Connectors API to manually run a warehouse imports. ```APIDOC ## Warehouse Connectors API ### Description Use the Warehouse Connectors API to manually run a warehouse imports. ### Servers - **Standard Server:** `mixpanel.com/api/app/projects` - **EU Residency Server:** `eu.mixpanel.com/api/app/projects` - **India Residency Server:** `in.mixpanel.com/api/app/projects` ``` -------------------------------- ### Aggregate Event Counts using Node.js Source: https://developer.mixpanel.com/reference/event-breakdown Node.js example for aggregating event counts. This snippet shows how to make a GET request to the Mixpanel API using the 'axios' library, including essential query parameters and headers. -------------------------------- ### Python Mixpanel Integration Example Source: https://developer.mixpanel.com/reference/delete-service-account This snippet demonstrates basic integration with Mixpanel using Python. It requires the 'mixpanel' library. The code sends an event to Mixpanel. ```python import mixpanel # Replace with your actual Mixpanel token MIXPANEL_TOKEN = "YOUR_MIXPANEL_TOKEN" mixpanel = mixpanel.Mixpanel(MIXPANEL_TOKEN) def track_signup_event(user_id): """Tracks a user signup event in Mixpanel.""" mixpanel.track(user_id, 'Signed Up', { 'source': 'web' }) # Example usage: track_signup_event('user123') print("Signup event tracked.") ``` -------------------------------- ### Warehouse Connectors API Source: https://developer.mixpanel.com/index Use the Warehouse Connectors API to manually run a warehouse imports. ```APIDOC ## Warehouse Connectors API ### Description Use the Warehouse Connectors API to manually run a warehouse imports. ### Servers * Standard: `mixpanel.com/api/app/projects` * EU Residency: `eu.mixpanel.com/api/app/projects` * India Residency: `in.mixpanel.com/api/app/projects` ``` -------------------------------- ### Aggregate Event Counts using cURL Source: https://developer.mixpanel.com/reference/event-breakdown Example cURL request to aggregate event counts. This demonstrates a GET request to the Mixpanel API endpoint with specified query parameters for event type, unit, and acceptance of JSON. ```shell curl --request GET \ --url 'https://mixpanel.com/api/query/events?type=general&unit=minute' \ --header 'accept: application/json' ``` -------------------------------- ### List Annotations using cURL Source: https://developer.mixpanel.com/reference/retrieve-annotations This snippet demonstrates how to list all annotations in a Mixpanel project using cURL. It requires the project ID and optionally accepts date range filters. The example shows a basic GET request with an accept header for JSON. ```shell curl --request GET \ --url https://mixpanel.com/api/app/projects/projectId/annotations \ --header 'accept: application/json' ``` -------------------------------- ### POST /websites/developer_mixpanel/export Source: https://developer.mixpanel.com/reference/create-warehouse-pipeline Initiates an export of website data. You can specify event filters, data format, and destination details for S3 or AWS Glue. ```APIDOC ## POST /websites/developer_mixpanel/export ### Description Initiates an export of website data. You can specify event filters, data format, and destination details for S3 or AWS Glue. ### Method POST ### Endpoint /websites/developer_mixpanel/export ### Parameters #### Query Parameters - **frequency** (string) - Optional - Controls the export frequency. Can be `hourly` or `daily`. - **events** (string) - Optional - A whitelist for specific events to export. Can be specified multiple times for multiple events. - **where** (string) - Optional - A selector expression to filter event data. Only valid when `data_source` is `events`. - **data_format** (string) - Optional - The file format for the exported data. Can be `json` or `parquet`. Defaults to `json`. - **s3_bucket** (string) - Optional - The S3 bucket name for exporting data. - **s3_region** (string) - Optional - The AWS region for the S3 bucket. - **s3_role** (string) - Optional - The AWS IAM role for S3 access. - **s3_prefix** (string) - Optional - The S3 path prefix for the export. - **s3_encryption** (string) - Optional - At rest encryption for the S3 bucket. Can be `none`, `aes`, or `kms`. Defaults to `none`. - **s3_kms_key_id** (string) - Optional - The KMS key ID to use if `s3_encryption` is set to `kms`. - **use_glue** (boolean) - Optional - Whether to use AWS Glue schema export. Defaults to `false`. - **glue_database** (string) - Optional - Required if `use_glue` is `true`. The AWS Glue database name. - **glue_role** (string) - Optional - Required if `use_glue` is `true`. The AWS IAM role for Glue access. - **glue_table_prefix** (string) - Optional - A prefix to add to table names when creating them in Glue. ### Request Body (No request body is specified for this endpoint in the provided documentation) ### Request Example (No example provided for this endpoint) ### Response #### Success Response (200) (Response details not provided in the documentation) #### Response Example (No example provided for this endpoint) ``` -------------------------------- ### Check Deletion Status in Node.js Source: https://developer.mixpanel.com/reference/check-status-of-deletion This Node.js example shows how to make a GET request to the Mixpanel API to check the status of a data deletion task. Ensure you have your project token and the tracking ID. The function returns the status of the deletion job. ```javascript const axios = require('axios'); const options = { method: 'GET', url: 'https://{regionAndDomain}.com/api/app/data-deletions/v3.0/{tracking_id}', params: {token: 'YOUR_PROJECT_TOKEN'}, headers: { accept: 'application/json' } }; axios .request(options) .then(function (response) { console.log(response.data); }) .catch(function (error) { console.error(error); }); ``` -------------------------------- ### Schematized BigQuery Pipeline Configuration Source: https://developer.mixpanel.com/reference/create-warehouse-pipeline Configuration for setting up a BigQuery pipeline with options for schema type, data source, and synchronization. ```APIDOC ## Schematized BigQuery Pipeline Configuration ### Description This outlines the parameters for configuring a BigQuery data pipeline. You can specify schema handling, data source (events or people), and synchronization behavior. ### Method POST ### Endpoint `/api/pipelines/bigquery` ### Parameters #### Request Body - **project_id** (number) - Required - Your project id (must be specified when using service account based authentication). - **type** (string) - Required - Pipeline type. Allowed values: `gcs-raw`, `s3-raw`, `azure-raw`, `bigquery`, `snowflake`, `aws`, `azure-blob`, `gcs-schema`. - **trial** (boolean) - Optional - Default: `false`. If true, a trial pipeline is created, exporting data for thirty days starting from the previous day. - **schema_type** (string) - Optional - Default: `monoschema`. Allowed values: `monoschema`, `multischema`. Determines how events are loaded into tables. - **data_source** (string) - Optional - Default: `events`. Allowed values: `events`, `people`. Specifies whether to export event or user data. - **sync** (boolean) - Optional - Default: `false`. If true, exported data is updated with any changes in your Mixpanel dataset. - **from_date** (string) - Required - The starting date of the export window in `YYYY-MM-DD` format. Cannot be more than six months in the past. Defaults to the previous day if `trial` is true. - **to_date** (string) - Optional - The end date of the export window in `YYYY-MM-DD` format. ### Request Example ```json { "project_id": 12345, "type": "bigquery", "schema_type": "multischema", "data_source": "events", "sync": true, "from_date": "2023-01-01", "to_date": "2023-01-31" } ``` ### Response #### Success Response (200) - **pipeline_id** (string) - The unique identifier for the created BigQuery pipeline. - **status** (string) - The current status of the pipeline. #### Response Example ```json { "pipeline_id": "bq-pipeline-abc123xyz", "status": "active" } ``` ``` -------------------------------- ### Check Retrieval Status with PHP Source: https://developer.mixpanel.com/reference/check-status-of-retrieval A PHP example for checking data retrieval job status via the Mixpanel API. This snippet utilizes cURL functions to perform the HTTP GET request, passing the tracking ID and authentication token in the request headers. ```php ``` -------------------------------- ### Azure Raw Pipeline Configuration Source: https://developer.mixpanel.com/reference/create-warehouse-pipeline Configuration details for setting up an Azure Raw data export pipeline. This includes specifying credentials and container information for data transfer. ```APIDOC ## Azure Raw Pipeline Configuration ### Description This section details the parameters required to configure an Azure Raw data export pipeline. It includes settings for authentication and destination storage. ### Parameters #### Request Body - **prefix** (string) - Optional - A custom prefix for all the data being exported to the container. - **client_id** (string) - Required - `clientId` from the Service Principal credentials. - **client_secret** (string) - Required - `clientSecret` from the Service Principal credentials. - **tenant_id** (string) - Required - `tenantId` from the Service Principal credentials. This is specific to the Active Directory instance where the Service Principal resides. ### Request Example ```json { "prefix": "my-custom-prefix", "client_id": "your_client_id", "client_secret": "your_client_secret", "tenant_id": "your_tenant_id" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating successful configuration. #### Response Example ```json { "message": "Azure Raw pipeline configured successfully." } ``` ``` -------------------------------- ### Check Retrieval Status with Node.js Source: https://developer.mixpanel.com/reference/check-status-of-retrieval Example of checking data retrieval job status using Node.js. This code makes an HTTP GET request to the Mixpanel API, requiring the tracking ID and project token. It handles JSON responses for status and results. ```javascript // Node.js example requires an HTTP client library like 'axios' or 'node-fetch' // const axios = require('axios'); // const trackingId = 'YOUR_TRACKING_ID'; // const token = 'YOUR_PROJECT_TOKEN'; // // axios.get(`https://{regionAndDomain}.com/api/app/data-retrievals/v3.0/${trackingId}`, { // headers: { // 'accept': 'application/json', // 'Authorization': `Bearer ${token}` // Assuming token is used as Bearer // } // }) // .then(response => { // console.log(response.data); // }) // .catch(error => { // console.error('Error checking status:', error); // }); ``` -------------------------------- ### Create Annotation via cURL Source: https://developer.mixpanel.com/reference/create-annotations This cURL example demonstrates how to make a POST request to create an annotation. It includes setting the content type and the target URL with placeholder project ID. ```shell curl --request POST \ --url https://mixpanel.com/api/app/projects/projectId/annotations \ --header 'accept: application/json' \ --header 'content-type: application/json' ``` -------------------------------- ### GET /api/app/data-retrievals/v3.0/ Source: https://developer.mixpanel.com/reference/gdpr-api Checks the status of a data retrieval job using its tracking ID. This endpoint returns the current status of the data retrieval process, which can be one of several states including PENDING, STAGING, STARTED, SUCCESS, FAILURE, REVOKED, NOT_FOUND, or UNKNOWN. ```APIDOC ## GET /api/app/data-retrievals/v3.0/ ### Description Checks the status of a data retrieval job. ### Method GET ### Endpoint `https://mixpanel.com/api/app/data-retrievals/v3.0/` ### Parameters #### Query Parameters - **token** (String) - Required - Your Mixpanel project token. #### Path Parameters - **tracking_id** (String) - Required - The tracking ID of the data retrieval job. #### Request Headers - **Authorization** (String) - Required - Bearer token for authentication. Example: `Bearer ` ### Request Example ```bash curl "https://mixpanel.com/api/app/data-retrievals/v3.0/1583958896131033662/?token=591b3354bb2bdd96f72f23bf56911673" -H "Authorization: Bearer vZcErNw8JCq42BZUJyWoZmDWCKBxXc" ``` ### Response #### Success Response (200) - **results** (Object) - Contains the status of the retrieval job. - **status** (String) - The current status of the retrieval job. Possible values: `PENDING`, `STAGING`, `STARTED`, `SUCCESS`, `FAILURE`, `REVOKED`, `NOT_FOUND`, `UNKNOWN`. #### Response Example ```json { "status": "ok", "results": { "status": "PENDING", "result": "", "distinct_ids": ["1"] } } ``` ``` -------------------------------- ### Create or Update Website Source: https://developer.mixpanel.com/reference/delete-profile This endpoint allows for the creation or updating of website configurations within the Developer Mixpanel project. It accepts a website object with project details and returns status information. ```APIDOC ## POST /websites/developer_mixpanel ### Description Creates or updates a website configuration. ### Method POST ### Endpoint /websites/developer_mixpanel ### Parameters #### Request Body - **websites** (object) - Required - An array of website objects to be created or updated. - **name** (string) - Required - The name of the website. - **project_token** (string) - Required - The Mixpanel project token. - **secret** (string) - Required - The Mixpanel project secret. ### Request Example ```json { "websites": [ { "name": "example.com", "project_token": "YOUR_PROJECT_TOKEN", "secret": "YOUR_PROJECT_SECRET" } ] } ``` ### Response #### Success Response (200) - **status** (object) - Contains validation status for the provided data. - **Valid Data** (object) - **value** (integer) - `1` if one or more objects are valid, `0` otherwise. - **Invalid Data** (object) - **value** (integer) - `0` if no data objects in the body are valid. #### Response Example ```json { "status": { "Valid Data": { "value": 1 }, "Invalid Data": { "value": 0 } } } ``` #### Error Responses - **401 Unauthorized** - **error** (string) - Error message. - **status** (string) - "error" - **403 Forbidden** - **error** (string) - Error message. - **status** (string) - "error" ``` -------------------------------- ### Get Annotation Tags API Request (cURL) Source: https://developer.mixpanel.com/reference/get-annotation-tags This snippet demonstrates how to make a GET request to the 'Get Annotation Tags' API endpoint using cURL. It includes the necessary URL and headers for the request. The response will be a JSON array of tag objects. ```shell curl --request GET \ --url https://mixpanel.com/api/app/projects/projectId/annotations/tags \ --header 'accept: application/json' ``` -------------------------------- ### Query Events Using Parameters for Date Ranges and Event Names Source: https://developer.mixpanel.com/docs/jql-overview Demonstrates how to use query parameters to make JQL queries more flexible and reusable. This example shows how to pass start date, end date, and a specific event name dynamically to the Events() function and filter results accordingly. This improves code reusability across different date ranges and events. ```javascript function main() { return Events({ from_date: params.start_date, to_date: params.end_date, }).filter(function(event) { return event.name == params.event }) } ``` -------------------------------- ### Raw Azure Pipeline Configuration Source: https://developer.mixpanel.com/reference/create-warehouse-pipeline This section details the configuration parameters for setting up a 'Raw Azure Pipeline' to export Mixpanel data to Azure Blob Storage. ```APIDOC ## POST /websites/developer_mixpanel/export/azure ### Description Configures and initiates a data export pipeline to Azure Blob Storage. ### Method POST ### Endpoint `/websites/developer_mixpanel/export/azure` ### Parameters #### Request Body - **project_id** (number) - Required - Your project id (must be specified when using service account based authentication). - **type** (string) - Required - Must be `azure-raw` for this pipeline type. - **trial** (boolean) - Optional - Defaults to `false`. If `true`, creates a trial pipeline exporting data from the previous day for thirty days. - **data_source** (string) - Optional - Defaults to `events`. Specifies the data to export, currently only `events` is supported. - **from_date** (date) - Required (unless `trial` is true) - The starting date of the export window in `YYYY-MM-DD` format. Cannot be more than six months in the past. - **to_date** (date) - Optional - The ending date of the export window in `YYYY-MM-DD` format. If omitted, the export continues indefinitely. - **frequency** (string) - Optional - Defaults to `daily`. Can be `daily` or `hourly`. Only applicable if `to_date` is not specified. - **events** (string) - Optional - A whitelist for specific events to export. Can be provided multiple times for multiple events. If omitted, all events are exported. - **where** (string) - Optional - An event selector expression to filter data. See [Segmentation Expressions](ref:segmentation-expressions) for details. - **data_format** (string) - Optional - Defaults to `json`. Specifies the file format, currently only `json` is supported. - **storage_account** (string) - Required - The Azure Blob Storage account name. - **container_name** (string) - Required - The name of the Blob Container within the storage account. ### Request Example ```json { "project_id": 12345, "type": "azure-raw", "from_date": "2023-10-26", "storage_account": "myazuresa", "container_name": "mixpanel-exports" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the pipeline setup was successful. #### Response Example ```json { "message": "Azure Raw Pipeline configured successfully." } ``` ``` -------------------------------- ### API Sample Request Languages Source: https://developer.mixpanel.com/reference/create-identity Lists the programming languages supported for generating sample API requests. These languages allow developers to quickly integrate with the API. ```curl curl ``` ```node node ``` ```ruby ruby ``` ```javascript javascript ``` ```python python ``` -------------------------------- ### Get Annotation Tags API Request (PHP) Source: https://developer.mixpanel.com/reference/get-annotation-tags This snippet shows how to retrieve annotation tags in PHP using cURL. It performs a GET request to the API endpoint and processes the JSON response. This is a common method for interacting with RESTful APIs in PHP. ```php ``` -------------------------------- ### List Pipeline Logs - cURL Example Source: https://developer.mixpanel.com/reference/list-warehouse-pipeline-sync-dates This snippet demonstrates how to call the 'List Pipeline Logs' endpoint using cURL. It shows the necessary parameters and the expected structure of the request. ```curl curl -X GET \ 'https://{server}.mixpanel.com/api/2.0/nessie/pipeline/timeline?project_id=12345&name=my-pipeline' \ -H 'Authorization: Basic YOUR_API_KEY' ``` -------------------------------- ### Get Annotation Tags API Request (Ruby) Source: https://developer.mixpanel.com/reference/get-annotation-tags This snippet demonstrates fetching annotation tags in Ruby using the Net::HTTP library. It constructs a GET request to the specified API endpoint and parses the JSON response. This code assumes a basic Ruby environment. ```ruby require 'net/http' require 'uri' require 'json' uri = URI.parse('https://mixpanel.com/api/app/projects/projectId/annotations/tags') response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| request = Net::HTTP::Get.new(uri) request['accept'] = 'application/json' http.request(request) end data = JSON.parse(response.body) puts data ``` -------------------------------- ### Resume Pipeline API Request (cURL) Source: https://developer.mixpanel.com/reference/resume-pipelines This example demonstrates how to resume a Mixpanel pipeline using cURL. It specifies the POST request, URL, and necessary headers for content type and acceptance of JSON. ```shell curl --request POST \ --url https://data.mixpanel.com/api/2.0/nessie/pipeline/resume \ --header 'accept: application/json' \ --header 'content-type: application/x-www-form-urlencoded' ``` -------------------------------- ### GET /funnels Source: https://developer.mixpanel.com/reference/funnels-query Retrieves data for a specified funnel report. This endpoint allows you to query saved Funnels reports and get detailed insights into user progression. ```APIDOC ## GET /funnels ### Description Get data for a funnel. The Query API has a rate limit of 60 queries per hour and a maximum of 5 concurrent queries. ### Method GET ### Endpoint /funnels ### Parameters #### Query Parameters - **project_id** (integer) - Required - Required if using service account to authenticate request. - **workspace_id** (integer) - Optional - The id of the workspace if applicable. - **funnel_id** (integer) - Required - The funnel that you wish to get data for. - **from_date** (string) - Required - The date in yyyy-mm-dd format to begin querying from. This date is inclusive. - **to_date** (string) - Required - The date in yyyy-mm-dd format to query to. This date is inclusive. - **length** (integer) - Optional - The number of units (defined by length_unit) each user has to complete the funnel, starting from the time they triggered the first step in the funnel. May not be greater than 90 days. Note that we will query for events past the end of to_date to look for funnel completions. This defaults to the value that was previously saved in the UI for this funnel. - **length_unit** (string) - Optional - The unit applied to the length parameter can be "second", "minute", "hour", or "day". Defaults to the value that was previously saved in the UI for this funnel. Example: `day` - **interval** (integer) - Optional - The number of days you want each bucket to contain. The default value is 1. - **unit** (string) - Optional - This is an alternate way of specifying interval and can be "day", "week", or "month". - **on** (string) - Optional - The property expression to segment the event on. See the [expression to segment](ref:segmentation-expressions) below. - **where** (string) - Optional - The property expression to filter events. See the [expression to filter](ref:filtering-expressions) below. ### Request Example ```json { "example": "Not applicable for GET request" } ``` ### Response #### Success Response (200) - **data** (array) - An array of objects, where each object represents a time interval and includes funnel completion data. - **meta** (object) - Metadata about the query, including date ranges and funnel details. #### Response Example ```json { "example": { "data": [ { "date": "2023-10-26", "completed": 150, "dropped": 50, "total": 200 } ], "meta": { "funnel_id": 12345, "from_date": "2023-10-26", "to_date": "2023-10-26", "length": 7, "length_unit": "day" } } } ``` ```