Python Shapeways Documentation
Release 1.0.0
Shapeways
Contents 1 shapeways.client 3 2 Installing 9 3 Documentation 11 3.1 Building Documentation . . . 11 4 Versions before 1.0.0 13
5 Indices and tables 15
Python Module Index 17
Python Shapeways Documentation, Release 1.0.0
Contents:
CHAPTER
1
shapeways.client
classshapeways.client.Client(consumer_key, consumer_secret, callback_url=None,
oauth_token=None,oauth_secret=None)
Api client for the Shapeways APIhttp://developers.shapeways.com
The API uses OAuth v1 to authenticate clients, so the following steps must be used. 1.Create a client
2.Connect to API and get request token and authentication url 3.Send user to authentication url
4.Verify callback from authentication url Example:
client = Client("key", "secret") url = client.connect()
# redirect user to ‘url‘
# capture response url from authentication callback
client.verify_url(response_url)
# make api requests
info = client.get_api_info()
Constructor for a newshapeways.client.Client Parameters
• consumer_key(str) – The API key for your app
• consumer_secret(str) – The API secret key for your app
• callback_url(str) – The url that should be redirected to after successful authentication with Shapeways OAuth
• oauth_token(str) – The OAuth token obtained from calls to connect/verify • oauth_secret(str) – The OAuth secret obtained from calls to connect/verify
add_model(params)
Make an API callPOST /models/v1 Required Parameters:
1.file- str (the file data) 2.fileName- str
3.hasRightsToModel- bool
4.acceptTermsAndConditions- bool Optional Parameters: 1.uploadScale- float 2.title- str 3.description- str 4.isPublic- bool 5.isForSale- bool 6.isDownloadable- bool 7.tags- list 8.materials- dict 9.defaultMaterialId- int 10.categories- list
Parameters params(dict) – dict of necessary parameters to make the api call Returns model upload information
Return type dict
Raises Exceptionwhen any of the required parameters are missing
add_model_file(model_id,params)
Make an API callPOST /models/{model_id}/files/v1 Required Parameters:
1.file- str (the file data) 2.fileName- str 3.hasRightsToModel- bool 4.acceptTermsAndConditions- bool Optional Parameters: 1.uploadScale- float Parameters
• model_id(int) – the id of the model to upload the file for • params(dict) – dict of necessary parameters to make the api call Returns file upload information
Return type dict
Raises Exceptionwhen any of the required parameters are missing
add_model_photo(model_id,params)
Make an API callPOST /models/{model_id}/photos/v1 Required Parameters:
1.file- str (the file data)
Python Shapeways Documentation, Release 1.0.0 Optional Parameters: 1.title- str 2.description- str 3.materialId- int 4.isDefault- bool Parameters
• model_id(int) – the id of the model to upload the photo for • params(dict) – dict of necessary parameters to make the api call Returns photo upload information
Return type dict
Raises Exceptionwhen the required parameter is missing
add_to_cart(params)
Make an API callPOST /orders/cart/v1 Required Parameters:
1.modelId- int Optional Parameters:
1.materialId- int 2.quantity- int
Parameters params(dict) – dict of necessary parameters to make the api call Returns whether or not the call was successful
Return type dict
Raises Exceptionwhen the required parameter is missing
connect()
Get an OAuth request token and authentication url
Returns the authentication url that the user must visit or None on error Return type str or None
delete_model(model_id)
Make an API callDELETE /models/{model_id}/v1 Parameters model_id– the id of the model to delete Returns information whether or not it was successful Return type dict
get_api_info()
Make an API callGET /api/v1 Returns api info Return type dict
get_cart()
Make an API callGET /orders/cart/v1 Returns items currently in the cart Return type dict
get_categories()
Make an API callGET /categories/v1
Returns information about all categories Return type dict
get_category(category_id)
Make an API callGET /categories/{category_id}/v1
Parameters category_id(int) – the category to fetch information for Returns information about a specific category
Return type dict
get_material(material_id)
Make an API callGET /materials/{material_id}/v1
Parameters material_id(int) – the id of the material to fetch Returns specific materials info
Return type dict
get_materials()
Make an API callGET /materials/v1
Returns information about all materials Return type dict
get_model(model_id)
Make an API callGET /models/{model_id}/v1
Parameters model_id– the id of the model to fetch Returns data for a specific model
Return type dict
get_model_file(model_id,file_version,include_file=False) Make an API callGET /models/{model_id}/files/{file_version}/v1
Parameters
• model_id(int) – the id of the model to get the file from • file_version(int) – the file version of the file to fetch
• include_file(bool) – whether or not to include the raw file data in the response Returns the file information
Return type dict
get_model_info(model_id)
Make an API callGET /models/{model_id}/info/v1 Parameters model_id– the id of the model to fetch Returns information for a specific model
Python Shapeways Documentation, Release 1.0.0
Return type dict
get_models(page=None)
Make an API callGET /models/v1
Returns information about all user’s models Return type dict
get_price(params)
Make an API callPOST /price/v1 Required Parameters: 1.volume- float 2.area- float 3.xBoundMin- float 4.xBoundMax- float 5.yBoundMin- float 6.yBoundMax- float 7.zBoundMin- float 8.zBoundMax- float Optional Parameters: 1.materials- list
Parameters params(dict) – dict of necessary parameters to make the api call Returns pricing information for theparamsgiven
Return type dict
Raises Exceptionwhen any of the required parameters are missing
get_printer(printer_id)
Make an API callGET /printers/{printer_id}/v1
Parameters printer_id(int) – the printer to fetch information for Returns information about a specific printer
Return type dict
get_printers()
Make an API callGET /printers/v1
Returns information about all printers Return type dict
update_model_info(model_id,params)
Make an API callPUT /models/{model_id}/info/v1 Optional Parameters:
1.uploadScale- float 2.title- str
3.description- str
4.isPublic- bool 5.isForSale- bool 6.isDownloadable- bool 7.tags- list 8.materials- dict 9.defaultMaterialId- int 10.categories- list Parameters
• model_id(int) – the id of the model to get the file from
• params(dict) – dict of necessary parameters to make the api call Returns the model information
Return type dict
url(path)
Generate the full url for an API path
client = Client("key", "secret") url = client.url("/api/")
# "https://api.shapeways.com/api/v1"
Parameters path(str) – The API path to get the url for Returns the full url topath
Return type str
verify(oauth_token,oauth_verifier)
Get an access token and setup OAuth credentials for further use
If you have the full url or query string from the authentication callback then you can use shapeways.client.Client.verify_url() which will parse the correct parameters from the query string and callshapeways.client.Client.verify()
Parameters
• oauth_token(str) – theoauth_tokenparameter from the authentication callback • oauth_verifier(str) – theoauth_verifierparameter from the authentication callback
verify_url(url)
Parse parameters and properly callshapeways.client.Client.verify()
If you already have the oauth_token and oauth_verifier parameters parsed, use shapeways.client.Client.verify()directly instead.
Parameters url(str) – The response url or query string from the authentication callback
CHAPTER
2
Installing
pip install shapeways
CHAPTER
3
Documentation
Documentation can be found atReadTheDocs.
3.1 Building Documentation
Once built the docs can be accessed from/docs/_build/html/index.html
git clone git://github.com/Shapeways/python-shapeways.git cd python-shapeways
make docs
CHAPTER
4
Versions before 1.0.0
The original client was written and maintained by @pauldw for information about versions earlier than v1.0.0 please visithttps://github.com/pauldw/shapeways-python
CHAPTER
5
Indices and tables
• genindex
• modindex
• search
Python Module Index
s
shapeways.client,3
Index
A
add_model() (shapeways.client.Client method),3 add_model_file() (shapeways.client.Client method),4 add_model_photo() (shapeways.client.Client method),4 add_to_cart() (shapeways.client.Client method),5
C
Client (class in shapeways.client),3
connect() (shapeways.client.Client method),5
D
delete_model() (shapeways.client.Client method),5
G
get_api_info() (shapeways.client.Client method),5 get_cart() (shapeways.client.Client method),5 get_categories() (shapeways.client.Client method),6 get_category() (shapeways.client.Client method),6 get_material() (shapeways.client.Client method),6 get_materials() (shapeways.client.Client method),6 get_model() (shapeways.client.Client method),6 get_model_file() (shapeways.client.Client method),6 get_model_info() (shapeways.client.Client method),6 get_models() (shapeways.client.Client method),7 get_price() (shapeways.client.Client method),7 get_printer() (shapeways.client.Client method),7 get_printers() (shapeways.client.Client method),7
S
shapeways.client (module),3
U
update_model_info() (shapeways.client.Client method),7 url() (shapeways.client.Client method),8
V
verify() (shapeways.client.Client method),8 verify_url() (shapeways.client.Client method),8