DOCS

Asset API

The Asset API is a REST API to interact with 3dverse Assets. It allows you to recreate most of the functionalities exposed in the 3dverse Console such as:

  • Uploading source files to 3dverse
  • Tracking conversions into Assets
  • CRUD operations on Assets
  • CRUD operations on Folders
  • Generating 3dverse Users and User Tokens

API Reference

https://docs.3dverse.com/api/

NPM Library

We provide a TypeScript wrapper library to make typesafe API requests and get typed responses: https://www.npmjs.com/package/@3dverse/api.

1
npm install @3dverse/api

Authentication

All API calls require authenticating with an API Key, or in some cases with a User Token. Authentication requirements for each route are defined in the Reference documentation.

To generate an API key, use the 3dverse Console and send an api_key header with your API requests. Make sure you always keep your API key private (do not publish client side).

Alternatively, you can authenticate with a user_token. You’ll have to register a user, generate a token for the user and make sure the user has access to the Folder where the assets are stored.

Generate a User Token

The user token can be used to make API calls client side, such as for Uploading Source Files.

To upload a source file to a folder, you’ll also have to grant access to the folder to the user.

  • The folder ID can be found in the Console or using the Asset API. Or it can be created from the API (as shown in the code samples below).

Javascript Sample

Install the npm package:

1
npm install @3dverse/api

Server code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as api from "@3dverse/api";
const YOUR_API_KEY = "";
api.setApiKey(YOUR_API_KEY);
async function example() {
// Register a user
const { data: user } = await api.registerUser({
username: "my-username",
});
// Generate a user token
const { data: userToken } = await api.generateUserToken({
user_id: user.user_id,
scope: "manage",
});
// Create a folder
const { data: folder } = await api.createFolder({
name: "my-folder",
});
// Grant "manage" access to the folder
await api.grantMemberAccessToFolder({
member_type: "users",
folder_id: folder.folder_id,
member_id: user.user_id,
access: "manage",
});
}

Python Sample

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import requests
API_KEY = "" # INPUT
# Register a user
register_user_url = f"https://api.3dverse.com/app/v1/users"
r = requests.post(register_user_url, headers={'api_key': API_KEY}, data={"username":"my-username"})
response = r.json()
print(f"Register response: \n{response}\n")
# Generate a user token
user_id = response["user_id"]
generate_user_url = f"https://api.3dverse.com/app/v1/users/{user_id}/tokens"
r = requests.post(generate_user_url, headers={'api_key': API_KEY}, data={"scope":"manage", "ttl": "24h"})
response = r.json()
user_token = response["user_token"]
print(f"Generate response: \n{response}\n")
# Create a folder
create_folder_url = "https://api.3dverse.com/app/v1/folders"
r = requests.post(create_folder_url, headers={'api_key': API_KEY}, data={"name":folder_name})
response = r.json()
folder_id = response["folder_id"]
print(f"Create Folder response: \n{response}\n")
# Grant "manage" access to the Folder
member_type = "users"
member_id = user_id
grant_member_access_url = f"https://api.3dverse.com/app/v1/folders/{folder_id}/access/{member_type}/{member_id}"
r = requests.put(grant_member_access_url, headers={'api_key': API_KEY}, data={"access":"manage"})
print(r)
Previous
Livelink.js