NAV
bash javascript

TruckPartsCross API

API Reference for Diesel Laptops' "TruckPartsCross" API Service.

Authentication

You should have been handed out an API key to use this service. (If not, please request yours)

The API expects you to include this API key in all your requests, in a header that looks like the following:

X-Authorization: api-key

Categories

List of categories with sub categories


Requires authentication Get a list of categories with sub categories.

Route Bindings

(no route bindings)

Query Parameters

(no query parameters)

Example request:

curl -X GET -G "https://api-truckpartscross.com/api/v1/category" \
    -H "X-Authorization: {api-key}" \
    -H "Accept: application/json"
var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api-truckpartscross.com/api/v1/category",
    "method": "GET",
    "headers": {
        "X-Authorization": "{api-key}",
        "Accept": "application/json",
    }
}

$.ajax(settings).done(function (response) {
    console.log(response);
});

Example response:

{
    "data": [
        {
            "id": 1,
            "name": "Chassis & Frame",
            "sub_categories": [
                {
                    "id": 1,
                    "category_id": 1,
                    "category_name": "Chassis & Frame",
                    "name": "Bolts and Misc"
                }
            ]
        }
    ]
}

HTTP Request

GET api/v1/category

Comments

List comments


Requires authentication Get a list of comments.

Route Bindings

(no route bindings)

Query Parameters

Parameter Type Status Description
part_id number optional restrict comments to only those for that part ID

Example request:

curl -X GET -G "https://api-truckpartscross.com/api/v1/comment" \
    -H "X-Authorization: {api-key}" \
    -H "Accept: application/json"
var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api-truckpartscross.com/api/v1/comment",
    "method": "GET",
    "headers": {
        "X-Authorization": "{api-key}",
        "Accept": "application/json",
    }
}

$.ajax(settings).done(function (response) {
    console.log(response);
});

Example response:

{
    "data": [
        {
            "id": 1,
            "created_at": {
                "date": "2018-07-30 03:56:03.000000",
                "timezone_type": 3,
                "timezone": "America\/New_York"
            },
            "part_id": 1004203,
            "part_name": "Lube Filter",
            "part_number": "LF3000",
            "user_name": "John Doe",
            "like": true,
            "comment": "Great tool",
            "date": "July 30, 2018",
            "approved": true
        }
    ],
    "meta": {
        "total": 18,
        "found": 6,
        "other_query_info": null
    }
}

HTTP Request

GET api/v1/comment

Retrieve a Comment


Requires authentication Fetch an existing comment.

Route Bindings

Binding Type Status Description
id number required the id of the comment to fetch.

Query Parameters

(no query parameters)

Example request:

curl -X GET -G "https://api-truckpartscross.com/api/v1/comment/{id}" \
    -H "X-Authorization: {api-key}" \
    -H "Accept: application/json"
var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api-truckpartscross.com/api/v1/comment/{id}",
    "method": "GET",
    "headers": {
        "X-Authorization": "{api-key}",
        "Accept": "application/json",
    }
}

$.ajax(settings).done(function (response) {
    console.log(response);
});

Example response:

{
    "data": {
        "id": 1,
        "created_at": {
            "date": "2018-07-30 03:56:03.000000",
            "timezone_type": 3,
            "timezone": "America\/New_York"
        },
        "part_id": 1004203,
        "part_name": "Lube Filter",
        "part_number": "LF3000",
        "user_name": "John Doe",
        "like": true,
        "comment": "Great tool",
        "date": "July 30, 2018",
        "approved": true
    }
}

HTTP Request

GET api/v1/comment/{id}

Add a Comment


Requires authentication Create a new comment for a part.

Route Bindings

Binding Type Status Description
part_id number required the id of the part to attach the comment to.
user_source number required source of the comment; must always be 1 (truckinfo.com)
user_id number required Id of the comment's author
user_name string required Name of the comment's author
like boolean required One of 1 (like) or 0 (dislike)
comment text required The actual comment from the author

Query Parameters

(no query parameters)

Example request:

curl -X POST "https://api-truckpartscross.com/api/v1/comment" \
    -H "X-Authorization: {api-key}" \
    -H "Accept: application/json"
var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api-truckpartscross.com/api/v1/comment",
    "method": "POST",
    "headers": {
        "X-Authorization": "{api-key}",
        "Accept": "application/json",
    }
}

$.ajax(settings).done(function (response) {
    console.log(response);
});

