@d-id/node-sdk
v1.9.0
Published
D-ID Node SDK
Downloads
3
Maintainers
Keywords
Readme
D-ID Node SDK
It's time to supercharge your product with the amazing Generative AI capabilities of D-ID's API. Using our state-of-the-art, battle-tested products, you can now create videos of Digital Humans at an unbelievable scale. Combine your ideas with our tech to create astonishing visuals that are high quality and customized to your needs
D-ID Node SDK specifically designed to help you incorporate the D-ID API into your applications with ease.
Installation
Install via npm:
npm install @d-id/node.js-sdk
Install via yarn:
yarn add @d-id/node.js-sdk
Explore the docs.
Table of contents
Enumerations
Classes
Interfaces
- CreateClipRequest
- CreateClipResponse
- CreateStreamIceCandidateRequest
- CreateStreamRequestDto
- CreateStreamResponseDto
- CreateTalkRequest
- CreateTalkResponseDto
- CreateTalkStream200Response
- CreateTalkStreamRequest
- DeleteStreamRequest
- GetClipResponse
- GetClipsDriversResponse
- GetClipsPresentersResponse
- GetClipsResponse
- GetTalkDto
- GetTalksDto
- InitStreamDto
- StartConnection200Response
Usage
Import DidClient
const DidClient = require("@d-id/node.js-sdk").default;
or
import DidClient from "@d-id/node.js-sdk";
Talks
Get talks list
- See for params - TalksClient.list
- See GetTalksDto
const did = new DidClient("DID_API_KEY");
(async () => {
const talks: GetTalksDto = await did.talks.list();
})();
Get talk by id
- See for params - TalksClient.get
- See GetTalkDto
const did = new DidClient("DID_API_KEY");
(async () => {
const talkId = "my-talk-id";
const talk: GetTalkDto = await did.talks.get("talk_id");
})();
Create talk
- See for params - TalksClient.create
- See CreateTalkRequest
- See CreateTalkResponseDto
const did = new DidClient("DID_API_KEY");
(async () => {
const talkRequest: CreateTalkRequest = {
script: {
type: "text",
subtitles: "false",
provider: {
type: "microsoft",
voice_id: "en-US-JennyNeural",
},
ssml: "false",
},
config: {
fluent: "false",
pad_audio: "0.0",
},
};
const createTalkResponse: CreateTalkResponseDto = await did.talks.create(
talkRequest
);
})();
Create talk async
- See for params - TalksClient.create
- See CreateTalkRequest
- See GetTalkDto
const did = new DidClient("DID_API_KEY");
(async () => {
const talkRequest: CreateTalkRequest = {
script: {
type: "text",
subtitles: "false",
provider: {
type: "microsoft",
voice_id: "en-US-JennyNeural",
},
ssml: "false",
},
config: {
fluent: "false",
pad_audio: "0.0",
},
};
const createTalkResponse: Promise<CreateTalkResponseDto> = did.talks
.createAsync(talkRequest)
.then((talk) => {
console.log(talk);
})
.catch((err) => console.log(err));
})();
Delete talk
- See for params - TalksClient.delete
- See GetTalkDto
const did = new DidClient("DID_API_KEY");
(async () => {
const talkId = "my-talk-id";
const deleteResponse = await did.talks.delete(talkId);
})();
Steams
Init a stream
- See for more details - TalksClient.initStream
- See InitStreamDto
- See CreateStreamResponseDto
const did = new DidClient("DID_API_KEY");
(async () => {
const initStreamRequest: InitStreamDto = {
source_url: "https://url/to/a/photo/you/wish/to/animate",
};
const initStreamResponse: CreateStreamResponseDto =
await did.talks.initStream(initStreamRequest);
})();
Start a stream
- See for more details - TalksClient.startStream
- See CreateStreamRequestDto
- See StartConnection200Response
const did = new DidClient("DID_API_KEY");
(async () => {
const streamId = "my-stream-id";
const starStreamRequest: CreateStreamRequestDto = {};
const startStreamResponse: StartConnection200Response =
await did.talks.startStream(streamId, starStreamRequest);
})();
Submit network information
- See for more details - TalksClient.submitNetwork
- See CreateStreamIceCandidateRequest
- See StartConnection200Response
const did = new DidClient("DID_API_KEY");
(async () => {
const streamId = "my-stream-id";
const submitNetworkRequest: CreateStreamIceCandidateRequest = {};
const submitNetworkResponse: StartConnection200Response =
await did.talks.submitNetwork(streamId, submitNetworkRequest);
})();
Create a talk stream
- See for more details - TalksClient.createStream
- See CreateTalkStreamRequest
- See createTalkStreamResponse
const did = new DidClient("DID_API_KEY");
(async () => {
const streamId = "my-stream-id";
const createTalkStreamRequest: CreateTalkStreamRequest = {};
const createTalkStreamResponse: CreateTalkStream200Response =
await did.talks.createStream(streamId, createTalkStreamRequest);
})();
Delete a talk stream
- See for more details - TalksClient.deleteStream
- See DeleteStreamRequest
- See StartConnection200Response
const did = new DidClient("DID_API_KEY");
(async () => {
const streamId = "my-stream-id";
const deleteStreamRequest: DeleteStreamRequest = {
session_id: "session-id",
};
const deleteStreamResponse: StartConnection200Response =
await did.talks.deleteStream(streamId, deleteStreamRequest);
})();
Clips
Get clips
- See for more details - ClipsClient.list
- See GetClipsResponse
const did = new DidClient("DID_API_KEY");
(async () => {
const clipsResponse: GetClipsResponse = await did.clips.list();
})();
Get specific clip
- See for more details - ClipsClient.get
- See GetClipResponse
const did = new DidClient("DID_API_KEY");
(async () => {
const clipId = "my-clip-id";
const clipResponse: GetClipResponse = await did.clips.get(clipId);
})();
Create a clip
- See for more details - ClipsClient.create
- See CreateClipRequest
- See CreateClipResponse
const did = new DidClient("DID_API_KEY");
(async () => {
const createClipRequest: CreateClipRequest = {
script: {
type: "text",
subtitles: "false",
provider: {
type: "microsoft",
voice_id: "en-US-JennyNeural",
},
ssml: "false",
},
config: {
result_format: "mp4",
},
presenter_config: {
crop: {
type: "rectangle",
},
},
};
const createResponse: CreateClipResponse = await did.clips.create(
createClipRequest
);
})();
Create a clip async
- See for more details - ClipsClient.create
- See CreateClipRequest
- See GetClipResponse
const did = new DidClient("DID_API_KEY");
(async () => {
const createClipRequest: CreateClipRequest = {
script: {
type: "text",
subtitles: "false",
provider: {
type: "microsoft",
voice_id: "en-US-JennyNeural",
},
ssml: "false",
},
config: {
result_format: "mp4",
},
presenter_config: {
crop: {
type: "rectangle",
},
},
};
const createResponse: Promise<GetClipResponse> = did.clips
.create(createClipRequest)
.then((clip) => {
console.log(clip);
})
.catch((err) => console.log(err));
})();
Delete clip
- See for params - ClipsClient.delete
- See GetClipsResponse
const did = new DidClient("DID_API_KEY");
(async () => {
const clipId = "my-clip-id";
const deleteResponse = await did.clips.delete(clipId);
})();
Get a list of the presenters
- See for more details - ClipsClient.listPresenters
- See GetClipsPresentersResponse
const did = new DidClient("DID_API_KEY");
(async () => {
const presentersResponse: GetClipsPresentersResponse =
await did.clips.listPresenters();
})();
Get presenter by id
- See for more details - ClipsClient.getPresenter
- See GetClipsPresentersResponse
const did = new DidClient("DID_API_KEY");
(async () => {
const presenterId = "my-presenter-id";
const getPresenterResponse: GetClipsPresentersResponse =
await did.clips.getPresenter(presenterId);
})();
Get presenter drivers by id
- See for more details - ClipsClient.getPresenterDrivers
- See GetClipsDriversResponse
const did = new DidClient("DID_API_KEY");
(async () => {
const presenterId = "my-presenter-id";
const presenterDriversResponse: GetClipsDriversResponse =
await did.clips.getPresenterDrivers(presenterId);
})();
Contribute
TBD
License
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.