Skip to content

Commit 5a47c1c

Browse files
committed
Add get_post method
1 parent 3a42c27 commit 5a47c1c

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

loading_api_wrapper/api.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,22 @@ def search(self, query):
6262
}
6363

6464
return response.json()
65+
66+
def get_post(self, post_id):
67+
if not post_id:
68+
return {"code": 404, "message": '"post_id" is not allowed to be empty'}
69+
70+
url = f"{API_URL}/{API_VERSION}/posts/{post_id}"
71+
headers = {
72+
"User-Agent": USER_AGENT,
73+
}
74+
75+
response = requests.get(url, headers=headers)
76+
77+
if response.status_code == 200:
78+
return {
79+
"code": response.status_code,
80+
"post": response.json(),
81+
}
82+
83+
return response.json()

0 commit comments

Comments
 (0)