Example response:

{
    "data": {
        "id": 53,
        "created_at": {
            "date": "2019-02-14 11:22:58.000000",
            "timezone_type": 3,
            "timezone": "America\/New_York"
        },
        "part_id": 1,
        "part_name": "Air Compressor",
        "part_number": "N5060",
        "user_name": "John Doe",
        "like": true,
        "comment": "Great tool",
        "date": "February 14, 2019",
        "approved": false
    }
}

HTTP Request

POST api/v1/comment

Check if user can add Comment


Requires authentication Check if user can add new Comment for specified part.

Route Bindings

(no route bindings)

Query Parameters

Binding Type Status Description
part_id number required the id of the part to attach the comment to.
user_source number required source of the comment; must always be 1 (truckinfo.com)
user_id number required Id of the comment's author

Example request:

curl -X GET -G "https://api-truckpartscross.com/api/v1/comment/can_add" \
    -H "X-Authorization: {api-key}" \
    -H "Accept: application/json"
var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api-truckpartscross.com/api/v1/comment/can_add",
    "method": "GET",
    "headers": {
        "X-Authorization": "{api-key}",
        "Accept": "application/json",
    }
}

$.ajax(settings).done(function (response) {
    console.log(response);
});

Example response:

{
    "result": true
}

HTTP Request

GET api/v1/comment/can_add

Parts

Search For Part


Requires authentication Search through the list of parts.

Route Bindings

(no route bindings)

Query Parameters

Parameter Type Status Description
search string required full or partial part number to look for (min: 3 characters)
sort_by string optional what column to sort the results on; defaults to "number"
Possible values: number or manufacturer_name
sort_dir string optional sort direction; defaults to "asc"
Possible values: asc or desc
page number optional which page of results to return; defaults to page 1
per_page number optional how many rows to return, per page; defaults to 10, maximum 100

Example request:

curl -X GET -G "https://api-truckpartscross.com/api/v1/part/search" \
    -H "X-Authorization: {api-key}" \
    -H "Accept: application/json"
var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api-truckpartscross.com/api/v1/part/search",
    "method": "GET",
    "headers": {
        "X-Authorization": "{api-key}",
        "Accept": "application/json",
    }
}

$.ajax(settings).done(function (response) {
    console.log(response);
});

Example response:

{
    "data": [
        {
            "id": 1312545,
            "sub_category_id": 30,
            "category_name": "Engine",
            "sub_category_name": "Rocker Levers",
            "number": "131496",
            "standardized_number": "131496",
            "name": "GASKET,Valve Cover (16 Holes)(L10E, M11 and ISM)",
            "manufacturer_name": "PAI",
            "price": null,
            "image": "",
            "image_url": "",
            "notes": ""
        }
    ],
    "meta": {
        "total": 1220353,
        "found": 2,
        "other_query_info": null
    }
}

HTTP Request

GET api/v1/part/search

Retrieve a Part


Requires authentication Get a Part and its equivalences.

Route Bindings

Binding Type Status Description
id number required the id of the part to fetch.

Query Parameters

(no query parameters)

Example request:

curl -X GET -G "https://api-truckpartscross.com/api/v1/part/{id}" \
    -H "X-Authorization: {api-key}" \
    -H "Accept: application/json"
var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api-truckpartscross.com/api/v1/part/{id}",
    "method": "GET",
    "headers": {
        "X-Authorization": "{api-key}",
        "Accept": "application/json",
    }
}

$.ajax(settings).done(function (response) {
    console.log(response);
});

Example response:

{
    "data": {
        "id": 1312545,
        "sub_category_id": 30,
        "category_name": "Engine",
        "sub_category_name": "Rocker Levers",
        "number": "131496",
        "standardized_number": "131496",
        "name": "GASKET,Valve Cover (16 Holes)(L10E, M11 and ISM)",
        "manufacturer_name": "PAI",
        "price": null,
        "image": "",
        "image_url": "",
        "notes": "",
        "manufacturer_id": 570,
        "equivalences": [
            {
                "id": 1312546,
                "number": "3883220",
                "name": "GASKET,Valve Cover (16 Holes)(L10E, M11 and ISM)",
                "manufacturer_id": 232,
                "manufacturer_name": "Cummins",
                "equivalences_count": 0,
                "automatic": false,
                "price": null
            }
        ]
    }
}

HTTP Request

GET api/v1/part/{id}