1. Fetching a product's information
What’s a product, product iteration, steps, etc?
-
A product is what we call the pipeline of transformations that a scan and part will go through to be shaped correctly.
-
A product can have multiple versions, they are called
product iterations. -
Each product iteration has some steps. Those steps describe the operations to apply and in which order. The steps also contain what we call
global variableswhich describe additional parameters that must be passed to each step. -
The
order-trackingsare calledcasesin the portal. -
The order trackings represent an execution of the pipeline of transformation. An order tracking has inputs and an output. The inputs are the scan of the body part and the values for each global variable. And the output is the final result of the transformations.
erDiagram
Product ||..o{ Product-iterations : "has some"
Product-iterations ||--o{ Steps : "has some"
Steps ||--|{ Step-status: "describes"
Order-tracking ||--|{ Step-status : "has some"
Steps {
json globalVariables
}
Getting a list of product iterations
Here is an example of how to get the list of iterations of a product given the product’s id.
import requests
def get_product_iterations_list(token, product_id):
"""Get a product's list of iterations
Calls the endpoint /v1/products/:productId/iterations
Args:
product_id (str): The GUID of the product
Returns:
list(dict): A list of product iteration
"""
url = f'{API_BASE_URL}/v1/products/{product_id}/iterations'
response = requests.get(url, headers=make_authorization_header(token))
return response.json()Get a product iteration
To get a product iteration, you need to make an HTTP GET request to
this path:
/v1/products/{product_id}/iterations/{product_iteration_id}?steps=true.
The query parameter steps=true is used to include the definitions of
the steps in the response, which is required to know which additional
parameter is required to create a case (order tracking).
Here is an example of how to get a product iteration, including the steps, given a product identifier and a product iteration identifier.
import requests
API_BASE_URL = "https://api.shapeshift3d.com"
def get_product_iteration(token, product_id, product_iteration_id):
"""Get a product iteration, with all its steps
Args:
product_id (string): The GUID of the product
product_iteration_id (string): The GUID of the product iteration
Returns:
dict: Returns a product iteration
"""
url = f'{API_BASE_URL}/v1/products/{product_id}/iterations/{product_iteration_id}?steps=true'
response = requests.get(url, headers=make_authorization_header(token))
return response.json()You can see an example of what that last request returns, it’s quite big so we included it in its own page.
Next step
Now we got the information required to know which data needs to be sent to the API to successfully create a case of a product. In the next part, we’ll see how to use that information.