KB User's Guide - API - Article Views

This document provides information in the Article Views API for the KnowledgeBase.

Title

Get Article Views

Calls page view values for the specified site domain.

Collection Endpoint

https://[KB site domain]/[subsite (optional)]/api/v1/article-views

Example: https://kb.wisc.edu/api/v1/article-views or https://kb.wisc.edu/helpdesk/api/v1/article-views

Method

GET

URL Params

parameter type description
instId integer ID number of an active partner institution *
groupId integer ID number of an active group space **
catId integer ID number of an active topic
articleId integer ID number of a document
startMonth year-month string Year and month for time range start, formatted as yyyy-mm
endMonth year-month string Year and month for time range end, formatted as yyyy-mm
year integer Single year for time range, formatted as yyyy ***
typeId integer 1 = Document
2 = Template
3 = Glossary
searchable string

If undefined, all documents will be included in results.

yes = filter out documents with "Exclude from search" priority set
no = only include documents with "Exclude from search" priority set

* If calling API from a KB subsite, setting instId will override subsite filter. Setting instId will also add "InstName" entry to Collection Response.

** Setting groupId will add "GroupName" entry to Collection Response.

*** Setting year will override startMonth and endMonth if also set. Setting year will also result in a different Collection Response showing monthly values broken down by Group.

Collection Sample Response

{
    "_links": {
        "self": {
            "href": "https://kb.wisc.edu/api/v1/article-views?page=1"
        },
        "first": {
            "href": "https://kb.wisc.edu/api/v1/article-views"
        },
        "last": {
            "href": "https://kb.wisc.edu/api/v1/article-views?page=1"
        }
    },
    "_embedded": {
        "article_view": [
            {
                "month": "2017-01",
                "internalViews": "71075",
                "externalViews": "3642189",
                "combinedViews": "3713264"
            },
            {
                "month": "2017-02",
                "internalViews": "66790",
                "externalViews": "3455495",
                "combinedViews": "3522285"
            },
            {
                "month": "2017-03",
                "internalViews": "71051",
                "externalViews": "4395981",
                "combinedViews": "4467032"
            },

            ...

            }
        ]
    },
    "page_count": 1,
    "page_size": 300,
    "total_items": 13,
    "page": 1
}

Entity Endpoint

N/A; see "Entity Parameters" below

Entity Parameters

/api/v1/article-views/sum

Result: Displays sum total of all page views for current year

OR

/api/v1/article-views/thisWeek

Result: Displays sum total of all page views for current week

OR

/api/v1/article-views/lastWeek

Result: Displays sum total of all page views for past week

Entity Sample Response

{
    "instName": "All institutions",
    "startMonth": "2017-01",
    "endMonth": "2018-01",
    "internalViews": 385642,
    "externalViews": 19182268,
    "combinedViews": 19567910,
    "_links": {
        "self": {
            "href": "https://kb.wisc.edu/helpdesk/api/v1/article-views/sum"
        }
    }
}

Success Response

Code: 200 OK
Content: Content-type: application/hal+json

Error Response

Code: 404 Page Not Found
Content: { error : "Page not found." }

OR

Code: 405 Method Not Allowed
Content: { error : None }

Notes

URL Parameters may be combined with Entity Parameters to further filter results.