Sketchfab API Client
Getting started
Install the module:
pip3 install sketchfab
Using the CLI
SKETCHFAB_API_TOKEN=XXXX sketchfab upload -f my_file.zip
Using the lib
This code creates a directory for each of your collection and places all models inside it.
import os
import sketchfab
sfc = sketchfab.Client('YOUR-API-KEY')
for c in sfc.collections():
print("Collection:", c)
col_dir = os.path.join("download", c.name)
os.makedirs(col_dir, exist_ok=True)
for m in c.models():
model_dir = os.path.join(col_dir, m.name)
print(f" Model: {m.name} ({model_dir})")
if not os.path.exists(model_dir):
os.rename(m.download_to_dir(), model_dir)
Which will give you something like that:
Collection: Collection{empty collection}
Collection: Collection{housing-updates}
Model: tableKitchen80x200 (download/housing-updates/tableKitchen80x200)
Model: kitchenModSink120x65x210 (download/housing-updates/kitchenModSink120x65x210)
Model: kitchenModSink60x65x90 (download/housing-updates/kitchenModSink60x65x90)
Model: kitchenModFridge60x65x210 (download/housing-updates/kitchenModFridge60x65x210)
Model: kitchenModCorner65x65x210 (download/housing-updates/kitchenModCorner65x65x210)
Model: kitchenModBasic10x65x90 (download/housing-updates/kitchenModBasic10x65x90)
Model: kitchenModWasher60x65x210 (download/housing-updates/kitchenModWasher60x65x210)
Model: kitchenModSink60x65x210 (download/housing-updates/kitchenModSink60x65x210)
Model: kitchenModBasic20x65x210 (download/housing-updates/kitchenModBasic20x65x210)
Model: washbasin120x60 (download/housing-updates/washbasin120x60)
Model: kitchenModWasher60x65x90 (download/housing-updates/kitchenModWasher60x65x90)
Model: bedDouble140x200-2 (download/housing-updates/bedDouble140x200-2)
Model: simpleBed90x200 (download/housing-updates/simpleBed90x200)
Model: wcFloor70x40 (download/housing-updates/wcFloor70x40)
Model: kitchenModBasic60x65x90 (download/housing-updates/kitchenModBasic60x65x90)
Model: kitchenModDishWasher60x65x90 (download/housing-updates/kitchenModDishWasher60x65x90)
Model: kitchenModSink120x65x90 (download/housing-updates/kitchenModSink120x65x90)
Model: kitchenModStove60x65x210 (download/housing-updates/kitchenModStove60x65x210)
Model: kitchenModStove60x65x90 (download/housing-updates/kitchenModStove60x65x90)
Model: washbasin60x60 (download/housing-updates/washbasin60x60)
Model: tableKitchen80x140 (download/housing-updates/tableKitchen80x140)
Model: shower90x90 (download/housing-updates/shower90x90)
Model: kitchenModDishWasher60x65x210 (download/housing-updates/kitchenModDishWasher60x65x210)
Model: kitchenModBasic10x65x210 (download/housing-updates/kitchenModBasic10x65x210)
Using docker
$ docker run -e SKETCHFAB_API_TOKEN=XXXXX -ti habx/sketchfab list_collections
Collections are:
2019-10-20 21:12:24,417 Starting new HTTPS connection (1): api.sketchfab.com:443
2019-10-20 21:12:24,762 https://api.sketchfab.com:443 "GET /v3/me/collections HTTP/1.1" 200 None
- Collection 1
- Collection 2
Why
- I couldn't find one
- The sample codes from the sketchfab website are pretty much unuseable
Choices
- The API is designed to be as simple as possible to use
Known issues
-
The code might not be the most elegant. I'm definitely interested by any feedback you can provide me on that.
-
The official swagger-based documentation is not respecting the API behavior. As such you might find that:
- The library enforces some strange rules (like passing a model when creating a model)
- The library doesn't properly use the API (like listing the models of a collection through search)
In both case it was by trial and error that I discovered how to use the API. If you find better ways to do it I'm interested.
-
The listing doesn't work with long lists (it needs to be re-implemented as an iterable calling the listing API)
-
The CLI is pretty much useless at this stage
Missing APIs
You can submit pull-requests or ask me to implement any feature that you need and might be missing.
Metadata
Release files for sketchfab 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sketchfab-0.0.8.tar.gz | 9.3 kB | Without provenance | Details for sketchfab-0.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sketchfab-0.0.8-py3-none-any.whl | Python 3 | none | any | Details for sketchfab-0.0.8-py3-none-any.whl |
Total release size: 18.3 kB
Release files / sketchfab-0.0.8.tar.gz
| Download URL | sketchfab-0.0.8.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69c7601444f3324efc6e4b3ee971fa3547d6a48420d1cc007f4f7f3e271769bc
|
|
BLAKE2b-256 checksum How to use checksums |
dce317e4485ba0f2ed6c4596a21006269487ed8cb391a58c94302460f32c0dcf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Release files / sketchfab-0.0.8-py3-none-any.whl
| Download URL | sketchfab-0.0.8-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c0fecd6ae27cf38631521687301912c61a05fb2d63e9e17ef2c3397e711586d
|
|
BLAKE2b-256 checksum How to use checksums |
2e238f15a241220aa56e55c7f696a4317442a6b24cda236a22eef688fa94536c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for sketchfab 0.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.