• Levi Fawcett

APIs - Getting started

Updated: Oct 20

Authentication

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

  1. login to PartsPal.

  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"
}


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


{
  parts(q:"12345"){
    items{
      id
      name
    }
  }
}

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



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
          }
        }
      ]
    }
  }
}


Recent Posts

See All

Navigation

Solutions

Applications

Links

Integrations