Contents
Root API URL: https://api.avatarsdk.com/
API endpoints produces JSON responses unless stated otherwise. Please see Content-Type HTTP Header for particular response format.
All POST requests accepts multipart/form-data unless stated otherwise.
All mesh/pointcloud retrieval endpoints produces zip archive with mesh/pointcloud in binary PLY format unless stated otherwise.
Before any of the API methods can be used, you should generate an application identifier (referenced later as client_id) for your app. This identifier is used to obtain the access token which is then used to sign actual API requests. You could use one of the official libraries listed on OAuth site (recommended) or any other on your taste to add OAuth 2.0 support in your app.
In order to get your client_id and client_secret please sign up for AvatarSDK developer account.
Besides client_id and client_secret (depending on application authorization grant type) you will need following settings:
For more information on grant types see section 4 of OAuth 2.0 RFC document.
All requests that return lists are paginated: each particular request return list of requested objects (up to 100 objects per page) and links to first, previous, next and last pages in Link HTTP header. If there are no other pages - Link header will not be present.
Link header may contain up to 4 entries separated by comma ,. Each entry contains URL itself and its relation name (rel) separated by semicolon ;. See example below:
$ curl -v -X GET -H "Authorization: Bearer F88pQWs8hoPzbeCg4xTGifDxxs1eKu" -H "Accept: application/json" "https://api.avatarsdk.com/avatars/?page=3" > GET /avatars/?page=3 HTTP/1.1 > User-Agent: curl/7.35.0 > Host: api.avatarsdk.com > Authorization: Bearer F88pQWs8hoPzbeCg4xTGifDxxs1eKu > Accept: application/json > < HTTP/1.0 200 OK < Date: Mon, 03 Apr 2017 04:08:15 GMT < Link: <https://api.avatarsdk.com/avatars/>; rel="first", <https://api.avatarsdk.com/avatars/?page=2>; rel="prev", <https://api.avatarsdk.com/avatars/?page=4>; rel="next", <https://api.avatarsdk.com/avatars/?page=5>; rel="last" < Content-Type: application/json < Allow: GET, POST, HEAD, OPTIONS < [...]
For more information about Link header see Web Linking RFC document.
Results of list-retrieving requests may be filtered by some fields of requested objects (e.g. creation time, status, etc.) by specifying filters as query parameter. All filters are case-insensitive, unless stated otherwise. Filters may be specified several times. In this case they all will be joined via logical AND. See example below:
$ curl -v -H "Authorization: Bearer F88pQWs8hoPzbeCg4xTGifDxxs1eKu" -X GET "https://api.avatarsdk.com/avatars/?status=completed&description=fb" > GET /avatars/?status=completed&description=fb HTTP/1.1 > User-Agent: curl/7.35.0 > Host: api.avatarsdk.com > Accept: */* > Authorization: Bearer F88pQWs8hoPzbeCg4xTGifDxxs1eKu > < HTTP/1.0 200 OK < Date: Mon, 03 Apr 2017 04:08:15 GMT < Link: <https://api.avatarsdk.com/avatars/?description=fb&status=completed>; rel="first", <https://api.avatarsdk.com/avatars/?description=fb&page=1&status=completed>; rel="last" < Vary: Accept, Cookie < Content-Type: application/json < Allow: GET, POST, HEAD, OPTIONS < [...]
Please see filters section in particular request documentation to find available filters.
API have two different access modes: developer and client access. Client access mode is slightly more restricted in terms of access to some methods: e.g. it is restricted to list all avatars created with the same client_id and allowed to list only those created with the same PlayerUID, etc.
Please see detailed description for each particular method to find more information about available access modes and it's restrictions.
It is highly recommended to use Client access in applications released into production: malicious users won't be able to access or delete data of other users even if client_id and client_secret are compromised.
Client access mode requires to sign each request with PlayerUID identifier along with OAuth access token. To do this you need to register PlayerUID once per unique application (e.g. on first launch) and then sign each request with this PlayerUID via X-PlayerUID HTTP header. See example below:
$ curl -v -H "Authorization: Bearer F88pQWs8hoPzbeCg4xTGifDxxs1eKu" -H "X-PlayerUID: 9418fd52-baef-401c-a2b3-e6fe16d93596" -X GET "https://api.avatarsdk.com/avatars/" > GET /avatars/ HTTP/1.1 > User-Agent: curl/7.35.0 > Host: api.avatarsdk.com > Accept: */* > Authorization: Bearer F88pQWs8hoPzbeCg4xTGifDxxs1eKu > X-PlayerUID: 9418fd52-baef-401c-a2b3-e6fe16d93596 > < HTTP/1.0 200 OK < Date: Mon, 03 Apr 2017 04:08:15 GMT < Vary: Accept, Cookie < Link: <https://api.avatarsdk.com/avatars/>; rel="first", <https://api.avatarsdk.com/avatars/?page=1>; rel="last" < Content-Type: application/json < Allow: GET, POST, HEAD, OPTIONS < [...]
In order to keep our system stable and healthy, we introduced a throttling mechanism which limits how many HTTP requests any particular client is allowed to make. Current limits are set to the following values:
Please note: in the Client access mode there is no limit to a number of requests per SDK account. In order to avoid throttling, please make sure to follow these guidelines:
If application exceeds limits it will receive HTTP 429 TOO MANY REQUESTS response code and Retry-After HTTP Response Header will be set to number of seconds application will need to wait to perform next request. See example below:
$ curl -v -H "Authorization: Bearer F88pQWs8hoPzbeCg4xTGifDxxs1eKu" -X GET "https://api.avatarsdk.com/avatars/" > GET /avatars/ HTTP/1.1 > User-Agent: curl/7.35.0 > Host: api.avatarsdk.com > Accept: */* > Authorization: Bearer F88pQWs8hoPzbeCg4xTGifDxxs1eKu > < HTTP/1.0 429 TOO MANY REQUESTS < Date: Mon, 03 Apr 2017 04:08:15 GMT < Retry-After: 10 < Vary: Accept, Cookie < Content-Type: application/json < Allow: GET, POST, HEAD, OPTIONS < {"detail":"Request was throttled. Expected available in 10.0 seconds."}
We have developed several samples where you could see this API in action:
More API usage examples are coming.
Player model DTO [*]:
{ // absolute URL to this DTO "url": string, // Player unique identifier (PlayerUID) "code": string, // ISO 8601 datetime "created_on": string, // May be used to contain arbitrary information for your taste "comment": string }
[*] | DTO is acronym for Data Transfer Object |
[ { "url":"https://api.avatarsdk.com/players/9418fd52-baef-401c-a2b3-e6fe16d93596/", "code":"9418fd52-baef-401c-a2b3-e6fe16d93596", "created_on":"2017-04-03T04:08:15.589833Z", "comment":"" }, ... ]
Avatar model DTO:
{ // absolute URL to this DTO "url": string, // Avatar identifier "code": string, // Avatar models computing status. One of [Uploading, Queued, Computing, Completed, Failed, Timed Out] "status": string, // current progress of Avatar status. In rage [0:100] "progress": integer, // Avatar name "name": string, // Pipeline used to calculate Avatar "pipeline": string, // Avatar description "description": string, // ISO 8601 datetime "created_on": string, // ISO 8601 last change datetime. May be `null` if haven't changed yet since creation "ctime": string, // absolute URL to retrieve zip with mesh of Avatar "mesh": string, // absolute URL to retrieve jpeg texture of Avatar "texture": string, // absolute URL to retrieve Avatar source image thumbnail "thumbnail": string, // absolute URL to retrieve png preview of Avatar "preview": string, // absolute URL to retrieve list of available haircuts for this Avatar model "haircuts": string, // absolute URL to retrieve zip archive of available blendshapes // for this Avatar model "blendshapes": string }
See avatar blendshapes for more information about blendshapes retrieval
[ { "url":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/", "code":"b63f9737-8594-460a-99a4-74e60b042bd4", "status":"Completed", "progress":100, "name":"Leo", "pipeline": "static", "description":"", "created_on":"2017-04-03T04:08:15.589833Z", "ctime":null, "mesh":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/mesh/", "texture":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/texture/", "thumbnail":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/thumbnail/", "preview":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/preview/", "haircuts":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/haircuts/", "blendshapes":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/blendshapes/" }, ... ]
Create new Avatar calculation task. Available in developer and client access modes. After POSTing a request, Avatar photo for calculation is being uploaded to calculation backend (state Uploading), then Queued until free calculation backend is found, then Computing and finally Completed.
In some cases calculation task may be Failed due to bad (blurry/dark/etc.) photo was submitted or for some other reasons. In rare cases task may be Timed out - calculation took too long time.
It is your responsibility to poll Avatar calculation task for progress (status and progress fields of avatar DTO). Access to the URL fields of incomplete Avatar will not succeed.
Accepts multipart/form-data requests with the following fields:
Accepts multipart/form-data requests with the following fields:
Represents per-Avatar haircuts morphed to fit particular Avatar model geometry.
The same haircuts meshes are interchangeable between different Avatars if corresponding pointcloud is applied. E.g. you could store mesh from Haircut1 of Avatar1, then download only pointclouds for Haircut1 of Avatar2, Avatar3 etc. and replace pointcloud in previously stored mesh. This way you could save customer's network traffic.
Per-Avatar haircut DTO:
{ // identifier of haircut "identity": string, // haircut formal gender. One of [male, female, unisex]. "gender": string, // absolute URL to preview of Avatar model with this haircut applied "preview": string, // absolute URL to this haircut "url": string, // absolute URL to haircut png texture "texture": string, // absolute URL to Avatar model "model": string, // absolute URL to per-avatar haircut point cloud zip "pointcloud": string, // absolute URL to per-avatar haircut mesh zip "mesh": string }
[ { "identity":"female_NewSea_J086f", "gender":"female", "preview":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/haircuts/female_NewSea_J086f/preview/", "url":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/haircuts/female_NewSea_J086f/", "texture":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/haircuts/female_NewSea_J086f/texture/", "model":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/", "pointcloud":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/haircuts/female_NewSea_J086f/pointcloud/", "mesh":"https://api.avatarsdk.com/avatars/b63f9737-8594-460a-99a4-74e60b042bd4/haircuts/female_NewSea_J086f/mesh/" }, ... ]
Retrieve zip archive with all available blendshapes for specific Avatar. If no blendhapes available - request will end with HTTP 204 NO CONTENT response.
By default blendshapes are delivered in ply files packed into zip archive. Blendshapes format may be changed to one fbx file also packed into zip archive.