REST API Advanced

REST API Advanced

Advanced API endpoints for analytics, revision tracking, and webhooks.

Analytics

The Analytics API provides statistics about your reference library usage.

Dashboard Overview

GET /wp-json/abt/v1/analytics/dashboard

Response:

{
  "total_references": 500,
  "total_citations": 1250,
  "total_views": 8000,
  "type_breakdown": {
    "article": 350,
    "book": 100,
    "chapter": 50
  }
}

Summary Statistics

GET /wp-json/abt/v1/analytics/summary

Parameters:

ParameterTypeDescription
periodstringTime period: week, month, year, all

Time Series Data

GET /wp-json/abt/v1/analytics/timeseries

Parameters:

ParameterTypeDescription
daysintegerNumber of days (1-365, default: 30)
metricstringall, references, views, citations

Response:

{
  "days": 30,
  "metric": "all",
  "data": [
    {
      "date": "2024-01-15",
      "total_references": 495,
      "new_references": 3,
      "total_views": 150,
      "total_citations": 12
    }
  ]
}

Top References

GET /wp-json/abt/v1/analytics/top

Parameters:

ParameterTypeDescription
metricstringcitations or views
limitintegerNumber of results (1-100, default: 10)

Type Breakdown

GET /wp-json/abt/v1/analytics/types

Returns reference count by type (article, book, etc.).

Author Statistics

GET /wp-json/abt/v1/analytics/authors

Parameters:

ParameterTypeDescription
limitintegerNumber of authors (1-100, default: 20)

Year Distribution

GET /wp-json/abt/v1/analytics/years

Returns reference count by publication year.

Recent Activity

GET /wp-json/abt/v1/analytics/activity

Parameters:

ParameterTypeDescription
limitintegerNumber of events (1-100, default: 20)

Single Reference Stats

GET /wp-json/abt/v1/analytics/reference/{id}

Response:

{
  "reference_id": 123,
  "title": "Example Reference",
  "view_count": 42,
  "citation_count": 8,
  "last_cited": "2024-01-15T10:30:00Z",
  "created": "2023-06-01T08:00:00Z",
  "modified": "2024-01-10T14:00:00Z"
}

Export Analytics (Admin)

GET /wp-json/abt/v1/analytics/export

Parameters:

ParameterTypeDescription
formatstringjson or csv

Reset Analytics (Admin)

POST /wp-json/abt/v1/analytics/reset

Request Body:

{
  "reset_counts": false
}

Revisions

Track and restore changes to references.

List Revisions

GET /wp-json/abt/v1/references/{reference_id}/revisions

Parameters:

ParameterTypeDescription
limitintegerMaximum revisions (1-50, default: 20)

Response:

{
  "reference_id": 123,
  "revisions": [
    {
      "revision_number": 5,
      "user_id": 1,
      "timestamp": "2024-01-15T10:30:00Z",
      "changes": ["title", "authors"]
    }
  ],
  "total": 5
}

Get Specific Revision

GET /wp-json/abt/v1/references/{reference_id}/revisions/{revision_number}

Response:

{
  "reference_id": 123,
  "revision": {
    "revision_number": 3,
    "user_id": 1,
    "user": {
      "id": 1,
      "display_name": "Admin"
    },
    "timestamp": "2024-01-14T09:00:00Z",
    "data": { ... }
  }
}

Restore Revision

POST /wp-json/abt/v1/references/{reference_id}/revisions/{revision_number}/restore

Response:

{
  "success": true,
  "message": "Reference restored to revision 3.",
  "reference_id": 123,
  "restored_revision": 3,
  "reference": { ... }
}

Compare Revisions

GET /wp-json/abt/v1/references/{reference_id}/revisions/compare

Parameters:

ParameterTypeDescription
fromintegerFirst revision number
tointegerSecond revision number

Response:

{
  "from_revision": 2,
  "to_revision": 5,
  "differences": [
    {
      "field": "title",
      "old": "Old Title",
      "new": "New Title"
    }
  ]
}

Delete Revisions (Admin)

DELETE /wp-json/abt/v1/references/{reference_id}/revisions

Deletes all revisions for a reference.

Revision Statistics

GET /wp-json/abt/v1/revisions/stats

Global statistics about all revisions.

Cleanup Revisions (Admin)

POST /wp-json/abt/v1/revisions/cleanup

Removes old revisions based on retention settings.

Webhooks

Register webhooks via API:

POST /wp-json/abt/v1/webhooks

See Integrations Settings for details.

Code Examples

JavaScript (Fetch)

// List references
const response = await fetch('/wp-json/abt/v1/references', {
  headers: {
    'X-WP-Nonce': wpApiSettings.nonce
  }
});
const data = await response.json();

// Create reference
const newRef = await fetch('/wp-json/abt/v1/references', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-WP-Nonce': wpApiSettings.nonce
  },
  body: JSON.stringify({
    type: 'article',
    title: 'New Reference',
    authors: [{family: 'Smith', given: 'John'}]
  })
});

PHP (wp_remote)

// List references
$response = wp_remote_get( rest_url( 'abt/v1/references' ), array(
    'headers' => array(
        'Authorization' => 'Basic ' . base64_encode( 'user:password' )
    )
) );
$references = json_decode( wp_remote_retrieve_body( $response ) );

// Create reference
$response = wp_remote_post( rest_url( 'abt/v1/references' ), array(
    'headers' => array(
        'Content-Type' => 'application/json',
        'Authorization' => 'Basic ' . base64_encode( 'user:password' )
    ),
    'body' => json_encode( array(
        'type' => 'article',
        'title' => 'New Reference'
    ) )
) );

Next Steps

Last updated: January 31, 2026