|
| 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! |
0 commit comments