Carsholic API Documentation

Base URL: https://carsholic.vercel.app/

Create User

Endpoint: POST /api/register/

Description: Register a new user.


Request Body:
{
    "username": "your_username",
    "email": "your_email",
    "password": "your_password"
}
Response:
{
    "message": "User registered successfully."
}
                

Login User

Endpoint: POST /api/login/

Description: Authenticate and log in a user.


Request Body:
{
    "username": "your_username",
    "password": "your_password"
}
Response:
{
    "access_token": "your_access_token",
    "refresh_token": "your_refresh_token"
}
                

Create Product (Car Post)

Endpoint: POST /api/cars/

Description: Create a new car post by using the access token as a bearer token of an authenticated user. You can also specify if the car post is public by sending a `public` parameter in the request body.


Request Body:
{
    "car_name": "Model S",
    "description": "Electric car by Tesla",
    "title": "Tesla Model S",
    "tags": "electric ,luxury",
    "car_type": "Sedan",
    "company": "Tesla",
    "dealer": "Tesla Showroom",
    "logo": "logo_url",
    "images": ["image1_url", "image2_url"],
    "public": true
}
Response:
{
    "car_name": "Model S",
    "description": "Electric car by Tesla",
    "title": "Tesla Model S",
    "tags": "electric ,luxury",
    "car_type": "Sedan",
    "company": "Tesla",
    "dealer": "Tesla Showroom",
    "logo": "logo_url",
    "images": ["image1_url", "image2_url"],
    "public": true
}
                

List Products (Public or User-specific)

Endpoint: GET /api/cars/

Description: Retrieve all car posts.

Behavior:

  • If the user is not authenticated (no Bearer token), only public car posts will be returned.
  • If the user is authenticated (with a Bearer token), only the car posts created by that user will be returned.

List Public Products

Endpoint: GET /api/cars/?isLoggedin=true

Description: Retrieve all car posts excluding those created by the authenticated user. If the user is not authenticated, this behaves the same as the `/api/cars/` endpoint.

Headers: Bearer token required for authenticated requests.

List Particular Product

Endpoint: GET /api/cars/<id>/

Description: Retrieve details of a specific car post.

Update Product

Endpoint: PUT /api/cars/<id>/

Description: Fully update an existing car post.

Partially Update Product

Endpoint: PATCH /api/cars/<id>/

Description: Partially update specific fields of a car post.

Delete Product

Endpoint: DELETE /api/cars/<id>/

Description: Delete a specific car post.

Delete Car Image

Endpoint: DELETE /api/carimages/<id>/

Description: Delete a specific image associated with a car post.