Contents
On this page

Get Share Counts - Plugixa Easy Social Share Buttons

GET /plugixa-social-share/v1/counts/{post}

A published post’s share counts from the networks, and its own click counts, as the buttons show them.

Public: no login, no nonce and no Application Password. It is meant to be called from the visitor’s browser on a cached page.

A number below the Hide counts below setting (5 by default) is not sent at all, so it cannot be read from the response either. Network counts and click counts are never added together: total is the sum of the network counts only. Click counts are all-time. Asking for a post’s counts also queues the post for a refresh from the networks, at most once an hour.

Note. For a post that does not exist or is not published, the answer is 200 with empty values, not 404, and networks and clicks then come back as empty arrays [] rather than empty objects {}. Accept both.

Request

GET https://your-site.example/wp-json/plugixa-social-share/v1/counts/123

Path parameters

Name Type Description
post integer The post’s ID

Responses

200 OK.

{
  "success": true,
  "data": {
    "networks": {
      "reddit": 48
    },
    "clicks": {
      "x": 12,
      "whatsapp": 9
    },
    "total": 48
  }
}
Field Type Meaning
data.networks object Network slug to the count that network reports for the post
data.clicks object Network slug to the clicks recorded on this site’s own buttons for the post
data.total integer The sum of networks, or 0 when it is below the threshold

Errors

Status Code When
404 rest_no_route Share counts are switched off, so the route is not registered.

Plus the errors every endpoint can return.

Examples

curl -s "https://your-site.example/wp-json/plugixa-social-share/v1/counts/123"
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-social-share/v1/counts/123');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-social-share/v1/counts/123');
const { data } = await response.json();

Quick Links

Share