https://github.com/heavenshell/py-qiita
Python wrapper for Qiita API v1.
https://github.com/heavenshell/py-qiita
Last synced: 9 months ago
JSON representation
Python wrapper for Qiita API v1.
- Host: GitHub
- URL: https://github.com/heavenshell/py-qiita
- Owner: heavenshell
- License: bsd-3-clause
- Created: 2012-10-15T14:30:22.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2018-10-30T13:16:05.000Z (over 7 years ago)
- Last Synced: 2025-09-24T06:31:47.124Z (9 months ago)
- Language: Python
- Size: 90.8 KB
- Stars: 10
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
README
Qiita
=====
Python wrapper for Qiita API v1.
.. image:: https://secure.travis-ci.org/heavenshell/py-qiita.png
Installation
------------
::
$ virtualenv --distribute qiita_sample
$ source qiita_sample/bin/activate
$ cd qiita_sample
$ pip install qiita
Qiita depends on `Requests `_.
Usage
-----
Get user's items
~~~~~~~~~~~~~~~~
::
# -*- coding: utf-8 -*-
from qiita import Items
client = Items()
items = client.user_items('heavenshell')
Get tag's items
~~~~~~~~~~~~~~~
::
# -*- coding: utf-8 -*-
from qiita import Tags
client = Tags()
items = client.tag_items('python')
Get a specified item with comments and raw markdown content
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
# -*- coding: utf-8 -*-
from qiita import Items
client = Items()
item_uuid = '1234567890abcdefg'
items = client.item(item_uuid)
Authenticated requests
----------------------
Login with "username & password" or "token"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
# -*- coding: utf-8 -*-
from qiita import Client
client = Client(url_name='heavenshell', password='mysecret')
token = client.token # => contains token
# or
client = Client(token='myauthtoken')
Get my items
~~~~~~~~~~~~
::
# -*- coding: utf-8 -*-
from qiita import Items
client = Client(token='myauthtoken')
items = client.user_item()
Post/Update/Delete an item
~~~~~~~~~~~~~~~~~~~~~~~~~~
::
# -*- coding: utf-8 -*-
from qiita import Items
client = Client(token='myauthtoken')
params = {
'title': 'Hello',
'body': 'markdown text',
'tags': [{name: 'python', versions: ['2.6', '2.7']}],
'private': False
}
# post
item = client.post_item(params)
# update
params['title'] = 'modified'
client.update_item(item['uuid'], params)
# delete
client.delete_item(item['uuid'])
Stock/Unstock item
~~~~~~~~~~~~~~~~~~
::
# -*- coding: utf-8 -*-
from qiita import Items
client = Items(token='myauthtoken')
item_uuid = '1489e2b291fed74713b2'
# Stock
client.stock_item(item_uuid)
# Unstock
client.unstock_item(item_uuid)
Contributing
------------
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create new Pull Request