Debian Codegraph @

README.rst

raw
1 .. _main_page:
2
3 prawcore
4 ========
5
6 .. image:: https://img.shields.io/pypi/v/prawcore.svg
7 :alt: Latest prawcore Version
8 :target: https://pypi.python.org/pypi/prawcore
9
10 .. image:: https://travis-ci.org/praw-dev/prawcore.svg?branch=main
11 :target: https://travis-ci.org/praw-dev/prawcore
12
13 .. image:: https://coveralls.io/repos/github/praw-dev/prawcore/badge.svg?branch=main
14 :target: https://coveralls.io/github/praw-dev/prawcore?branch=main
15
16 prawcore is a low-level communication layer used by PRAW 4+.
17
18 Installation
19 ------------
20
21 Install prawcore using ``pip`` via:
22
23 .. code-block:: console
24
25 pip install prawcore
26
27 Execution Example
28 -----------------
29
30 The following example demonstrates how to use prawcore to obtain the list of trophies
31 for a given user using the script-app type. This example assumes you have the
32 environment variables ``PRAWCORE_CLIENT_ID`` and ``PRAWCORE_CLIENT_SECRET`` set to the
33 appropriate values for your application.
34
35 .. code-block:: python
36
37 #!/usr/bin/env python
38 import os
39 import pprint
40 import prawcore
41
42 authenticator = prawcore.TrustedAuthenticator(
43 prawcore.Requestor("YOUR_VALID_USER_AGENT"),
44 os.environ["PRAWCORE_CLIENT_ID"],
45 os.environ["PRAWCORE_CLIENT_SECRET"],
46 )
47 authorizer = prawcore.ReadOnlyAuthorizer(authenticator)
48 authorizer.refresh()
49
50 with prawcore.session(authorizer) as session:
51 pprint.pprint(session.request("GET", "/api/v1/user/bboe/trophies"))
52
53 Save the above as ``trophies.py`` and then execute via:
54
55 .. code-block:: console
56
57 python trophies.py
58
59 Additional examples can be found at:
60 https://github.com/praw-dev/prawcore/tree/main/examples
61
62 Depending on prawcore
63 ---------------------
64
65 prawcore follows `semantic versioning <http://semver.org/>`_ with the exception that
66 deprecations will not be preceded by a minor release. In essense, expect only major
67 versions to introduce breaking changes to prawcore's public interface. As a result, if
68 you depend on prawcore then it is a good idea to specify not only the minimum version of
69 prawcore your package requires, but to also limit the major version.
70
71 Below are two examples of how you may want to specify your prawcore dependency:
72
73 setup.py
74 ~~~~~~~~
75
76 .. code-block:: python
77
78 setup(..., install_requires=["prawcore >=0.1, <1"], ...)
79
80 requirements.txt
81 ~~~~~~~~~~~~~~~~
82
83 .. code-block:: text
84
85 prawcore >=1.5.1, <2