Repository navigation
Expand file tree
/
Copy pathREADME
More file actions
114 lines (73 loc) · 2.99 KB
/
Copy pathREADME
File metadata and controls
114 lines (73 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
Parsely API Python Binding
==========================
This library provides a pure Python interface for the
[Parsely API](http://parsely.com/api).
The documentation, on which this binding is based, can be found
[here](http://parsely.com/api/api_ref.html)
Installation
------------
python-parsely is available on PyPI. To download it, use pip:
pip install python-parsely
Getting the Code
----------------
`git clone` this repository - it's the primary source of the python-parsely code.
git clone http://github.com/Parsely/python-parsely.git
Using python-parsely
--------------------
To use Parsely from Python, first import it
>>> from parsely.parsely import Parsely
Create a new Parsely object with your public and private API keys
>>> p = Parsely("mysite.com", secret="asf98gf7aw98ev7nwe98vfayewfa9hew8f7ha")
To get a list of recent top posts, use
>>> posts = p.analytics()
The objects in this list are Posts:
>>> posts[1]
<models.Post instance at 0x21bc828>
You can pass these Posts to other library functions. `meta_detail` returns a list of
Posts sharing the same `aspect` as the Post you give it.
>>> p.meta_detail(posts[1], aspect="section")[1:2]
[<models.Post instance at 0x21bc828>]
`post_detail` gives more detailed information on the Post
>>> p.post_detail(posts[1])
You can also use the library to get shares and referrers information surrounding
given posts.
>>> p.referrers_meta_detail(posts[1], meta="author")
>>> p.referrers_post_detail(posts[1])
>>> p.shares()
>>> p.shares(post=posts[1])
The `realtime` call can be used to make a live-updating feed of pageview data:
import time
for i in range(1,5):
real = p.realtime(limit=1)
for r in real:
print "%s: %d" % (r.title, r.hits)
print "\n"
time.sleep(3)
Recommendations API
-------------------
The library handles personalized recommendations via the User class
>>> from recommendations import User
>>> user = User(p, "myuuid")
You can train a user profile with a post
>>> user.train(posts[1])
Get a user's history with `history`
>>> user.history()
Receive personalized User recommendations with `related`
>>> user.related()
Testing
-------
To run the unit tests for this library, use
python tests.py
License
-------
Copyright (C) 2013 Emmett Butler, Parsely Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.