https://github.com/toddself/node-parsely
Node interface for talking to parsely
https://github.com/toddself/node-parsely
Last synced: about 2 months ago
JSON representation
Node interface for talking to parsely
- Host: GitHub
- URL: https://github.com/toddself/node-parsely
- Owner: toddself
- Created: 2014-01-08T19:12:48.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-03-04T15:38:27.000Z (over 11 years ago)
- Last Synced: 2026-03-25T19:50:46.589Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 478 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](http://travis-ci.org/toddself/node-parsely)
# 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](http://www.parsely.com/api), providing the same options as the API docs there. The [wiki](/toddself/node-parsely/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
```javascript
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
```javascript
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 install
```
## API
-
<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
type
string
One of posts, authors, sections, topics, tags
opts
object
<optional>
A list of options for the call
Properties
Name
Type
Argument
Description
days
string
<optional>
Number of days since today to consider for _hits value. Defaults to 3.
period_start
mixed
<optional>
Period of data to cover. Must supply opts.period_end as well
period_end
mixed
<optional>
Period of data to cover, cannot be in the future. Must use opts.period_start as well.
pub_date_state
mixed
<optional>
Start date of content publication to consider. Must use opts.pub_date_end as well.
pub_date_end
mixed
<optional>
End date of content publication to consider. Must use opts.pub_date_start as well.
sort
string
<optional>
Sort value. Defaults to _hits
limit
string
<optional>
Number of records to retrieve, detauls to 10
page
string
<optional>
Page number of results set, defaults to 1
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
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
meta
string
What values to return. Must be one of author, section, topic, tag
value
string
Search term for query
opts
object
<optional>
A list of options for the call
Properties
Name
Type
Argument
Description
days
string
<optional>
Number of days since today to consider for _hits value. Defaults to 3.
period_start
mixed
<optional>
Period of data to cover. Must supply opts.period_end as well
period_end
mixed
<optional>
Period of data to cover, cannot be in the future. Must use opts.period_start as well.
pub_date_state
mixed
<optional>
Start date of content publication to consider. Must use opts.pub_date_end as well.
pub_date_end
mixed
<optional>
End date of content publication to consider. Must use opts.pub_date_start as well.
sort
string
<optional>
Sort value. Defaults to _hits
limit
string
<optional>
Number of records to retrieve, detauls to 10
page
string
<optional>
Page number of results set, defaults to 1
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret* @param {Function} cb [description]
- Source:
Returns:
undefined
-
Type
-
object
-
<static> postDetail(url, opts, auth, cb) → {object}
-
Parameters:
Name
Type
Argument
Description
url
string
Canonical URL for asset. Must start with http/s
opts
object
<optional>
A list of options for the call
Properties
Name
Type
Argument
Description
days
string
<optional>
Number of days since today to consider for _hits value. Defaults to 3.
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
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
apikey
string
The publisher API key
opts
object
<optional>
A list of options for the call
Properties
Name
Type
Argument
Description
url
string
<optional>
Restrict the listing to a specified URL
days
string
<optional>
Number of days since today to consider for _hits value. Defaults to 3.
period_start
mixed
<optional>
Period of data to cover. Must supply opts.period_end as well
period_end
mixed
<optional>
Period of data to cover, cannot be in the future. Must use opts.period_start as well.
limit
string
<optional>
Number of records to retrieve, detauls to 10
page
string
<optional>
Page number of results set, defaults to 1
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
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
apikey
string
The publisher API key
opts
object
<optional>
A list of options for the call
Properties
Name
Type
Argument
Description
days
string
<optional>
Number of days since today to consider for _hits value. Defaults to 3.
period_start
mixed
<optional>
Period of data to cover. Must supply opts.period_end as well
period_end
mixed
<optional>
Period of data to cover, cannot be in the future. Must use opts.period_start as well.
limit
string
<optional>
Number of records to retrieve, detauls to 10
page
string
<optional>
Page number of results set, defaults to 1
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
What to do when it's done!
- Source:
Returns:
undefined
-
Type
-
object
-
<static> createOverride(url, expiry, priority, apikey, auth, cb) → {object}
-
Parameters:
Name
Type
Argument
Description
url
string
URL of the article to re-rank
expiry
mixed
<optional>
Date, in YYYY-MM-DD to expire ranking (max: 2 weeks)
priority
number
The priority you want. 1 is highest...
apikey
string
Your publisher API key
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
What to do when it's done!
- Source:
Returns:
undefined
-
Type
-
object
-
<static> editorialOverrides(limit, page, apikey, auth, cb) → {object}
-
Parameters:
Name
Type
Argument
Description
limit
number
<optional>
Number of records to retrieve, defaults to 10
page
number
<optional>
Page to request
apikey
string
publisher's api key
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
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 DAYS
Parameters:
Name
Type
Argument
Description
uuid
string
UUID of person to get history
apikey
string
The publisher API key
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
What to do when it's done!
- Source:
Returns:
undefined
-
Type
-
object
-
<static> profile(uuid, url, apikey, auth, cb) → {object}
-
Parameters:
Name
Type
Argument
Description
uuid
string
UUID for the user profile being trained
url
url
The URL being trained against the profile
apikey
string
Publisher API key
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
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
type
string
Recommend by uuid or url
criteria
string
Either the UUID or URL to retrieve recommendations for
apikey
string
The publisher API key
opts
object
<optional>
A list of options for the call
Properties
Name
Type
Argument
Description
days
string
<optional>
Number of days since today to consider for _hits value. Defaults to 3.
pub_date_state
mixed
<optional>
Start date of content publication to consider. Must use opts.pub_date_end as well.
pub_date_end
mixed
<optional>
End date of content publication to consider. Must use opts.pub_date_start as well.
limit
string
<optional>
Number of records to retrieve, detauls to 10
page
string
<optional>
Page number of results set, defaults to 1
section
string
<optional>
Return recommendations that belong only in the specified section
author
string
<optional>
Return recommendations that belong only to the specified author
tag
string
<optional>
Return recommendations that belong only to the specified tag
strategy
string
<optional>
Algorithm to use for search. One of click or recency. Defaults to recency
clickMethod
string
<optional>
What click method to use for when opts.strategy is click. One of ref_social, ref_search, ref_internal
sort
string
<optional>
What to sort the results by. There are currently 2 valid options: score, which will sort articles by overall score and pub_date which will sort results by their publication date. The default is score.
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
What to do when it's done!
- Source:
Returns:
undefined
-
Type
-
object
-
<static> byType(type, apikey, opts, auth, cb) → {object}
-
Parameters:
Name
Type
Argument
Description
type
string
One of social, search, other, internal
apikey
string
Your parsley API key
opts
object
<optional>
Options for the call.
Properties
Name
Type
Argument
Description
section
string
<optional>
Section to restrict this query to.
tag
string
<optional>
Tag to restrict this query to.
domain
string
<optional>
domain to restrict this query to.
days
number
<optional>
Number of days since today to consider; defaults to 3 days. Use days=14 or days=30 to only consider traffic from last several days.
period_start
mixed
<optional>
Period of data to cover. Must be specified with period_end.
period_end
mixed
<optional>
Period of data to cover; must be specified with period_start, must be greater than that value, and must not be in the future.
pub_date_start
mixed
<optional>
Publication date. Must be specified with pub_date_end.
pub_date_end
mixed
<optional>
Publication end date; must be specified with pub_date_start, must be greater than that value, and must not be in the future.
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
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
type
string
One of social, search, other, internal
meta
string
One of posts, authors, sections,topics, tags
apikey
string
Your parsley API key
opts
object
<optional>
Options for the call.
Properties
Name
Type
Argument
Description
section
string
<optional>
Section to restrict this query to.
tag
string
<optional>
Tag to restrict this query to.
domain
string
<optional>
domain to restrict this query to.
days
number
<optional>
Number of days since today to consider; defaults to 3 days. Use days=14 or days=30 to only consider traffic from last several days.
period_start
mixed
<optional>
Period of data to cover. Must be specified with period_end.
period_end
mixed
<optional>
Period of data to cover; must be specified with period_start, must be greater than that value, and must not be in the future.
pub_date_start
mixed
<optional>
Publication date. Must be specified with pub_date_end.
pub_date_end
mixed
<optional>
Publication end date; must be specified with pub_date_start, must be greater than that value, and must not be in the future.
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
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:
Name
Type
Argument
Description
type
string
One of social, search, other, internal
meta
string
One of posts, authors, sections,topics, tags
value
string
The value for this meta type
apikey
string
Your parsley API key
opts
object
<optional>
Options for the call.
Properties
Name
Type
Argument
Description
tag
string
<optional>
Tag to restrict this query to.
domain
string
<optional>
domain to restrict this query to.
days
number
<optional>
Number of days since today to consider; defaults to 3 days. Use days=14 or days=30 to only consider traffic from last several days.
period_start
mixed
<optional>
Period of data to cover. Must be specified with period_end.
period_end
mixed
<optional>
Period of data to cover; must be specified with period_start, must be greater than that value, and must not be in the future.
pub_date_start
mixed
<optional>
Publication date. Must be specified with pub_date_end.
pub_date_end
mixed
<optional>
Publication end date; must be specified with pub_date_start, must be greater than that value, and must not be in the future.
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
What to do with the results
- Source:
Returns:
undefined
-
Type
-
object
-
<static> postDetail(url, apikey, opts, auth, cb) → {object}
-
Parameters:
Name
Type
Argument
Description
url
string
URL to get details on. Must start with http|https
apikey
string
The publisher API key
opts
object
<optional>
Options for the call
Properties
Name
Type
Argument
Description
days
number
<optional>
Number of days since today to consider; defaults to 3 days. Use days=14 or days=30 to only consider traffic from last several days.
period_start
mixed
<optional>
Period of data to cover. Must be specified with period_end.
period_end
mixed
<optional>
Period of data to cover; must be specified with period_start, must be greater than that value, and must not be in the future.
pub_date_start
mixed
<optional>
Publication date. Must be specified with pub_date_end.
pub_date_end
mixed
<optional>
Publication end date; must be specified with pub_date_start, must be greater than that value, and must not be in the future.
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
What to do with the results
- Source:
Returns:
undefined
-
Type
-
object
-
<static> search(q, opts, auth, cb) → {object}
-
Parameters:
Name
Type
Argument
Description
q
string
Search query. Will be properly escaped
opts
object
<optional>
A list of options for the call
Properties
Name
Type
Argument
Description
days
string
<optional>
Number of days since today to consider for _hits value. Defaults to 3.
pub_date_state
mixed
<optional>
Start date of content publication to consider. Must use opts.pub_date_end as well.
pub_date_end
mixed
<optional>
End date of content publication to consider. Must use opts.pub_date_start as well.
limit
string
<optional>
Number of records to retrieve, detauls to 10
page
string
<optional>
Page number of results set, defaults to 1
section
string
<optional>
Return recommendations that belong only in the specified section
author
string
<optional>
Return recommendations that belong only to the specified author
tag
string
<optional>
Return recommendations that belong only to the specified tag
strategy
string
<optional>
Algorithm to use for search. One of click or recency. Defaults to recency
clickMethod
string
<optional>
What click method to use for when opts.strategy is click. One of ref_social, ref_search, ref_internal
sort
string
<optional>
What to sort the results by. There are currently 2 valid options: score, which will sort articles by overall score and pub_date which will sort results by their publication date. The default is score.
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
What to do when it's done!
Returns:
undefined
-
Type
-
object
-
<static> byType(type, auth, cb) → {object}
-
Retreive a listing of tops posts or authors by social shares across top
social networks. Docs: /shares/{type}
Parameters:
Name
Type
Argument
Description
type
string
One of posts, authors
opts.pub_days
number
<optional>
Number of days since an article has been published since today to consider for _shares value. Use days=1 or days=3 to only consider shares from last several days.
opts.pub_date_state
mixed
<optional>
Start date of content publication to consider. Must use opts.pub_date_end as well.
opts.pub_date_end
mixed
<optional>
End date of content publication to consider. Must use opts.pub_date_start as well.
opts.limit
string
<optional>
Number of records to retrieve, detauls to 10
opts.page
string
<optional>
Page number of results set, defaults to 1
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
What to do when it's done!
Returns:
undefined
-
Type
-
object
-
<static> postDetail(url, auth, cb) → {object}
-
For a given canonical URL, return the total share counts across the top
social networks. Docs: /shares/post/detail
Parameters:
Name
Type
Argument
Description
url
string
Canonical URL. Must start with http|https
auth
object
<optional>
Authorization information. If not using, pass in null or undefined
Properties
Name
Type
Argument
Description
secretKey
string
<optional>
If using oAuth your app's secret. Must be used with auth.consumerKey
consumerKey
string
<optional>
If using oAuth, your app's consumer key. Must be used with auth.secretKey
sharedSecret
string
<optional>
If using shared secrets, your shared secret
cb
function
What to do when it's done!
Returns:
undefined
-
Type
-
object
-
<static> track(params, user_agent, cb) → {object}
-
Parameters:
Name
Type
Argument
Description
params
object
map of values
Properties
Name
Type
Description
idsite
string
site ID assigned by parsely
[date]
date
time/date of request.
ip_address
string
IP Address of person performing action
url
string
URL of page action was taken on
urlref
string
Referrer
screen
string
Screen dimensions: Monitor width x height|Browser width x height|color-depth: 1024x758|900x600|24
title
string
Title of the document
action
string
Type of request (pageview)
body
object
user data about user being tracked
Properties
Name
Type
Description
parsely_site_uuid
sting
Unique identifier for user
user_agent
string
<optional>
User-Agent of browser being used
cb
function
<optional>
callback to fire when request is complete
Returns:
undefined
-
Type
-
object
*generated with [docme](https://github.com/thlorenz/docme)*
## License
node-parsely copyright 2013 Todd Kennedy. MIT Licensed.