Using /latest Endpoint
In this tutorial, we will be using the /latest
endpoint to get the latest circular in a category.
This endpoint returns a JSON object containing the latest circular's information.
Request Structure
Send a GET request to the following URL: https://bpsapi.rajtech.me/latest/**{category}**
or, send a GET request to: https://bpsapi.rajtech.me/latest?category={category}
(not recommended, legacy way)
{category} here is either a category name (from https://bpsapi.rajtech.me/categories) or a category-id (In https://bpsdoha.com/circular/category/**52**-academic-year-2024-25, 52 is the id)
Example Requests
- Python
- cURL
- Node.js
Here is an example request using Python's requests
library:
- Preset Category
- Category ID
import requests
category = "general"
url = f"https://bpsapi.rajtech.me/latest/{category}"
request = requests.get(url)
print(request.text)
import requests
category = "52"
url = f"https://bpsapi.rajtech.me/latest/{category}"
request = requests.get(url)
print(request.text)
Here is an example request using cURL:
- Preset Category
- Category ID
curl "https://bpsapi.rajtech.me/latest/general"
curl "https://bpsapi.rajtech.me/latest/52"
Here is an example request using Node.js's node-fetch
library:
- Preset Category
- Category ID
const fetch = require('node-fetch');
const category = 'general';
const url = `https://bpsapi.rajtech.me/latest/${category}`;
fetch(url)
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
const fetch = require('node-fetch');
const category = '52';
const url = `https://bpsapi.rajtech.me/latest/${category}`;
fetch(url)
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Example Response
- Preset Category
- Empty Category
- Error
When getting circulars from the general
category, the response is a dictionary with the following keys:
{
"status": "success",
"http_status": 200,
"data": {
"title": "Circular 01 - Public Holiday- Eid-Al-Fitr 2024",
"link": "https://bpsdoha.com/circular/category/52-academic-year-2024-25?download=1618",
"id": "1618"
}
}
Here's what you get when you try to get the data from an empty category.
{
"status": "success",
"http_status": 200,
"data": [],
}
Here's what you get when you try to get the data from an empty category.
{
"status": "error",
"http_status": 400,
"error": "Invalid category"
}
Thanks for reading!