Package Exports
- @samuel-butcher-typedb/typedb-http-driver
Readme
TypeDB HTTP Typescript Driver
Driver Architecture
To learn about how the TypeDB HTTP driver communicates with the TypeDB Server, refer to the HTTP API Reference.
API Reference
To learn about the methods available for executing queries and retrieving their answers using Typescript, refer to the API Reference.
Install TypeDB HTTP Typescript Driver through NPM
- Install
typedb-driver-httpthrough npm:
npm install typedb-driver-http- Make sure the TypeDB Server is running.
- Use TypeDB Driver in your program:
import { TypeDBHttpDriver, isApiErrorResponse } from "typedb-driver-http";
const driver = new TypeDBHttpDriver({
username: "admin",
password: "password",
addresses: [ "localhost:1729" ],
});
const transactionResponse = await driver.openTransaction("database-name", "read");
if (isApiErrorResponse(transactionResponse)) throw transactionResponse.err;
const transactionId = transactionResponse.ok.transactionId;
const answerResponse = await driver.query(transactionId, "match entity $x;");
if (isApiErrorResponse(answerResponse)) throw answerResponse.err;
const answer = answerResponse.ok;
if (answer.answerType === "conceptRows") {
answer.answers.forEach((row) => {
console.log(row.data)
})
}