Using /list Endpoint
In this tutorial, we will be using the /list
endpoint to get a list of all circulars in a single category.
This endpoint returns a JSON object containing the list of circulars in the category.
Request Structure
Send a GET request to the following URL: https://bpsapi.rajtech.me/list/{category}
or, send a GET request to: https://bpsapi.rajtech.me/list?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 are example requests using Python's requests
library:
- Category Name
- Category ID
One of the categories from https://bpsapi.rajtech.me/categories
import requests
category = 'general'
url = f"https://bpsapi.rajtech.me/list/{category}"
request = requests.get(url)
print(request.text)
import requests
category = '52'
url = f"https://bpsapi.rajtech.me/list/{category}"
request = requests.get(url)
print(request.text)
Here is are example requests using cURL:
- Category Name
- Category ID
One of the categories from https://bpsapi.rajtech.me/categories
curl "https://bpsapi.rajtech.me/list/general"
curl "https://bpsapi.rajtech.me/list/52"
Here are example requests using Node.js's node-fetch
library:
- Category Name
- Category ID
One of the categories from https://bpsapi.rajtech.me/categories
const fetch = require('node-fetch');
const category = 'general';
const url = `https://bpsapi.rajtech.me/list/${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/list/${category}`;
fetch(url)
.then(response => response.text())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Example Responses
- Valid Category
- Empty Category
- Error
One of the categories from https://bpsapi.rajtech.me/categories
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 invalid category.
{
"status": "error",
"http_status": 400,
"error": "Invalid category"
}
Thanks for reading!