Skip to main content

Sketchfab client

Project description

Sketchfab API Client

Getting started

Install the module:

pip3 install sketchfab

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)

Why

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sketchfab-0.0.4.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

sketchfab-0.0.4-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file sketchfab-0.0.4.tar.gz.

File metadata

  • Download URL: sketchfab-0.0.4.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for sketchfab-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2e2ac1be76c5136bfd6433426d6a6cb7f22dc4b593023b4a8a8362bbda4bd29e
MD5 f353b8047cbfc718ed8ee2c5bf9baa9b
BLAKE2b-256 d1fde41c28a5cd35ffe207b966f988438faca6a1ecc9a8b39c3077c01a10fced

See more details on using hashes here.

File details

Details for the file sketchfab-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: sketchfab-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for sketchfab-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9128060c1f955f7a781f486f0c7845ec0cbdae100027eaf9118dd709a918964e
MD5 dab2a0f23e8f472e64b740b281ce7a80
BLAKE2b-256 82ac08ec99a4fb66c1c9ea1cc1a37e71c1dec2ec400e9802c613b78dfd05c3ec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page