Swat.io Developer DocumentationSwat.io Developer Documentation
Home
Getting Started
  • Overview
  • Core Resources
  • Posts
  • Drafts
  • Campaigns
  • Asset Library
  • Inbox
  • Insights
MCP
Home
Getting Started
  • Overview
  • Core Resources
  • Posts
  • Drafts
  • Campaigns
  • Asset Library
  • Inbox
  • Insights
MCP
  • Insights

Insights

The Insights API provides report charts and tables for a workspace. It exposes the same report widgets used by Swat.io's internal reporting API.

See the API Overview for authentication, the API URL, rate limits, and error responses. You need the Premium Insights add-on, access to the requested workspace, and permission to view its reports.

Discover available widgets

The API is configuration-driven. Start with reportsWidgetsConfig and use the returned configuration to determine which widgets are available and how to query them. The query returns all available widget configurations.

To fetch a widget's data, use reportsWidgetChart when its kind is chart. Use reportsWidgetTable when its kind is table, table_summary, or table_top_content.

Use GraphQL introspection for the complete enum values and concrete fields. The configuration tells you which result type, filters, columns, and chart options apply to each widget.

Chart configuration

Select the configuration fields relevant to charts, then find the entry whose kind is chart and use its type in reportsWidgetChart.

Show chart configuration query
query chartWidgetConfiguration {
  reportsWidgetsConfig(workspace_id: <WORKSPACE_ID>) {
    type
    kind
    title
    description
    graphql_type
    channel_types
    supported_filters
    supports_compare_data
    chart_type
    supported_chart_types
    chart_x_axis_type
    chart_y_axis_type
    chart_series_label_type
    supported_time_aggregations
    chartLabels {
      label
      title
      title_short
      tooltip
      channel_types
    }
  }
}

chart_type, supported_chart_types, axis types, and label metadata describe how to interpret and render the chart. The type value is the widget identifier, such as channel_posts_chart.

Table configuration

Find the entry whose kind is a table, then use its type and graphql_type for the table query and its result fragment.

Show table configuration query
query tableWidgetConfiguration {
  reportsWidgetsConfig(workspace_id: <WORKSPACE_ID>) {
    type
    kind
    title
    description
    graphql_type
    channel_types
    supported_filters
    supports_pagination
    primary_column {
      column
      column_type
      title
      title_short
      tooltip
      sortable
      is_list
      is_hidden
      channel_types
    }
    tableColumns {
      column
      column_type
      title
      title_short
      tooltip
      sortable
      is_list
      is_hidden
      channel_types
    }
    table_column_default_sort
    table_column_default_sort_order
  }
}

For example, the post_performance_table configuration identifies the ReportsWidgetPostPerformanceTableList result type and describes the columns that can be requested. Table result fields vary by widget. Do not assume that fields from one table exist on another table.

Filters

reportsWidgetChart and reportsWidgetTable both require a filters object. Most filter fields are optional in the shared GraphQL input, but date_from, date_to, and channel_ids are required for these data queries. Each widget supports only the fields listed in its supported_filters configuration.

FieldTypeDescription
date_fromDateRequired start of the absolute reporting period.
date_toDateRequired end of the absolute reporting period.
channel_ids[ID!]Required channels in the workspace to include.
campaign_ids[ID!]Limit post-related metrics to campaigns.
tags[String!]Limit post-related results to posts with these tags.
tag_comments[String!]Limit comment-related results to comments with these tags.
ad_types[PostAdTypeEnum!]Filter by boosted, dark, and/or organic posts.
post_categories[ReportsWidgetPostCategoriesEnum!]Filter by post category.
time_aggregationReportsWidgetTimeAggregationsEnumAggregate chart data by daily, weekly, or monthly where supported.
limitIntLimit table rows where supported.
sortReportsWidgetTableColumnsEnumSelect the table column used for sorting where supported.
orderSortOrderEnumSelect ascending or descending order where supported.
table_columns[ReportsWidgetTableColumnsEnum!]Select and order table columns where supported.

