Skip to content

This plugin adds a custom API action 'shorturl_analytics' to show stats in a range of dates.

License

Notifications You must be signed in to change notification settings

stefanofranco/yourls-api-shorturl-analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Plugin for YOURLS: API ShortURL Analytics

Plugin Name License

Description

Yourls API ShortURL Analytics is a plugin for Yourls that provides analytics for short URLs via a custom API action. This plugin allows users to retrieve detailed statistics for short URLs within a specified date range.

Requirements

This plugin requires YOURLS version 1.7.3 and above and Php >= 7.0.

Note: Please, if you've tested it with other versions and it works fine, contact me and I will update this section.

Installation

Download the latest release from the releases page. Extract the contents to a folder named yourls-api-shorturl-analytics within the /user/plugins directory of your Yourls installation. Activate the plugin from the Plugins administration page (http://yourls-site.com/admin/plugins.php). You're ready to go! License This package is licensed under the MIT License.

Usage

This plugin extends Yourls API functionality to include a custom action for retrieving analytics data for short URLs. The action can be accessed through the endpoint /yourls-api.php, and requires the following parameters:

  • date: The start date for the analytics data (required).
  • date_end: The end date for the analytics data (optional, defaults to the start date if not provided).
  • shorturl: The short URL for which analytics data is requested (required).

Example - Stats for a specific date

curl -X GET "http://yourls-site.com/yourls-api.php?signature=YourSignature&action=shorturl_analytics&date=2024-01-01&shorturl=abc123"
# Sample result for a specific date
# Parameters: date = 2024-01-01
{
  "statusCode": 200,
  "message": "success",
  "stats": {
    "total_clicks": 15, # Total clicks (lifetime)
    "range_clicks": 15, # Total clicks (in the range)
    "daily_clicks": {
      "2024-01-01": 15 # Total clicks (in the specific date)
    }
  }
}

Example - Stats for a date range

curl -X GET "http://yourls-site.com/yourls-api.php?signature=YourSignature&action=shorturl_analytics&date=2024-01-01&date_end=2024-12-31&shorturl=abc123"
# Sample result for a date range
# Parameters: date = 2024-01-01, date_end = 2024-01-05
{
    "statusCode": 200,
    "message": "success",
    "stats": {
        "total_clicks": 120, # Total clicks (lifetime)
        "range_clicks": 24, # Total clicks (in the range)
        "daily_clicks": {
          "2024-01-01": 15 # Total clicks (in the specific date)
          "2024-01-02": 8,
          "2024-01-03": 1,
          "2024-01-04": 0,
          "2024-01-05": 0
        }
    }
}

Author

Created by Stefano Franco.

About

This plugin adds a custom API action 'shorturl_analytics' to show stats in a range of dates.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages