Skip to content

Commit 4c7d07f

Browse files
committed
Add /cached-latest endpoint + minor fixes
1 parent b4840b4 commit 4c7d07f

File tree

3 files changed

+90
-5
lines changed

3 files changed

+90
-5
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
sidebar_position: 4
3+
---
4+
5+
# Using /cached-latest Endpoint
6+
7+
In this tutorial, we will be using the /cached-latest endpoint to get a cached list of
8+
all circulars in one Category.
9+
10+
This endpoint returns a dictionary (for `receive` being `all`) or string (for `receive` being `titles`/`links`), containing the latest circular (of the given category)'s title and direct download URL like the /latest endpoint.
11+
But, This endpoint caches the latest circular for an hour, and returns the cached circulars if the cache is still valid.
12+
13+
This endpoint should be used when making an app that needs to get the latest circulars in one Category but does not need minute level precision.
14+
15+
:::warning Warning!
16+
17+
Don't use this endpoint if you're making an app that needs minute level precision. Use `/latest` instead!
18+
19+
:::
20+
21+
#### Parameters:
22+
* `category` : `string`. Can have values (`general`, `ptm`, `exam`) [Mandatory]
23+
* `receive` : `string`. Can have values (`all`, `titles`, `links`) [Optional]
24+
25+
The `category` parameter refers to one of the 3 main category of circulars on the
26+
BPS Website.
27+
28+
The `receive` parameter refers to what data you want to receive, either `all` which gives
29+
the latest circular's Name and download URL, or `titles` which gives only the latest circular's Name, or `links` which gives only the latest circular's download URL.
30+
31+
## Example Requests
32+
33+
Python
34+
35+
36+
```python
37+
import requests
38+
39+
url = "https://raj.moonball.io/bpsapi/v1/cached-latest/"
40+
payload = {'category': 'ptm', "receive": "all"}
41+
42+
request = requests.get(url, json=payload)
43+
print(request.text)
44+
```
45+
46+
Curl
47+
48+
```bash
49+
curl -X 'GET' \
50+
'https://raj.moonball.io/bpsapi/v1/cached-latest/' \
51+
-H 'accept: application/json' \
52+
-H 'Content-Type: application/json' \
53+
-d '{
54+
"category": "ptm",
55+
"receive": "all"
56+
}'
57+
```
58+
59+
## Example Response
60+
61+
1. Category: `ptm`, Receive: `all`
62+
63+
```python
64+
{"title":"2nd Parent Teacher Meeting (PTM) for Grades IX, X & XII",
65+
"link":"https://bpsdoha.com/circular/category/40-circular-ptm-2022-23?download=1095:2nd-parent-teacher-meeting-ptm-for-grades-ix-x-xii"}
66+
```
67+
68+
2. Category: `ptm`, Receive: `titles`
69+
70+
```python
71+
"2nd Parent Teacher Meeting (PTM) for Grades IX, X & XII"
72+
```
73+
74+
3. Category: `ptm`, Receive: `links`
75+
76+
```python
77+
"https://bpsdoha.com/circular/category/40-circular-ptm-2022-23?download=1095:2nd-parent-teacher-meeting-ptm-for-grades-ix-x-xii"
78+
```
79+
80+
Thanks for reading!

docs/API/Using the API/Use-geturl.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ sidebar_position: 3
33
---
44
# Using /search Endpoint
55

6-
In this tutorial, we will be using the /search endpoint to get a circular's download URL.
7-
The /search endpoint returns a string containing the download URL of the circular, taking the circular title as a parameter.
6+
In this tutorial, we will be using the `/search` endpoint to get a circular's download URL.
7+
The `/search` endpoint returns a string containing the download URL of the circular, taking the circular title as a parameter.
88

99
This endpoint returns a string (or None if not found) containing the download URL of the circular.
1010

docs/API/Using the API/Use-latest.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ sidebar_position: 2
44

55
# Using /latest Endpoint
66

7-
In this tutorial, we will be using the /latest endpoint to get a list of
8-
all circulars in one Category.
7+
In this tutorial, we will be using the /latest endpoint to get the latest
8+
circular in a category.
99

10-
This endpoint returns a dictionary (for `receive` being `all`) or string (for `receive` being `titles`/`links`, )containing the latest circular (of the given category)'s title and direct download URL.
10+
This endpoint returns a dictionary (for `receive` being `all`) or string (for `receive` being `titles`/`links`), containing the latest circular (of the given category)'s title and direct download URL.
1111

12+
:::tip Tip!
13+
14+
Use the `/cached-latest` endpoint if you're making an app that does not require minute level precision. It gives faster responses and reduces server load :D
15+
16+
:::
1217

1318
#### Parameters:
1419
* `category` : `string`. Can have values (`general`, `ptm`, `exam`) [Mandatory]

0 commit comments

Comments
 (0)