API Documentation
IMPERIAL has a RESTful API that allows you to interact with IMPERIAL from virtually any application.
Heres a quick-start guide
IMPERIAL owns two domains
- imperialb.in (opens in a new tab) - The main domain
- impb.in (opens in a new tab) - The secondary domain
API endpoints are available on both domains.
Responses
A response can look like this
{
"success": true,
"data": {
"test": "fields"
}
}
Or if a failed request happened
{
"success": false,
"error": {
"message": "Bad Request",
"errors"?: ZodErrors[]
}
}
Authentication (optional)
Whilst you can use IMPERIAL's API unauthenticated, you will NOT have any options besides changing the language. There are two different ways to authenticate yourself with IMPERIAL's API, either by a user auth token, or an API token (which is assigned to a user).
They look like this
API Token:
imperial_c181MzFhNWFiYTVkM2MwNGU3Y2U4MTRmMTViODNiNjgwYV8xNjc4NTgxNTkwMzQzNzIwOTg
Authentication Token:
imperial_auth_c18wMGU0MjVlODM0ZDI1ODNjNmU3YjYxM2Y5OTAxYzhjM18xNjk0OTE5MzQzODE5ODE3MDM
Create a Document
Creating a document with IMPERIAL's API is really easy, you can either use IMPERIAL's JavaScript SDK, or you can interact with the API directly.
Using the SDK
JavaScript:
import { Imperial } from "imperial.js";
const client = new Imperial(/_ token _/);
client.createDocument("hello world!").then(console.log, console.error);
Using the API
JavaScript:
fetch("https://api.imperialb.in/v1/document", {
method: "POST",
body: JSON.stringify({
content: "hello world!",
}),
});
Get a Document
Getting a document with IMPERIAL's API is really easy, you can either use IMPERIAL's JavaScript SDK, or you can interact with the API directly.
Using the SDK
JavaScript:
import { Imperial } from "imperial.js";
const client = new Imperial(/_ token _/);
client.getDocument("document_id").then(console.log, console.error);
Using the API
JavaScript:
fetch("https://api.imperialb.in/v1/document/:id");
Learn More
If you want to learn more about the API, you can check out the other tabs on the sidebar.