Owned Social Analytics - API Quickstart
In this tutorial we’ll cover the basics of accessing owned social analytics features using the API.
Note that you need access to the Meltwater API, plus Engage or Social Analytics features in the Meltwater application to use these features.
Before you start
To run through this tutorial, you will need:
- Your Meltwater API token
- An owned social connection configured for your Meltwater account
Authentication
To call any of the endpoints in this guide you need to provide your API token as a header called apikey
, for example:
For full details take a look at the Authentication page.
Fetching your connected accounts
When calling the API to fetch owned social analytics you must provide the account IDs you would like data for.
You can fetch your list of accounts by calling the GET /v3/owned/accounts
endpoint:
The response will be similar to the following:
Here you are fetching the accounts that you have set up owned connections for in the Meltwater application. For each account you’ll see an id
, which you’ll use in the account_ids
parameter when fetching metrics and analytics.
Note that all your connections are returned in this one call, regardless of the social network the connection is for.
Fetching numeric account metrics
The API supports a number of account-level metrics. You can fetch these metrics to report the performance of your owned social accounts.
First we’ll take a look at ‘numeric’ metrics (basic metrics like the number of page fans), later in the guide we’ll look at demographic metrics and analytics.
Understanding which metrics are available
The metrics available for each of your accounts depends on the social network they belong to, currently supported networks include:
Facebook
Instagram
LinkedIn
X
Tiktok
As we expect this list to grow over time, we provide a full list of metrics per network on the Social Analytics Metrics page. Metrics on this page are listed by source, then whether they are account-level or post-level, and finally by type.
You can also call the GET /v3/owned/supported_metrics
endpoint to programmatically fetch the list of supported metrics.
Making an API call
You can fetch numeric account metrics by calling the GET /v3/owned/accounts/metrics/numeric
endpoint.
Note this endpoint only supports int
and float
account metrics. There are separate endpoints for breakdown
, nested-breakdown
and heatmap
typed account metrics.
When fetching account metrics you provide the following parameters:
source
: The social network of the accounts you are requesting (for examplefacebook
)account_ids
: One or more IDs of accounts you’d like metrics for (up to 10 accounts), as a comma-separated liststart
: The start of the time period (inclusive)end
: The end of the time period (inclusive)metrics
: One or more metrics you’d like fetched (up to 10 metrics), as a comma-separated list
For example this call would fetch the page_fans
metric for a single Facebook account, for the first week of December 2021.
The response will be similar to the following:
In the response the API returns:
- For each account requested
- For each date in the requested time period
- A daily value for each requested metric
- For each date in the requested time period
Note you can request multiple metrics for multiple accounts in one API call, but the accounts must be from the same social network.
Fetching demographic analytics
In addition to simple numeric account metrics, the API also allows you to fetch demographic-breakdowns of account fans and followers.
The endpoint you need to call for a particular breakdown will depend on the metric’s type, as listed on the Social Analytics Metrics page. For example the demographics_audience_city
metric is of type breakdown
, so you would call the GET /v3/owned/accounts/metrics/breakdown
endpoint.
All of the metrics endpoints require the same parameters:
source
: The social network of the accounts you are requesting (for examplefacebook
)account_ids
: One or more IDs of accounts you’d like metrics for (up to 10 accounts), as a comma-separated liststart
: The start of the time period (inclusive)end
: The end of the time period (inclusive)metrics
: One or more metrics you’d like fetched (up to 10 metrics), as a comma-separated list
Fetching breakdown metrics
A ‘breakdown’ metric is an analysis that provides a single-level breakdown by a category or concept. For example, the demographics_audience_country
metric breaks down the audience for a Facebook page by country.
As an example of a breakdown metric request, this call would fetch the demographics_audience_country
metric for a single Facebook account, for the first week of December 2021.
The response will be similar to the following:
The API returns for each account requested, the breakdown for each date in the requested time range.
Fetching nested-breakdown metrics
A ‘nested-breakdown’ metric is an analysis that provides a double-level breakdown by two categories or concepts. For example, the demographics_gender_age
metric breaks down the audience for a Facebook page by firstly gender, then age group.
As an example of a nested-breakdown metric request, this call would fetch the demographics_gender_age
metric for a single Facebook account, for the first week of December 2021.
The response will be similar to the following:
The API returns for each account requested, the breakdown for each date in the requested time range.
Fetching heatmap metrics
A ‘heatmap’ metric is an analysis that provides a break down over date and time. For example, the page_fans_heatmap
metric breaks down the audience for a Facebook page by how active they are each day and hour.
As an example of a heatmap metric request, this call would fetch the page_fans_heatmap
metric for a single Facebook account, for the first week of December 2021.
The response will be similar to the following:
In this case, for each day in the requested range, the API returns an hourly value for the metric. Note that the time is always in PST timezone.
Fetching posts
You can use the API to fetch the top posts for owned social accounts. You might do this to report the most engaged with posts in a period of time for example.
When calling the API you can fetch multiple posts for multiple accounts in one API call. Note the accounts must be from the same social network.
You can fetch posts by calling the GET /v3/owned/accounts/posts/top_posts
endpoint.
When fetching posts you must provide the following parameters:
source
: The social network of the accounts you are requesting (for examplefacebook
)account_ids
: One or more IDs of accounts you’d like posts for (up to 10 accounts), as a comma-separated liststart
: The start of the time period (inclusive)end
: The end of the time period (inclusive)
Optionally you can also provide any of the following parameters:
post_types
: The types of the post you’d like to fetch, for examplestatus
, as a comma-separated listsort_by
: The field to sort posts by, defaults tocreated_at
sort_order
: The direction of the sort applied, defaults todesc
page_size
: The number of posts to return per page, defaults to10
, maximum of100
page
: The page number to return, default to1
If you have a large number of posts for your accounts you can use the page_size
and page
parameters to paginate through these.
The API will return the top posts, ordered by your sort options for the requested time period.
We aim to make features across social networks, but as each network has different names for their concepts and metrics the sort order options differ per network for the Top Posts endpoint.
Sort orders of engagement_rate
and created_at
are supported for all networks.
In addition we support the following sort order options for each network:
- Facebook:
comments_count
,reactions_count
,shares_count
- Instagram:
comments_count
- LinkedIn:
comment_count
- TikTok:
comments
For example this call would fetch the top posts sorted by descending engagement_rate
, for a single Facebook account, for the first week of December 2021.
The response will be similar to the following:
The count
field in the response tells you how many posts are available for the accounts in the timeframe.
For each post the API returns:
- The ID, type and URL for the post
- When the post was created
- The account which the post belongs to
- All available metrics for the post
Note that the post metrics available will vary by social network. These are documented on the Social Analytics Metrics page.
Filtering using Tags
The top_posts
endpoint allows you to filter results based on tags users have applied to posts in the Meltwater application. For instance users may tag posts for a particular campaign.
To results to specific tags use the following parameters for the endpoint:
tag
: The tag(s) to filter to. You can provide multiple values, as in the example below.match_all_tags
: Set totrue
if you want posts to match all tags you provide, orfalse
to match one or more of your tags. (Defaults tofalse
.)