Skip to content

Get All Blogs

Use the following endpoint to get all blog posts via the API.

GET /api/v1/public/get-all-blogs

Include your API key in the Authorization header:

Terminal window
Authorization: Bearer YOUR_API_KEY
// Endpoint: {API_ENDPOINTS.BLOGS.GET_ALL}
fetch(`https://api.blogz.ai/api/v1/public/get-all-blogs`, {
method: 'GET', // Method is GET to retrieve data
headers: {
'Authorization': `Bearer YOUR_API_KEY`,
'Content-Type': 'application/json' // Good practice, though not strictly needed for GET
}
})
.then(response => response.json()) // Expecting an ARRAY of blog objects
.then(blogsArray => {
console.log('All blogs retrieved successfully:', blogsArray);
// Iterate over the array or use it as needed
blogsArray.forEach(blog => {
console.log(`- ${blog.title}`);
});
})
.catch(error => console.error('Error retrieving all blogs:', error));