You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
odrling 3c0f8c96d6 change log level of debug message 1 month ago
docs docs: fix 'How to access the API' example (superfluous '.status') (#36) 3 months ago
examples fix oauth2 authentication 2 years ago
peony change log level of debug message 1 month ago
tests Prepend `HTTP` to status code related exceptions #32 8 months ago
.gitignore support aiohttp 3 3 years ago
.travis.yml [travis] remove tests for aiohttp-2.0 2 years ago
LICENSE add a proxy option, update readme and license 4 years ago
MANIFEST.in setup tox 4 years ago
Makefile don't run formatters on __init__.py (it could break everything) 2 years ago
README.rst fix README.rst 2 years ago
dev_requirements.txt Update documentation 4 years ago
extras_require.txt completely remove PIL 4 years ago
requirements.txt Update requirements.txt 11 months ago
setup.cfg pass flake8 test 2 years ago
setup.py drop Python < 3.5.3 support 3 years ago
tests_requirements.txt just use flake8 for tests 4 years ago
tox.ini just use flake8 for tests 4 years ago

README.rst

Asynchronous Twitter API client for Python 3.5+
===============================================


.. image:: https://travis-ci.org/odrling/peony-twitter.svg?branch=master
:target: https://travis-ci.org/odrling/peony-twitter

.. image:: https://codecov.io/gh/odrling/peony-twitter/branch/master/graph/badge.svg
:target: https://codecov.io/gh/odrling/peony-twitter

.. image:: https://readthedocs.org/projects/peony-twitter/badge/?version=stable
:target: https://peony-twitter.readthedocs.io/en/stable/?badge=stable
:alt: Documentation Status



Installation
------------

To install this module simply run::

pip install peony-twitter[all]

This will install all the modules required to make peony run out of the box.
You might feel like some of them are not fit for your needs.
Check `Advanced installation`_ for more information about how to install only
the modules you will need.

.. _Advanced installation: https://peony-twitter.readthedocs.io/en/latest/adv_usage/install.html#adv-install

Authorize your client
---------------------

You can use ``peony.oauth_dance`` to authorize your client:

.. code-block:: python

>>> from peony.oauth_dance import oauth_dance
>>> tokens = oauth_dance(YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET)
>>> from peony import PeonyClient
>>> client = PeonyClient(**tokens)

This should open a browser to get a pin to authorize your application.


Getting started
---------------

You can easily create a client using the class ``PeonyClient``.
Make sure to get your api keys and access tokens from
`Twitter's application management page`_ and/or to `Authorize your client`_

.. code-block:: python

import asyncio

# NOTE: the package name is peony and not peony-twitter
from peony import PeonyClient

loop = asyncio.get_event_loop()

# create the client using your api keys
client = PeonyClient(consumer_key=YOUR_CONSUMER_KEY,
consumer_secret=YOUR_CONSUMER_SECRET,
access_token=YOUR_ACCESS_TOKEN,
access_token_secret=YOUR_ACCESS_TOKEN_SECRET)

# this is a coroutine
req = client.api.statuses.update.post(status="I'm using Peony!!")

# run the coroutine
loop.run_until_complete(req)

.. _Twitter's application management page: https://apps.twitter.com

.. _Authorize your client: #authorize-your-client

Documentation
-------------

Read `Peony's documentation`_.

.. _Peony's documentation: https://peony-twitter.readthedocs.io

Contributing
------------

Every kind of contribution is appreciated.

If you find a bug please start an issue and if you're very motivated you can
create a pull request.

If you have a suggestion you can also start an issue and create a pull
request if you managed to make it work.

Tests
-----

To run the tests run:

.. code-block:: bash

make test

The first time this command is run it will install all the dependencies
which can take a bit of time.

The tests include a code style test. The code style is mostly PEP8, the only
exception so far being long urls included in docstrings and some imports
that are not at the top of the file (because they can't be there).

To resolve the most trivial errors you can run:

.. code-block:: bash

make format

Note that running ``make`` is equivalent to running
``make format && make test``

You can also use tox to run the tests, a configuration file is provided:

.. code-block:: bash

tox