npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

akamai-api-tools

v0.8.0

Published

Library to facilitate using Akamai {OPEN} APIs

Downloads

5

Readme

Akamai API Tools

Library to facilitate using Akamai {OPEN} APIs


Prerequisites:

Local .edgerc file with valid Akamai client API credentials (Authenticate with EdgeGrid)


Functions

getDatesRelative(endDateOffset = 0, daysPrior = 1, returnEndDateObj = false)

 

Returns formatted start/end timestamps for a range of days

Input

Parameter | Type | Description ------------- | ------------- | ------------- endDateOffset | Int | Days prior to today for end date (e.g. 0 = through midnight today UTC) daysPrior | Int | Number of days prior to endDate to include in report (e.g. 1 day, 5 days, etc.) returnDateObj | Boolean | Include endDate Date object in response array

 

Output (array)

Type | Description ------------- | ------------- String | Formatted timestamp for start of period String | Formatted timestamp for end of period Date object | Date object equivalent for end period

 

getDatesToFriday(weeksBack = 0, weeks = 1, returnEndDateObj = false)

 

Custom use case: Report is run each week between Monday - Thursday morning for the prior week ending last Friday (a buffer since data for prior two days is not final)

Input

Parameter | Type | Description ------------- | ------------- | ------------- weeksBack | Int | Weeks prior to last week (0 = last week ending Friday) weeks | Int | Number of weeks prior to endDate to include in report returnDateObj | Boolean | Include endDate Date object in response array

 

Output (array)

Type | Description ------------- | ------------- String | Formatted timestamp for start of period String | Formatted timestamp for end of period Date object | Date object equivalent for end period

 

async getTopCpcodes(accountSwitchKey, startDateFormatted, endDateFormatted, count=10, measurement='hits', level='edge', products=[])

 

Returns the top CP codes by hits or bytes for a given time period

Input

Parameter | Type | Description ------------- | ------------- | ------------- accountSwitchKey | String | Send empty '' value if not known which default to own account startDateFormatted | String | Formatted Akamai API timestamp for start of reporting period endDateFormatted | String | Formatted Akamai API timestamp for end of reporting period count | Int | number of CP codes to return in array measurement | String | 'hits' or 'bytes' level | String | 'edge' or 'origin' products | Array | Limit reporting data to specific products e.g. ['Ion Standard']

 

Output (array)

Type | Description ------------- | ------------- Object | Log details from API request Array | Array of top CP code IDs

 

async getReportData(reqObj)

 

Get content from an Akamai {OPEN} API

Input (object)

Object key | Type | Description ------------- | ------------- | ------------- path | String | API endpoint path method | String | GET or POST accountSwitchKey | String | Ignore if not known (for Akamai employees) body | Object | Varies by API, may be an empty but is required — see Tech Docs for details dataProperty | String | JSON key within response to return (E.g. 'data') params | String | Optional: List of additional URL parameters unique to a specific API startDate | String | Required if needed by API -- see Tech Docs for details endDate | String | Required if needed by API -- see Tech Docs for details interval | String | Required if needed by API -- see Tech Docs for details groupId | String | Required if needed by API -- see Tech Docs for details contractId | String | Required if needed by API -- see Tech Docs for details headers | String | Optional: Additional headers which can change response (E.g. 'PAPI-Use-Prefixes': false) arrayToObject | Boolean | Optional: Return object instead of array objectKey | String | Required if arrayToObject is true, specifies what value in each array to use as object key

 

Output (array)

Type | Description ------------- | ------------- Object | Log details from API request Array or Object | API response, limited to the object property identified in 'dataProperty' request object

 

Sample request for account CP codes (response: object)

const cpcodeDetails = await apiTools.getReportData({
	path: '/cprg/v1/cpcodes',
	method: 'GET',
	accountSwitchKey: '',
	body: {},
	dataProperty: 'cpcodes',
	arrayToObject: true,
	objectKey: 'cpcodeId'
});

Sample request for property (response: array)

const propertyHostnames = await apiTools.getReportData({
	path: `/papi/v1/properties/${property.propertyId}/versions/${propertyVersion}/hostnames`,
	method: 'GET',
	headers: {'PAPI-Use-Prefixes': false},
	accountSwitchKey: '',
	groupId: property.groupId,
	contractId: property.contractId,
	body: {},
	dataProperty: 'hostnames.items'
});

 

getProductName(productId)

 

Convert Property Mananger API (PAPI) product ID to a human-friendly product name

Input

Parameter | Type | Description ------------- | ------------- | ------------- productId | String | PAPI product ID (E.g. 'Fresca')

 

Output (array)

Type | Description ------------- | ------------- String | Human-friendly product name (E.g. 'Ion Standard')

 

getLength(input)

 

Standard method to get length of variable which can be an string, array, or object

Input

Parameter | Type | Description ------------- | ------------- | ------------- input | String, Array, or Object | Variable to determine length

 

Output (array)

Type | Description ------------- | ------------- Int | Legnth of string, number of array elements, or number of object keys