Skip to content

Commit 363338f

Browse files
committed
Add example code to the README
1 parent 8fb43d0 commit 363338f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,31 @@ for Python 3 (You have pip, right?) to install it::
6161
python3 -m pip install ghreq
6262

6363

64+
Example
65+
=======
66+
67+
.. code:: python
68+
69+
from ghreq import Client
70+
71+
with Client(token="your-api-token-here") as client:
72+
user = client.get("/user")
73+
print("I am user", user["login"])
74+
print()
75+
76+
print("Here are my repositories:")
77+
for repo in client.paginate("/user/repos"):
78+
print(repo["full_name"])
79+
print()
80+
81+
hello_world = client / "repos" / "octocat" / "Hello-World"
82+
details = hello_world.get()
83+
print(f"{details['full_name']} has been starred {details['stargazers_count']} times.")
84+
print("Here is the first page of its open issues & PRs:")
85+
for issue in (hello_world / "issues").get():
86+
print(f"#{issue['number']}: {issue['title']}")
87+
88+
6489
API
6590
===
6691

0 commit comments

Comments
 (0)