Get up and running with our API to start developing your own Shapeways integrations.
Once you have registered
and verified your Shapeways account you are ready to create your first app.
Create your first app
Create a new app
to generate the API keys you’ll use to authenticate your
API requests. You can access all apps associated with your account from the Manage
apps page on the Shapeways Developers site.
Note: From the Manage apps screen, you can create, edit, or delete your applications.
Your application will need access to users’ Shapeways accounts to upload models and place orders. To get
started, you’ll need to decide what type of access your app will need as the user authorization process is
different.
Note: The Shapeways API uses 0Auth 2.0 to authenticate users. Learn more about OAuth 2.0.
1. How many accounts will need access to the API?
This is the simplest way to get started using the API. Choose this option if the API only needs access to
your Shapeways account.
2. Requesting the API Access Tokens
In Manage apps > (Your App) copy your Client ID and Client Secret. Add them to the code below and make a
POST
request. Save this Access Token & Refresh Token (only for multiple user accounts flow) in a safe place.
// Add your Client ID & Client Secret to the following code examples:
$clientId = 'YOUR_CLIENT_ID'; // replace this
$clientSecret = 'YOUR_CLIENT_SECRET'; // replace this
$url = 'https://api.shapeways.com/oauth2/token';
$params = ['grant_type' => 'client_credentials'];
try {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, $clientId . ':' . $clientSecret);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// showing response on screen
print_r($response);
} catch (\Exception $e) {
// printing error on screen
echo 'Exception: '. $e->getMessage();
}
// Example API response
{
"access_token": "ACCESS_TOKEN",
"token_type": "bearer",
"expires_in": 3600
}
// Add your Client ID & Client Secret to the following code examples:
curl -d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=\
YOUR_CLIENT_SECRET" -H "Content-Type: application/x-www-form-urlencoded" -X\
POST https://api.shapeways.com/oauth2/token
// Example API response
{"access_token":"ACCESS_TOKEN","token_type":"bearer","expires_in":3600}
// Add your Client ID & Client Secret to the following code examples:
import requests
url = 'https://api.shapeways.com/oauth2/token'
client_id = 'YOUR_CLIENT_ID'
client_secret = 'YOUR_CLIENT_SECRET'
post_data = {
'grant_type': 'client_credentials'
}
response = requests.post(url=url, data=post_data, auth=(client_id,client_secret))
access_token = response.json()['access_token']
print("Access token: " + access_token)
// Example API response
{
"access_token": "ACCESS_TOKEN",
"token_type": "bearer",
"expires_in": 3600
}
This option allows any user to authorize access to their Shapeways accounts so they can use your app. For
example, choose this option if you are creating a plugin for Shopify, Squarespace, Etsy, etc that will need
access to Shapeways user data other than your own.
2. Generate user authorization code
In Manage apps > (Your app) add a Redirect URI. This determines where authentication requests will be sent
and received by your app. Users will be redirected to this URL when they attempt to use your app.
Note: Users will be redirected to this URL in browser and asked to Authorize your app.
// Redirect your user to Shapeways.com to authorize access
// Use the app’s Client ID and Redirect URI to make the API request
$redirectURL = 'https://example.com/redirect'; // replace this
$clientId = 'YOUR_CLIENT_ID'; // replace this
// A random text to be verified laster in your handle callback function
$verificationString = 'VERIFICATION_STRING';
$params = [
'response_type' => 'code',
'client_id' => $clientId,
'redirect_uri' => rawurlencode($redirectURL),
'state' => rawurlencode($verificationString),
];
$url = 'https://api.shapeways.come/oauth2/authorize';
$url = $url . '?' . http_build_query($params);
header('Location: ' . $url);
// Handling callback from Shapeways.com
// Use the Verification String you created for the authorization request
$verificationString = 'VERIFICATION_STRING';
$state = $_REQUEST['state'] ?? null;
if ($state !== $verificationString) {
echo 'Invalid request';
// retry or send error alerts
}
$code = $_REQUEST['code'] ?? null;
if ($code === null) {
echo 'Missing Authorization Code';
// retry or send error alerts
}
// Use the $code for the token request (#link to access token)
For oob curl instructions follow the quick start instruction below
// Add your Client ID & Redirect Url to the following code examples:
import requests
url = 'https://api.shapeways.com/oauth2/authorize?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URL}'
r = requests.head(url, allow_redirects=True)
print(r.url)
Quick start method. Using "oob"(Out-Of-Band)
Don’t need other users to access your app yet? Get access for the account owner only by following these
quick steps:
In Manage apps > (Your app) add “oob” as a Redirect URI
To generate an authorization code, modify and open this URL on your browser:
Copy the authorization code displayed on the screen
3. Requesting the API Access Tokens
Use the authorization code returned in the previous step to request access to the API. Add the necessary
credentials to the code below and make a POST request. Save this Access Token & Refresh Token (only for multiple users flow) in a safe
place
(app owner only).
// Example API response
{
"access_token": "ACCESS_TOKEN",
"token_type": "bearer",
"expires_in": 3600,
"refresh_token": "REFRESH_TOKEN"
}
// Add your Client ID & AUTHORIZATION_CODE to the following code examples:
curl -X POST -F 'grant_type=authorization_code' -F 'code={AUTHORIZATION_CODE}'\
-F 'redirect_uri={YOUR_REDIRECT_URL}' -F 'client_id={YOUR_CLIENT_ID}' -F\
'client_secret={YOUR_CLIENT_SECRET}' https://api.shapeways.com/oauth2/token
// Example API response
{"access_token":"ACCESS_TOKEN","token_type":"bearer","expires_in":3600}
// Add your access token to the following code examples:
curl -X GET -H "Authorization: Bearer {YOUR_ACCESS_TOEKN}" -H "Content-Type: application/json" https://api.shapeways.com/materials/v1
After an access token expires, using it to make a request from the API will result in an "Invalid Token
Error".
Your refresh token can be used to request a fresh access token from the authorization server.
// Model upload example showing the required fields only
// Add your access token to the following code examples:
// Make sure to use json encoded body and have the application/json for your header
$accessToken = 'YOUR_ACCESS_TOKEN';
$url = 'https://api.shapeways.com/models/v1';
// loading file data
$file = file_get_contents(YOUR_FILE_PATH);
// generating request data
$postFields = [
"fileName" => "cube.stl", // make sure include the correct file extension
"file" => rawurlencode(base64_encode($file)),
"description" => "This is a nice cube!",
"hasRightsToModel" => 1,
"acceptTermsAndConditions" => 1
];
$postData = json_encode($postFields);
try {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER,
['Authorization: Bearer ' . $accessToken, 'Content-type: application/json']);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// printing API response on screen
print_r($response);
} catch (\Exception $e) {
// printing error on screen
echo $e->getMessage();
}
// Example API response
{
"result":"success",
"modelId":123456,
"modelVersion":0,
"title":"cube",
"fileName":"cube.stl",
"contentLength":684,
"fileMd5Checksum":"a6d5646bcb5a1437cb38ad07c45adf7",
"description":"This is a nice cube!",
"isPublic":0,
"isClaimable":0,
"isForSale":false,
"isDownloadable":0,
"materials":{
"6":{
"materialId":6,
"markup":0,
"isActive":1,
"price":4
},
...
"addModelPhoto":{
"method":"POST",
"restUrl":"https:\/\/api.shapeways.com\/models\/v1",
"link":"\/models\/v1"
}
}
}
// Add your Client ID & AUTHORIZATION_CODE to the following code examples:
COMING SOON
// Example API response
{
"result":"success",
"modelId":123456,
"modelVersion":0,
"title":"cube",
"fileName":"cube.stl",
"contentLength":684,
"fileMd5Checksum":"a6d5646bcb5a1437cb38ad07c45adf7",
"description":"This is a nice cube!",
"isPublic":0,
"isClaimable":0,
"isForSale":false,
"isDownloadable":0,
"materials":{
"6":{
"materialId":6,
"markup":0,
"isActive":1,
"price":4
},
...
"addModelPhoto":{
"method":"POST",
"restUrl":"https:\/\/api.shapeways.com\/models\/v1",
"link":"\/models\/v1"
}
}
}
// Model upload example showing the required fields only
// Add your access token to the following code examples:
// Make sure to use json encoded body and have the application/json for your header
import requests
access_token =
headers = {
'Authorization': 'Bearer ' + access_token
}
with open('cube.stl', 'rb') as model_file:
model_file_data = model_file.read()
model_upload_post_data = {
'fileName': 'cube.stl', // make sure include the correct file extension
'file': base64.b64encode(model_file_data).decode('utf-8'),
'description': 'Someone call a doctor, because this cube is SIIIICK.',
'hasRightsToModel': 1,
'acceptTermsAndConditions': 1
}
response = requests.post(url='https://api.shapeways.com/models/v1', headers=headers, data=json.dumps(model_upload_post_data))
print(json.dumps(response.json(), indent=4, sort_keys=True))
// Example API response
{
"result":"success",
"modelId":123456,
"modelVersion":0,
"title":"cube",
"fileName":"cube.stl",
"contentLength":684,
"fileMd5Checksum":"a6d5646bcb5a1437cb38ad07c45adf7",
"description":"This is a nice cube!",
"isPublic":0,
"isClaimable":0,
"isForSale":false,
"isDownloadable":0,
"materials":{
"6":{
"materialId":6,
"markup":0,
"isActive":1,
"price":4
},
...
"addModelPhoto":{
"method":"POST",
"restUrl":"https:\/\/api.shapeways.com\/models\/v1",
"link":"\/models\/v1"
}
}
}
Get model information
Once you’ve uploaded a model to Shapeways, you can use GET requests to find out more about it, including:
// Add your access token and a Model ID to the code example
$accessToken = 'YOUR_ACCESS_TOKEN';
$url = 'https://api.shapeways.com/models/{MODEL_ID}/v1';
try {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER,
['Authorization: Bearer ' . $accessToken, 'Content-type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// printing API response on screen
print_r($response);
} catch (\Exception $e) {
// printing error on screen
echo 'Exception: ' . $e->getMessage();
}
// Example API response
{
"result":"success",
"modelId":123456,
"modelVersion":0,
"title":"cube",
"fileName":"cube.stl",
"contentLength":684,
"fileMd5Checksum":"a6d5646bcb5a1437cb38ad07c45adf7",
"description":"This is a nice cube!",
"isPublic":0,
"isClaimable":0,
"isForSale":false,
"isDownloadable":0,
"materials":{
"6":{
"materialId":6,
"markup":0,
"isActive":1,
"price":4
},
...
"addModelPhoto":{
"method":"POST",
"restUrl":"https:\/\/api.shapeways.com\/models\/v1",
"link":"\/models\/v1"
}
}
}
// Add your access token & model id to the following code examples:
curl -X GET -H "Authorization: Bearer {YOUR_ACCESS_TOKEN}"\
-H "Content-Type: application/json" https://api.shapeways.com\
/models/{MODEL ID}/v1
// Example API response
{
"result":"success",
"modelId":123456,
"modelVersion":0,
"title":"cube",
"fileName":"cube.stl",
"contentLength":684,
"fileMd5Checksum":"a6d5646bcb5a1437cb38ad07c45adf7",
"description":"This is a nice cube!",
"isPublic":0,
"isClaimable":0,
"isForSale":false,
"isDownloadable":0,
"materials":{
"6":{
"materialId":6,
"markup":0,
"isActive":1,
"price":4
},
...
"addModelPhoto":{
"method":"POST",
"restUrl":"https:\/\/api.shapeways.com\/models\/v1",
"link":"\/models\/v1"
}
}
}
// Add your access token, model id to the following code examples:
import requests
access_token = '{YOUR ACCESS TOKEN}'
model_id = '{MODEL ID}'
headers = {
'Authorization': 'Bearer ' + access_token
}
api_url = 'https://api.shapeways.com/models/' + model_id + '/v1'
response = requests.get(url=api_url +'?', headers=headers)
print(response.json()['models'])
// Example API response
{
"result":"success",
"modelId":123456,
"modelVersion":0,
"title":"cube",
"fileName":"cube.stl",
"contentLength":684,
"fileMd5Checksum":"a6d5646bcb5a1437cb38ad07c45adf7",
"description":"This is a nice cube!",
"isPublic":0,
"isClaimable":0,
"isForSale":false,
"isDownloadable":0,
"materials":{
"6":{
"materialId":6,
"markup":0,
"isActive":1,
"price":4
},
...
"addModelPhoto":{
"method":"POST",
"restUrl":"https:\/\/api.shapeways.com\/models\/v1",
"link":"\/models\/v1"
}
}
}
// Add your access token to the following code examples:
curl -X GET -H "Authorization: Bearer {YOUR_ACCESS_TOEKN}" -H "Content-Type: application/json" https://api.shapeways.net/materials/v1
See what types of information are returned by /materials/v1.
Placing orders
Use the /orders/v1 API endpoint to integrate with Shapeways fulfillment services to
seamlessly place and manage orders. Quickly learn how to:
Place orders
Check order statuses
Placing your first order
1. Setting up a payment method
In Settings add and save a credit card.
Placed orders will be charged to the credit card on file for this Shapeways account.
2. Get the Model ID and Material ID
To place an order, the API needs to know both 1) the model you want to order and 2) which material you want to
print it in. Below are two different ways you can locate the Model ID and Material ID.
// Add your Client ID & AUTHORIZATION_CODE to the following code examples:
COMING SOON
// Example API response
COMING SOON
// Add your REDIRECT_URL, Authorization Code, Client ID & Client Secret to the following code examples:
COMING SOON
// Example API response
COMING SOON
Transaction fees
By default, orders placed through the Shapeways API are charged a 5% fee per order. Contact us if you are a growing business and
want to learn about volume discounts.
Not a developer?
If setting up API access seems daunting, don’t worry, we’ve got you covered with a Shopify plug-in.