Created
April 12, 2013 23:59
-
-
Save revolunet/5376129 to your computer and use it in GitHub Desktop.
sample sketchfab API upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- encoding: UTF-8 -*- | |
| import os | |
| # pip install requests if not installed | |
| import requests | |
| def sketchfab_send(fullpath, title, tags='', description=''): | |
| ''' sends a 3D model to the sketchfab API ''' | |
| url = 'https://api.sketchfab.com/v1/models' | |
| token_api = '123abc' | |
| private = 1 | |
| password = 'sketchfabrox' | |
| data = { | |
| 'title': title, | |
| 'description': description, | |
| 'fileModel': open(fullpath).read(), | |
| 'filenameModel': os.path.basename(fullpath), | |
| 'tags': tags, | |
| 'token': token_api, | |
| 'private': private, | |
| 'password': password | |
| } | |
| result = requests.post(url, data=data) | |
| return result.content | |
| result = sketchfab_send('/path/to/model.dae', | |
| title='My awesome model', | |
| tags='test collada glasses', | |
| description='This is my first sketchfab upload' | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment