node-parsely
A javascript client for the Parse.ly APIs.
Installation
npm install parsely
Documentation
This is a very light wrapper around the parsely.com API, providing the same options as the API docs there. The wiki has a full set of API docs, where you can see what method corresponds to which API, and a list of the parameters they take.
Tracking Events
var parsely = require('parsley');
var trackingData = {
idsite: 'parselyid',
date: (new Date()),
data: {
parsely_site_uuid: 'unique id for client'
}
};
parsely.track(trackingData, 'Mozilla/6.0', function(err){
if(err){
console.log(err);
}
});Analytics
parsely.analytics.byType('query', 'posts', {days: 1}, {sharedSecret: 'dudes'}, function(err, data){
if(err){
console.log(err);
}
console.log(data);
});#
Development
git clone https://github.com/toddself/node-parsely
cd node-parsely
npm installAPI
- Source:
-
<static> byType(type, opts, auth, cb) → {object}
-
Returns a list of posts, authors, section topics or tags depending on specified type. Docs: analytics/{type}
Parameters:
Name Type Argument Description typestring One of
posts,authors,sections,topics,tagsoptsobject <optional>
A list of options for the call
Properties
Name Type Argument Description daysstring <optional>
Number of days since today to consider for _hits value. Defaults to 3.
period_startmixed <optional>
Period of data to cover. Must supply
opts.period_endas wellperiod_endmixed <optional>
Period of data to cover, cannot be in the future. Must use
opts.period_startas well.pub_date_statemixed <optional>
Start date of content publication to consider. Must use
opts.pub_date_endas well.pub_date_endmixed <optional>
End date of content publication to consider. Must use
opts.pub_date_startas well.sortstring <optional>
Sort value. Defaults to
_hitslimitstring <optional>
Number of records to retrieve, detauls to
10pagestring <optional>
Page number of results set, defaults to
1authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do when it's done!
- Source:
Returns:
undefined
- Type
- object
-
<static> metaValueDetail(meta, value, opts, auth) → {object}
-
Returns a list of posts falling under the specified author, section or topic. Docs: /analaytics/{meta}/{value}/detail
Parameters:
Name Type Argument Description metastring What values to return. Must be one of
author,section,topic,tagvaluestring Search term for query
optsobject <optional>
A list of options for the call
Properties
Name Type Argument Description daysstring <optional>
Number of days since today to consider for _hits value. Defaults to 3.
period_startmixed <optional>
Period of data to cover. Must supply
opts.period_endas wellperiod_endmixed <optional>
Period of data to cover, cannot be in the future. Must use
opts.period_startas well.pub_date_statemixed <optional>
Start date of content publication to consider. Must use
opts.pub_date_endas well.pub_date_endmixed <optional>
End date of content publication to consider. Must use
opts.pub_date_startas well.sortstring <optional>
Sort value. Defaults to
_hitslimitstring <optional>
Number of records to retrieve, detauls to
10pagestring <optional>
Page number of results set, defaults to
1authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret* @param {Function} cb [description]
- Source:
Returns:
undefined
- Type
- object
-
<static> postDetail(url, opts, auth, cb) → {object}
-
Returns the metadata and total pageviews for a post specified by URL. Docs: /analytics/post/detail
Parameters:
Name Type Argument Description urlstring Canonical URL for asset. Must start with http/s
optsobject <optional>
A list of options for the call
Properties
Name Type Argument Description daysstring <optional>
Number of days since today to consider for _hits value. Defaults to 3.
authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do when it's done
- Source:
Returns:
undefined
- Type
- object
- Source:
-
<static> clicks(apikey, opts, auth, cb) → {object}
-
Retrieve a list of URLs and the corresponding clicks recorded by the API over a period. Docs: /clicks
Parameters:
Name Type Argument Description apikeystring The publisher API key
optsobject <optional>
A list of options for the call
Properties
Name Type Argument Description urlstring <optional>
Restrict the listing to a specified URL
daysstring <optional>
Number of days since today to consider for _hits value. Defaults to 3.
period_startmixed <optional>
Period of data to cover. Must supply
opts.period_endas wellperiod_endmixed <optional>
Period of data to cover, cannot be in the future. Must use
opts.period_startas well.limitstring <optional>
Number of records to retrieve, detauls to
10pagestring <optional>
Page number of results set, defaults to
1authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do when it's done!
- Source:
Returns:
undefined
- Type
- object
-
<static> clicks(apikey, opts, auth, cb) → {object}
-
Retrieve a list of URLs and the corresponding clicks recorded by the API over a period. Docs: /clicks
Parameters:
Name Type Argument Description apikeystring The publisher API key
optsobject <optional>
A list of options for the call
Properties
Name Type Argument Description daysstring <optional>
Number of days since today to consider for _hits value. Defaults to 3.
period_startmixed <optional>
Period of data to cover. Must supply
opts.period_endas wellperiod_endmixed <optional>
Period of data to cover, cannot be in the future. Must use
opts.period_startas well.limitstring <optional>
Number of records to retrieve, detauls to
10pagestring <optional>
Page number of results set, defaults to
1authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do when it's done!
- Source:
Returns:
undefined
- Type
- object
-
<static> createOverride(url, expiry, priority, apikey, auth, cb) → {object}
-
Specify posts to be ranked in the recommendation API. Docs: /editorial_override
Parameters:
Name Type Argument Description urlstring URL of the article to re-rank
expirymixed <optional>
Date, in
YYYY-MM-DDto expire ranking (max: 2 weeks)prioritynumber The priority you want.
1is highest...apikeystring Your publisher API key
authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do when it's done!
- Source:
Returns:
undefined
- Type
- object
-
<static> editorialOverrides(limit, page, apikey, auth, cb) → {object}
-
Retrieve list of URLs that should be given special ranking. Docs: /editoral_overrides
Parameters:
Name Type Argument Description limitnumber <optional>
Number of records to retrieve, defaults to 10
pagenumber <optional>
Page to request
apikeystring publisher's api key
authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do when it's done!
- Source:
Returns:
undefined
- Type
- object
-
<static> history(uuid, apikey, auth, cb) → {object}
-
Retrieve a list of URLs visited by a user by UUID. Docs: /history. THIS METHOD'S SIGNATURE DIFFERS FROM THE DOCS SINCE THEY ARE CALLING A UUID
DAYSParameters:
Name Type Argument Description uuidstring UUID of person to get history
apikeystring The publisher API key
authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do when it's done!
- Source:
Returns:
undefined
- Type
- object
-
<static> profile(uuid, url, apikey, auth, cb) → {object}
-
Train a user profile for the purpose of personalized recommendations. Docs: /profile
Parameters:
Name Type Argument Description uuidstring UUID for the user profile being trained
urlurl The URL being trained against the profile
apikeystring Publisher API key
authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do with the results
- Source:
Returns:
undefined
- Type
- object
-
<static> related(type, criteria, apikey, opts, auth, cb) → {object}
-
Retrieve a list of post recommendations which are either personalized or for a specific URL. Docs: /related
Parameters:
Name Type Argument Description typestring Recommend by
uuidorurlcriteriastring Either the UUID or URL to retrieve recommendations for
apikeystring The publisher API key
optsobject <optional>
A list of options for the call
Properties
Name Type Argument Description daysstring <optional>
Number of days since today to consider for _hits value. Defaults to 3.
pub_date_statemixed <optional>
Start date of content publication to consider. Must use
opts.pub_date_endas well.pub_date_endmixed <optional>
End date of content publication to consider. Must use
opts.pub_date_startas well.limitstring <optional>
Number of records to retrieve, detauls to
10pagestring <optional>
Page number of results set, defaults to
1sectionstring <optional>
Return recommendations that belong only in the specified section
authorstring <optional>
Return recommendations that belong only to the specified author
tagstring <optional>
Return recommendations that belong only to the specified tag
strategystring <optional>
Algorithm to use for search. One of
clickorrecency. Defaults torecencyclickMethodstring <optional>
What click method to use for when
opts.strategyisclick. One ofref_social,ref_search,ref_internalsortstring <optional>
What to sort the results by. There are currently 2 valid options:
score, which will sort articles by overall score andpub_datewhich will sort results by their publication date. The default isscore.authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do when it's done!
- Source:
Returns:
undefined
- Type
- object
- Source:
-
<static> byType(type, apikey, opts, auth, cb) → {object}
-
Return a list of top referrers by type. Docs: /referrers/{type}
Parameters:
Name Type Argument Description typestring One of
social,search,other,internalapikeystring Your parsley API key
optsobject <optional>
Options for the call.
Properties
Name Type Argument Description sectionstring <optional>
Section to restrict this query to.
tagstring <optional>
Tag to restrict this query to.
domainstring <optional>
domain to restrict this query to.
daysnumber <optional>
Number of days since today to consider; defaults to 3 days. Use
days=14ordays=30to only consider traffic from last several days.period_startmixed <optional>
Period of data to cover. Must be specified with
period_end.period_endmixed <optional>
Period of data to cover; must be specified with p
eriod_start, must be greater than that value, and must not be in the future.pub_date_startmixed <optional>
Publication date. Must be specified with
pub_date_end.pub_date_endmixed <optional>
Publication end date; must be specified with
pub_date_start, must be greater than that value, and must not be in the future.authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do with the results
- Source:
Returns:
undefined
- Type
- object
-
<static> byTypeMetaType(type, meta, apikey, opts, auth, cb) → {object}
-
Return a list of the top posts, authors, sections or topics referred to. Docs: /referrers/{referrer_type}/{meta_type}
Parameters:
Name Type Argument Description typestring One of
social,search,other,internalmetastring One of
posts,authors,sections,topics,tagsapikeystring Your parsley API key
optsobject <optional>
Options for the call.
Properties
Name Type Argument Description sectionstring <optional>
Section to restrict this query to.
tagstring <optional>
Tag to restrict this query to.
domainstring <optional>
domain to restrict this query to.
daysnumber <optional>
Number of days since today to consider; defaults to 3 days. Use
days=14ordays=30to only consider traffic from last several days.period_startmixed <optional>
Period of data to cover. Must be specified with
period_end.period_endmixed <optional>
Period of data to cover; must be specified with p
eriod_start, must be greater than that value, and must not be in the future.pub_date_startmixed <optional>
Publication date. Must be specified with
pub_date_end.pub_date_endmixed <optional>
Publication end date; must be specified with
pub_date_start, must be greater than that value, and must not be in the future.authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
cbfunction What to do with the results
- Source:
Returns:
undefined
- Type
- object
-
<static> metaValueDetail(type, meta, value, apikey, opts, auth, cb) → {object}
-
Returns a list of posts falling under the specified author, section or topic. Docs: /referrers/{referrer_type}/{meta_type}/{meta_value}/detail
Parameters:
<td class="nName Type Argument Description typestring One of
social,search,other,internalmetastring One of
posts,authors,sections,topics,tagsvaluestring The value for this meta type
apikeystring Your parsley API key
optsobject <optional>
Options for the call.
Properties
Name Type Argument Description tagstring <optional>
Tag to restrict this query to.
domainstring <optional>
domain to restrict this query to.
daysnumber <optional>
Number of days since today to consider; defaults to 3 days. Use
days=14ordays=30to only consider traffic from last several days.period_startmixed <optional>
Period of data to cover. Must be specified with
period_end.period_endmixed <optional>
Period of data to cover; must be specified with p
eriod_start, must be greater than that value, and must not be in the future.pub_date_startmixed <optional>
Publication date. Must be specified with
pub_date_end.pub_date_endmixed <optional>
Publication end date; must be specified with
pub_date_start, must be greater than that value, and must not be in the future.authobject <optional>
Authorization information. If not using, pass in
nullorundefinedProperties
Name Type Argument Description secretKeystring <optional>
If using oAuth your app's secret. Must be used with
auth.consumerKeyconsumerKeystring <optional>
If using oAuth, your app's consumer key. Must be used with
auth.secretKeysharedSecretstring <optional>
If using shared secrets, your shared secret