Date ranges

  • Chart and table data queries require both date_from and date_to.
  • The two absolute date fields must be provided together.
  • The range must not end in the future.
  • A range cannot exceed 12 months, subject to the workspace's reporting history and product-tier limits.
  • Dates are interpreted using the workspace/user timezone and converted for the report query.
  • date_relative_number and date_relative_unit are available in the shared filter input, but relative dates are not supported by these data queries.
  • Negative relative date numbers are not valid.

Widget-specific validation is applied after the common input is parsed. A filter being present in the GraphQL input does not mean every widget accepts it. Check supported_filters before constructing a request.

Charts

Charts return a list of series. The series label is a GraphQL union, so select the label fields with inline fragments for the label types you support.

query postEngagementsChart {
  reportsWidgetChart(
    workspace_id: <WORKSPACE_ID>
    filters: {
      date_from: "2026-01-01"
      date_to: "2026-01-31"
      channel_ids: [<CHANNEL_ID>]
      time_aggregation: weekly
    }
    type: post_engagements_chart
  ) {
    label {
      ... on ReportsWidgetChartSeriesLabelChannel {
        channel {
          id
          name
        }
      }
      ... on ReportsWidgetChartSeriesLabelCampaign {
        campaign {
          id
          name
        }
      }
      ... on ReportsWidgetChartSeriesLabelString {
        value
      }
      ... on ReportsWidgetChartSeriesLabelTag {
        value
      }
    }
    data
  }
}

For performance reasons, data is a JSON-encoded string rather than a GraphQL list. Decode it in the client. Its value is an array of date/value pairs, for example:

[[20260101, 12], [20260108, 18], [20260115, null]]

The exact label variant depends on the selected widget. Use chart_series_label_type and GraphQL introspection to determine the relevant fragment.

Tables and pagination

Tables return ReportsWidgetTableResultUnion. Select the concrete result type with an inline fragment. This example uses the post performance table exposed by the configuration as ReportsWidgetPostPerformanceTableList.

query postPerformanceTable {
  reportsWidgetTable(
    workspace_id: <WORKSPACE_ID>
    filters: {
      date_from: "2026-01-01"
      date_to: "2026-01-31"
      channel_ids: [<CHANNEL_ID>]
      limit: 25
    }
    type: post_performance_table
  ) {
    __typename
    ... on ReportsWidgetPostPerformanceTableList {
      items {
        id
        post {
          channel {
            id
            name
          }
        }
        campaign {
          id
          name
          color_number
        }
        comment_count
        impressions
        impressions_unique
        interaction_rate_impressions
        interaction_rate_reach
        interactions
        link_clicks
        publication_at
        reactions
        share_rate_impressions
        share_rate_reach
        shares
        short_url_clicks
        tags
      }
      pagination {
        after
      }
    }
  }
}

If pagination.after is non-null, pass it as the top-level after argument in the next request. Keep the same widget type and filters.

query nextPostPerformanceTable {
  reportsWidgetTable(
    after: "<AFTER_CURSOR>"
    workspace_id: <WORKSPACE_ID>
    filters: {
      date_from: "2026-01-01"
      date_to: "2026-01-31"
      channel_ids: [<CHANNEL_ID>]
      limit: 25
    }
    type: post_performance_table
  ) {
    ... on ReportsWidgetPostPerformanceTableList {
      items {
        id
        publication_at
        interactions
      }
      pagination {
        after
      }
    }
  }
}

Only widgets with supports_pagination: true should be paginated. The exact row fields and cursor behavior are widget-specific.

Schema exploration

The Insights API intentionally uses GraphQL unions and many widget-specific types. Use introspection in Bruno, Postman, or another GraphQL client to explore:

  • All chart and table enum values.
  • The concrete result type for each widget.
  • The fields available on each table row.
  • Enum values for filters, sorting, aggregation, and channel types.
  • The complete configuration response.

The configuration response is the source of truth for which widgets and filters are available to the authenticated customer in a workspace.