API / Deactivate parts

XSparts provides an API endpoint to deactivate your inventory programatically. In order to use the API, you will first need to obtain an API KEY for your account. You can obtain the key by sending your request to xsparts@pcbplanet.com. Once you have the API KEY you can begin sending the requests.

The API in general is in BETA state. Inventory deactivation will be reflected immediately in the search result.

API endpointhttp://localhost:8090/api/inventory_deactivate/
Request MethodPOST

Parameters

api_keyYour 36 character long hex key
dataYour inventory deactivation data as Array (see example below)

Currently API has a restriction of sending array size of 1000 per request (That means, if you want to send 5000 MPNs then you have to send 5 API requests (array of 1000 MPNs) each).

Field TypeMandatory?
arrayyes

An example array payload

["test-mpn1", "test-mpn2"]

An example Python Programming Language code snippet to send the request to the endpoint is given below.

import requests

url = "http://localhost:8090/api/inventory_deactivate/"

payload = {
    'api_key': '**4a6243-****-497e-****-6d3982******',
    'data': '["test-mpn1", "test-mpn2"]'
}

headers = {}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

After a valid request is submitted, you will get a JSON response as shown below if data is deactivated successfully from the database.

{"code": 1, "msg": "Success!"}

In case of an error you will get a JSON response with an error message.

{"code": 0, "msg": "Invalid API key"}