The Shujaurrahman API serves as the backend data source for the portfolio website shujaurrahman.me. It provides endpoints to fetch various content, such as profiles, projects, social media links, and images used throughout the site. The API is designed to be lightweight, easy to use, and adaptable for future enhancements, including a dashboard for content management.
- Separation of Concerns: By having a dedicated API, the frontend can remain focused on presentation while the backend handles data management.
- Dynamic Content: Easily manage and update content without modifying the frontend code.
- Scalability: The API can be extended with new endpoints and features as needed.
- Future Enhancements: Plans to integrate a dashboard for real-time content updates, deletions, and additions.
The following endpoints are available in the API:
Method: GET
Description: Fetches profile information, sections about the user, and contact details.
Response:
{
"profile": {
"image": "URL to profile image",
"name": "Shuja Ur Rahman",
"description": "User description..."
},
"sections": [ /* Array of sections */ ],
"contact": {
"email": "user email",
"github": "URL to GitHub profile"
}
}
Method: GET
Description: Fetches bookmarks data for the user.
Method: GET
Description: Provides information about the website's design and development credits.
Method: GET
Description: Fetches image links for the gallery section.
Method: GET
Description: Provides hiring information for the user.
Method: GET
Description: Fetches notes or blog post data.
Method: GET
Description: Provides information about what the user is currently working on.
Method: GET
Description: Fetches project information and links.
Method: GET
Description: Provides links to the user's social media profiles.
Method: GET
Description: Fetches current status updates for the user.
Method: GET
Description: Fetches stories with thumbnails and images.
Method: GET
Description: Provides information on how users can support the creator.
Method: GET
Description: Fetches timeline or history data for the user.
The API serves static content by linking to media files hosted at the following base URL:
https://host/content/
When fetching content, the frontend retrieves relative paths from the JSON responses and constructs the full URL dynamically, eliminating the need for hardcoded URLs in the JSON files.
For instance, the JSON response for the about
section may contain a relative path for the profile image:
{
"profile": {
"image": "profile/shuja.jpg"
}
}
In the frontend, this path is combined with the base URL to construct the full URL:
const baseUrl = "https://host/content/";
const imageUrl = baseUrl + data.profile.image; // Results in full image URL
Future plans include developing a dashboard for managing content through a user-friendly interface. This will allow for real-time updates, deletions, and additions of data to the JSON files, making the API even more dynamic and easier to maintain.
To run the API locally:
- Clone the repository:
git clone <repository-url> cd <repository-directory>
- Install dependencies:
npm install
- Start the server:
node server.js
- Access the API at
http://localhost:3000/api/public/<endpoint>