• Levi Fawcett

APIs - Getting started

Updated: Jan 5

Authentication

Authentication is done via shared keys - to generate your API keys

  1. Login to PartsPal (or create an account from: https://admin.parts-pal.com)

  2. Go to "Settings" -> "Developer Options" -> "API Keys" then click "Generate Keys"

  3. Click copy beside "Public Key"

You now have your permanent API key for authenticating your app.



Testing environment.

To begin testing:

  1. Go to https://api.parts-pal.com/node-api/graphql

  2. Click http header button at left bottom

  3. Paste the following code in http header panel, but with your own public key:



{
    "x-api-key":"paste public key here"
}


Example query

Finally, to search for your first part add the query below, and click "Play" button



{
  gapc{  
  	parts(q: "0 190 350 049") {
      items {
        name
        weight_g
        description
        fitted_uvdb_vehicle_definitions {
          items {
            name
            uvdb_make {
              name
            }
            uvdb_model {
              name
            }
          }
        }
        gapc_part_type {
          id
          name
        }
        interchange {
          items {
            name
            mpn
            gapc_brand {
              id
              name
            }
          }
        }
      }
      
    }
  }
}


You can use the "Docs" tab on the right to see other options to query for.


To see some examples for vehicle and part queries go here:


API Summary and example queries


Running from your application

You can call these APIs from any application, some examples are:


CURL

(Replace "paste public key here" with your key)

curl 'https://api.parts-pal.com/node-api/graphql' -H 'Content-Type: application/json' -H 'x-api-key: paste public key here' --data-binary '{"query":"{\n  parts(q:\"12345\"){\n    items{\n      id\n      name\n    }\n  }\n}"}' --compressed

PHP (using Guzzle)

(Replace "paste public key here" with your key)

use GuzzleHttp\Client;

$graphQLquery = '{"query":"{\n  parts(q:\"12345\"){\n    items{\n      id\n      name\n    }\n  }\n}"}';

$response = (new Client)->request('post', 'https://api.parts-pal.com/node-api/graphql', [
    'headers' => [
        'X-Api-Key' => 'paste public key here',
        'Content-Type' => 'application/json'
    ],
    'body' => $graphQLquery
]);

You will receive a JSON response like the following



{
  "data": {
    "parts": {
      "items": [
        {
          "id": 8427062,
          "name": "Champion Spark Plug TESTING Spark Plug"
        },
        {
          "id": 10391627,
          "name": "Starter Motor Excel TEST_21129"
        },
        {
          "id": 10391635,
          "name": "Alternator Excel TEST_10363"
        }
      ]
    }
  }
}



More advanced queries


You can query whatever fields you like, for example a more advanced query is


{
  parts(q:"12345", limit: 1){
    items{
      id
      name
      mpn
      fitment_notes
      weight_g
      height_mm
      width_mm
      length_mm
      brand {
        id
        name
        created_at
        is_oem
      }
    }
  }
}

Which will give you something like



{
  "data": {
    "parts": {
      "items": [
        {
          "id": 2798053,
          "name": "Headlight Left 1-800 Radiator 25012345",
          "mpn": "25012345",
          "fitment_notes": null,
          "weight_g": null,
          "height_mm": null,
          "width_mm": null,
          "length_mm": null,
          "brand": {
            "id": 16614,
            "name": "1-800-Radiator & AC/Premium",
            "created_at": "2019-09-20T03:35:34.000Z",
            "is_oem": false
          }
        }
      ]
    }
  }
}


193 views0 comments

Navigation

Solutions

Applications

Links

Integrations

Customers