Python bindings for the Parsely API
Project description
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 requests
Getting the Code
----------------
`git clone` this repository - it's the primary source of the python-parsely code.
git clone http://github.com/emmett9001/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/>.
==========================
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 requests
Getting the Code
----------------
`git clone` this repository - it's the primary source of the python-parsely code.
git clone http://github.com/emmett9001/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/>.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-parsely-1.4.3.tar.gz
(6.4 kB
view details)
File details
Details for the file python-parsely-1.4.3.tar.gz
.
File metadata
- Download URL: python-parsely-1.4.3.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc3a7cec8851406840a9c91e037c30380361929b3b01a1e72b8416b7bc593755 |
|
MD5 | c6279b89853b2317dfc6672860937fe0 |
|
BLAKE2b-256 | 8392532f432d80fbb1978641f1020a8b4c4a149d8a7b034b9f594c12678fb62a |