Sketchfab-v3-model.py working in a strange way: list models from other accounts


(Brestscan3d) #1

Testing the example script to list my models, I get a random list of models which don’t belong to me.
I was able to make the upload script working, then I know that I have the proper Token and all the functions are working in a right way for uploading.
I’m just trying to list my models using the provided function:
def list_my_models():
my_models_endpoint = SKETCHFAB_API_URL + ‘/models’

try:
    r = requests.get(my_models_endpoint, **_get_request_payload())
except requests.exceptions.RequestException as e:
    print u'An API error occured: {}'.format(e)
else:
    data = r.json()

    if not len(data['results']) > 0:
        print u'You don\'t seem to have any model :('

    return data['results']

The “_get_request_payload()” (which is the same and working in the upload process) should provide to the system my authorization then I don’t understand how I can have a list of models which don’t belong to me.
As anyone tested this list-my-models() function recently ?

for reference here is an example of what I get (but it changes every time I run the function !):
Getting models from your profile …
{u’uid’: u’81c140970752432aa01ec0beb5a21834’, u’publishedAt’: u’2019-02-21T09:40:59.040127’, u’likeCount’: 0, u’commentCount’: 0, u’createdAt’: u’2019-02-21T09:40:21.783891’, u’isAgeRestricted’: False, u’tags’: [{u’uri’: u’https://api.sketchfab.com/v3/tags/pamir’, u’name’: u’pamir’, u’slug’: u’pamir’}], u’staffpickedAt’: None, u’isDownloadable’: False, u’embedUrl’: u’085043 - 3D model by Forfar Roof Truss Company - Sketchfab’, u’description’: u’Building exported from Pamir.’, u’animationCount’: 0, u’viewerUrl’: u’085043 - 3D model by Forfar Roof Truss Company (@ForfarRoofTrussCompany) - Sketchfab’, u’isProtected’: False, u’price’: None, u’vertexCount’: 7686, u’user’: {u’username’: u’ForfarRoofTrussCompany’, u’account’: u’basic’, u’displayName’: u’Forfar Roof Truss Company’, u’uid’: u’6dce960801f84185b1f6930227cdef4d’, u’uri’: u’https://api.sketchfab.com/v3/users/6dce960801f84185b1f6930227cdef4d’, u’profileUrl’: u’Forfar Roof Truss Company (@ForfarRoofTrussCompany) - Sketchfab’, u’avatar’: {u’images’: [{u’url’: u’https://media.sketchfab.com/avatars/3496bcf24d1b41b6bb0af0a418ff9cd3/16bbd0dacfdc49f2ae5a6cd0daa0b53b.jpeg’, u’width’: 32, u’size’: 595, u’height’: 32}, {u’url’: u’https://media.sketchfab.com/avatars/3496bcf24d1b41b6bb0af0a418ff9cd3/c816cf8e5bbd4fbc9e248d9903d21b6f.jpeg’, u’width’: 48, u’size’: 942, u’height’: 48}, {u’url’: u’https://media.sketchfab.com/avatars/3496bcf24d1b41b6bb0af0a418ff9cd3/f2b146760e154d259827ad80eb48bbc6.jpeg’, u’width’: 90, u’size’: 1591, u’height’: 90}, {u’url’: u’https://media.sketchfab.com/avatars/3496bcf24d1b41b6bb0af0a418ff9cd3/004632cc16bf409caea8afd3c620fd3f.jpeg’, u’width’: 100, u’size’: 1801, u’height’: 100}], u’uri’: u’https://api.sketchfab.com/v3/avatars/3496bcf24d1b41b6bb0af0a418ff9cd3’}}, u’categories’: [], u’name’: u’085043’, u’viewCount’: 0, u’thumbnails’: {u’images’: [{u’url’: u’https://media.sketchfab.com/urls/81c140970752432aa01ec0beb5a21834/dist/thumbnails/4cf0fd6494ea495e9caa54f15dae0b5b/418d539f1f824fb1b9f36b1d6843c160.jpeg’, u’width’: 1920, u’size’: 150535, u’uid’: u’40aaf9e98caf496a90e65548ad7c4293’, u’height’: 1080}, {u’url’: u’https://media.sketchfab.com/urls/81c140970752432aa01ec0beb5a21834/dist/thumbnails/4cf0fd6494ea495e9caa54f15dae0b5b/826e51f00a0244aa925b75843946b452.jpeg’, u’width’: 1024, u’size’: 47083, u’uid’: u’edf57b8f1ef1431e97b3dddb6b28e1d5’, u’height’: 576}, {u’url’: u’https://media.sketchfab.com/urls/81c140970752432aa01ec0beb5a21834/dist/thumbnails/4cf0fd6494ea495e9caa54f15dae0b5b/88d858441415465d9649f3e6a883445f.jpeg’, u’width’: 720, u’size’: 25867, u’uid’: u’1bf476cf341445e6aea653938138ecb5’, u’height’: 405}, {u’url’: u’https://media.sketchfab.com/urls/81c140970752432aa01ec0beb5a21834/dist/thumbnails/4cf0fd6494ea495e9caa54f15dae0b5b/b25cf789f276457e80b4d8df71c2d258.jpeg’, u’width’: 256, u’size’: 4127, u’uid’: u’6371dd7aaba1411c9b3067a853f6da77’, u’height’: 144}, {u’url’: u’https://media.sketchfab.com/urls/81c140970752432aa01ec0beb5a21834/dist/thumbnails/4cf0fd6494ea495e9caa54f15dae0b5b/796874b4d66548f7a5ecb64546f41ca5.jpeg’, u’width’: 64, u’size’: 692, u’uid’: u’fecdd75e378a46fb81d2c128bdd18b87’, u’height’: 36}]}, u’license’: None, u’soundCount’: 0, u’uri’: u’https://api.sketchfab.com/v3/models/81c140970752432aa01ec0beb5a21834’, u’faceCount’: 9404}
Now do some more stuff on model 81c140970752432aa01ec0beb5a21834
{u’uid’: u’e60c629067b2416486fc05c97eba19d9’, u’publishedAt’: u’2019-02-21T09:40:08.396073’, u’likeCount’: 0, u’commentCount’: 0, u’createdAt’: u’2019-02-21T09:39:28.103585’, u’isAgeRestricted’: False, u’tags’: [{u’uri’: u’https://api.sketchfab.com/v3/tags/pamir’, u’name’: u’pamir’, u’slug’: u’pamir’}], u’staffpickedAt’: None, u’isDownloadable’: False, u’embedUrl’: u’Ambrozja_2A - 3D model by WOBANA - Sketchfab’, u’description’: u’Building exported from Pamir.’, u’animationCount’: 0, u’viewerUrl’: u’Ambrozja_2A - 3D model by WOBANA (@WOBANA) - Sketchfab’, u’isProtected’: False, u’price’: None, u’vertexCount’: 11049, u’user’: {u’username’: u’WOBANA’, u’account’: u’basic’, u’displayName’: u’WOBANA’, u’uid’: u’8bf4b8fd37434770a3fa5a5339d2dba8’, u’uri’: u’https://api.sketchfab.com/v3/users/8bf4b8fd37434770a3fa5a5339d2dba8’, u’profileUrl’: u’WOBANA (@WOBANA) - Sketchfab’, u’avatar’: {u’images’: [{u’url’: u’https://media.sketchfab.com/avatars/78fa317e46024a5283765aa34df5e508/aec92fe9a74e499c98d759362cd7f02f.jpeg’, u’width’: 100, u’size’: 6421, u’height’: 100}, {u’url’: u’https://media.sketchfab.com/avatars/78fa317e46024a5283765aa34df5e508/17fa177ffaa344a2b2fc8e78efd40fbb.jpeg’, u’width’: 48, u’size’: 2518, u’height’: 48}, {u’url’: u’https://media.sketchfab.com/avatars/78fa317e46024a5283765aa34df5e508/02162695bdc840faa3bcb2d418309c5e.jpeg’, u’width’: 90, u’size’: 5653, u’height’: 90}, {u’url’: u’https://media.sketchfab.com/avatars/78fa317e46024a5283765aa34df5e508/6fde876cbded4cd48d36a76029e3aa02.jpeg’, u’width’: 32, u’size’: 1350, u’height’: 32}], u’uri’: u’https://api.sketchfab.com/v3/avatars/78fa317e46024a5283765aa34df5e508’}}, u’categories’: [], u’name’: u’Ambrozja_2A’, u’viewCount’: 0, u’thumbnails’: {u’images’: [{u’url’: u’https://media.sketchfab.com/urls/e60c629067b2416486fc05c97eba19d9/dist/thumbnails/983add384c274af6abe3afd5e0971208/baf76674f8ea49dd8c7ae86343cb4315.jpeg’, u’width’: 1920, u’size’: 103511, u’uid’: u’4ddfae7dd1c04b4682a2d749e233f55c’, u’height’: 1080}, {u’url’: u’https://media.sketchfab.com/urls/e60c629067b2416486fc05c97eba19d9/dist/thumbnails/983add384c274af6abe3afd5e0971208/aa73e458ed944ca4b2c2d89453821aef.jpeg’, u’width’: 1024, u’size’: 33055, u’uid’: u’4d6faaa8163c42bba076ddb15f249577’, u’height’: 576}, {u’url’: u’https://media.sketchfab.com/urls/e60c629067b2416486fc05c97eba19d9/dist/thumbnails/983add384c274af6abe3afd5e0971208/7038a0f33d1c4f03beb31d1275e513e0.jpeg’, u’width’: 720, u’size’: 17840, u’uid’: u’87d56ec07bfe4c398c00951930ef388b’, u’height’: 405}, {u’url’: u’https://media.sketchfab.com/urls/e60c629067b2416486fc05c97eba19d9/dist/thumbnails/983add384c274af6abe3afd5e0971208/ce626016c143432ba59e1b0d8bf5a089.jpeg’, u’width’: 256, u’size’: 3295, u’uid’: u’839886a9dda84da8baf39673e697c9dd’, u’height’: 144}, {u’url’: u’https://media.sketchfab.com/urls/e60c629067b2416486fc05c97eba19d9/dist/thumbnails/983add384c274af6abe3afd5e0971208/b45ff0e8276c4cd6b8caf39acf06791a.jpeg’, u’width’: 64, u’size’: 716, u’uid’: u’215e919928d7446ea6939f7d3d83d4ae’, u’height’: 36}]}, u’license’: None, u’soundCount’: 0, u’uri’: u’https://api.sketchfab.com/v3/models/e60c629067b2416486fc05c97eba19d9’, u’faceCount’: 13412}
Now do some more stuff on model e60c629067b2416486fc05c97eba19d9
{u’uid’: u’bdb608e87fc7444c925164c8d7ed2f3e’, u’publishedAt’: u’2019-02-21T09:42:12.373025’, u’likeCount’: 0, u’commentCount’: 0, u’createdAt’: u’2019-02-21T09:37:53.180850’, u’isAgeRestricted’: False, u’tags’: [], u’staffpickedAt’: None, u’isDownloadable’: False, u’embedUrl’: u’Thibaut Claes 3 - 3D model by Treedys - Sketchfab’, u’description’: u’’, u’animationCount’: 0, u’viewerUrl’: u’Thibaut Claes 3 - 3D model by Treedys (@treedys) - Sketchfab’, u’isProtected’: False, u’price’: None, u’vertexCount’: 174896, u’user’: {u’username’: u’treedys’, u’account’: u’prem’, u’displayName’: u’Treedys’, u’uid’: u’d9fdc9e01690471e8e4e9160a5afbf49’, u’uri’: u’https://api.sketchfab.com/v3/users/d9fdc9e01690471e8e4e9160a5afbf49’, u’profileUrl’: u’Treedys (@treedys) - Sketchfab’, u’avatar’: {u’images’: [{u’url’: u’https://media.sketchfab.com/avatars/865ca971cba94f54881fec97c902bd0e/a4a0f73448b74d529dc2d6715f65e935.jpeg’, u’width’: 32, u’size’: 1214, u’height’: 32}, {u’url’: u’https://media.sketchfab.com/avatars/865ca971cba94f54881fec97c902bd0e/8dbe4fa3ea354bc4817d7a9818955e1c.jpeg’, u’width’: 48, u’size’: 1685, u’height’: 48}, {u’url’: u’https://media.sketchfab.com/avatars/865ca971cba94f54881fec97c902bd0e/730b6667858446a1b927ff8c81b11bfc.jpeg’, u’width’: 90, u’size’: 3035, u’height’: 90}, {u’url’: u’https://media.sketchfab.com/avatars/865ca971cba94f54881fec97c902bd0e/acae0abf9bea456e86ed41b88a398722.jpeg’, u’width’: 100, u’size’: 3358, u’height’: 100}], u’uri’: u’https://api.sketchfab.com/v3/avatars/865ca971cba94f54881fec97c902bd0e’}}, u’categories’: [], u’name’: u’Thibaut Claes 3’, u’viewCount’: 0, u’thumbnails’: {u’images’: [{u’url’: u’https://media.sketchfab.com/urls/bdb608e87fc7444c925164c8d7ed2f3e/dist/thumbnails/2d2065f817b540368569dc20f674b970/bc9cbd42ea284b78a3da3d3d40f0b5ff.jpeg’, u’width’: 1920, u’size’: 150187, u’uid’: u’25fd619cfba849379d3c8287fef618dc’, u’height’: 1080}, {u’url’: u’https://media.sketchfab.com/urls/bdb608e87fc7444c925164c8d7ed2f3e/dist/thumbnails/2d2065f817b540368569dc20f674b970/8e10a130c9e048cc9369723c6dfd0ee0.jpeg’, u’width’: 1024, u’size’: 48388, u’uid’: u’df1bdd532ad649b7964498602ef682be’, u’height’: 576}, {u’url’: u’https://media.sketchfab.com/urls/bdb608e87fc7444c925164c8d7ed2f3e/dist/thumbnails/2d2065f817b540368569dc20f674b970/159b47e73b024226a636c4d66faeca3a.jpeg’, u’width’: 720, u’size’: 27714, u’uid’: u’cffef0c539f14799a53e141912c0717b’, u’height’: 405}, {u’url’: u’https://media.sketchfab.com/urls/bdb608e87fc7444c925164c8d7ed2f3e/dist/thumbnails/2d2065f817b540368569dc20f674b970/403ebd72b0b4498bb3cd9d09f685ccc3.jpeg’, u’width’: 256, u’size’: 5477, u’uid’: u’49197a8920434924a8ce9cba389fa92d’, u’height’: 144}, {u’url’: u’https://media.sketchfab.com/urls/bdb608e87fc7444c925164c8d7ed2f3e/dist/thumbnails/2d2065f817b540368569dc20f674b970/559f7fe9f1784739b6c5ad4b16b8482a.jpeg’, u’width’: 64, u’size’: 988, u’uid’: u’9f4f2ce50245437bb644f08d1f18facc’, u’height’: 36}]}, u’license’: None, u’soundCount’: 0, u’uri’: u’https://api.sketchfab.com/v3/models/bdb608e87fc7444c925164c8d7ed2f3e’, u’faceCount’: 350000}
Now do some more stuff on model bdb608e87fc7444c925164c8d7ed2f3e


(Tiagojdferreira) #2

Hi @brestscan3d !

It seems you are using the public /models endpoint:
https://docs.sketchfab.com/data-api/v3/index.html#!/models/get_v3_models

And what you want to use is your list of models:
https://docs.sketchfab.com/data-api/v3/index.html#!/models/get_v3_me_models

Hope this helps, feel free to ask any follow up questions.

Cheers,


(Brestscan3d) #3

thanks… but as in your example, I’m using:

def list_my_models():
my_models_endpoint = SKETCHFAB_API_URL + '/models'

(Tiagojdferreira) #4

Could you give me the url of where in the docs you found that code so I can update it?

Our API has multiple endpoints. The endpoint /models is for all public models and /me/models is for your own models (private or public). In you case you will want to do:

def list_my_models():
    my_models_endpoint = SKETCHFAB_API_URL + '/me/models'

For a full example you can look at the python example using api v3, Data API v3 with Python - Developers - Sketchfab

def list_my_models():
    my_models_endpoint = os.path.join(SKETCHFAB_API_URL, 'me', 'models')

    try:
        r = requests.get(my_models_endpoint, **_get_request_payload())
    except requests.exceptions.RequestException as e:
        print u'An API error occured: {}'.format(e)
    else:
        data = r.json()

        if not len(data['results']) > 0:
            print u'You don\'t seem to have any model :('

        return data['results']