A client library for the Cloudnode API, written in TypeScript. Documentation
npm install cloudnode-ts
import Cloudnode from 'cloudnode-ts';
const cloudnode = new Cloudnode("token_YourSecretToken123");
// get a newsletter
const newsletter = await cloudnode.newsletter.get("newsletter_123asd");
// get response status code
console.log(newsletter._response.status); // 200
const Cloudnode = require('cloudnode-ts');
const cloudnode = new Cloudnode("token_YourSecretToken123");
// get a newsletter
const newsletter = await cloudnode.newsletter.get("newsletter_123asd");
console.log(newsletter._response.status); // 200
Download the browser version from browser/Cloudnode.js
or use our hosted version.
<script src="https://cdn.jsdelivr.net/npm/cloudnode-ts@latest/browser/Cloudnode.min.js"></script>
<script>
const cloudnode = new Cloudnode();
// get a newsletter
const newsletter = await cloudnode.newsletter.get("newsletter_123asd");
console.log(newsletter._response.status); // 200
</script>
Warning: You most likely don't want to set your private token in a public front-end website, as this will allow anyone who sees your front-end JavaScript code to use it for possibly malicious purposes. We advise you use a back-end server to proxy requests to our API, so you do not expose your token to the public.
import Cloudnode from 'cloudnode-ts';
const cloudnode = new Cloudnode("token_YourSecretToken123");
// get a newsletter
const newsletter: Cloudnode.Newsletter = await cloudnode.newsletter.get("newsletter_123asd");
If you want to access response metadata (headers, status code, etc.), use Cloudnode.ApiResponse<T>
, e.g.:
const newsletter: Cloudnode.ApiResponse<Cloudnode.Newsletter> = await cloudnode.newsletter.get("newsletter_123asd");
console.log(newsletter.id); // newsletter_123asd
console.log(newsletter._response.status); // 200
Table of contents
-
new Cloudnode([token], [options])
cloudnode.getPage<T>(response, page)
cloudnode.getNextPage<T>(response)
cloudnode.getPreviousPage<T>(response)
cloudnode.getAllPages<T>(response)
cloudnode.checkCompatibility()
cloudnode.account.changePassword(currentPassword, newPassword)
cloudnode.account.get()
cloudnode.account.getEmail()
cloudnode.account.getIdentity()
cloudnode.account.listEmails()
cloudnode.account.listPermissions()
cloudnode.account.replaceIdentity(username, name)
cloudnode.account.setEmail(email)
cloudnode.account.updateIdentity(username, [name])
cloudnode.auth.login(user, password)
cloudnode.auth.register(username, email, password)
cloudnode.newsletters.get(id)
cloudnode.newsletters.list([limit], [page])
cloudnode.projects.create(name)
cloudnode.projects.delete(id)
cloudnode.projects.get(id)
cloudnode.projects.list([limit], [page])
cloudnode.projects.update(id, name)
cloudnode.subscriptions.create(newsletter, email, [data])
cloudnode.subscriptions.delete(id)
cloudnode.subscriptions.get(id)
cloudnode.subscriptions.list([limit], [page])
cloudnode.tokens.create(permissions, lifetime, [note])
cloudnode.tokens.get(id)
cloudnode.tokens.getRequest(id, request)
cloudnode.tokens.list([limit], [page], [internal])
cloudnode.tokens.listRequests(id, [limit], [page])
cloudnode.tokens.refresh(id)
cloudnode.tokens.revoke(id)
-
- Class:
Cloudnode.ApiResponse<T>
- Class:
Cloudnode.RawResponse
- Enum:
Cloudnode.CompatibilityStatus
- Interface:
Cloudnode.AccountDetails
- Interface:
Cloudnode.AccountEmail
- Interface:
Cloudnode.AccountIdentity
- Interface:
Cloudnode.DatedNewsletterSubscription
- Interface:
Cloudnode.DatedPrimaryEmail
- Interface:
Cloudnode.Error
- Interface:
Cloudnode.Newsletter
- Interface:
Cloudnode.NewsletterData
- Interface:
Cloudnode.NewsletterSubscription
- Interface:
Cloudnode.Options
- Interface:
Cloudnode.PaginatedData<T>
- Interface:
Cloudnode.PartialToken
- Interface:
Cloudnode.Permission
- Interface:
Cloudnode.PrimaryEmail
- Interface:
Cloudnode.Project
- Interface:
Cloudnode.Request
- Interface:
Cloudnode.ShortRequest
- Interface:
Cloudnode.Token
- Interface:
Cloudnode.TokenMetadata
- Class:
A client library for the Cloudnode API, written in TypeScript. Documentation
Construct a new Cloudnode API client
token
string
API token to use for requests.options
Partial<Cloudnode.Options>
API client options. Default:{baseUrl: "https://api.cloudnode.pro/v5/", autoRetry: true, maxRetryDelay: 5, maxRetries: 3}
Get another page of paginated results
response
Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>
Response to get a different page of.page
number
Page to get.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null>
The new page or null if the page is out of bounds - Throws:
Cloudnode.Error
Error returned by the API
Get next page of paginated results
response
Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>
Response to get the next page of.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null>
The next page or null if this is the last page - Throws:
Cloudnode.Error
Error returned by the API
Get previous page of paginated results
response
Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>
Response to get the previous page of.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null>
The previous page or null if this is the first page - Throws:
Cloudnode.Error
Error returned by the API
Get all other pages of paginated results and return the complete data
Warning: Depending on the amount of data, this can take a long time and use a lot of memory.
response
Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>
Response to get all pages of.- Returns:
Promise<Cloudnode.PaginatedData<T>>
All of the data in 1 page - Throws:
Cloudnode.Error
Error returned by the API
Check compatibility with the API
- Returns:
Promise<Cloudnode.CompatibilityStatus>
Change account password. Requires token with scope account.details.password.update
.
currentPassword
string
Your current password.newPassword
string
The new password. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.- Returns:
Promise<Cloudnode.ApiResponse<void>>
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Get account details. Requires token with scope account.details
.
- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.AccountDetails>>
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Get your primary e-mail address. Requires token with scope account.details.email
.
- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.DatedPrimaryEmail>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Get account identity. Requires token with scope account.details.identity
.
- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.AccountIdentity>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
List account e-mail addresses. Requires token with scope account.details.email.list
.
- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<Cloudnode.AccountEmail[]>>>
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
List account permissions with user-friendly descriptions. Some permissions (such as wildcard ones) may be excluded in this list if they don't have a description. Requires token with scope account.details
.
- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<Cloudnode.Permission[]>>>
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Replace account identity. Requires token with scope account.details.identity.update
.
username
string
Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start withuser_
.name
string | null
Your full name. Set tonull
to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z',-.,
andÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ
.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.AccountIdentity>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "CONFLICT"}
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Set your primary e-mail address. Requires token with scope account.details.email.update
.
email
string
E-mail address to set as primary.- Returns:
Promise<Cloudnode.ApiResponse<void>>
- Throws:
Cloudnode.Error & {code: "CONFLICT"}
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Update account identity. Requires token with scope account.details.identity.update
.
username
string
Your unique username. Between 3 and 20 characters. Only letters, numbers, dashes and underscores. May not start withuser_
.name
string | null
Your full name. Set tonull
to remove. Min 2 characters, max 32. Allowed characters (lowercase as well): A–Z',-.,
andÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞSŸ
.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.AccountIdentity | void>>
void
if nothing was changed. - Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "CONFLICT"}
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Create a session using user ID/username/e-mail and password.
Note: Logging in can only be performed from residential IP. Proxying this endpoint will likely not work. It is normally not recommended to use this endpoint to gain API access. Instead, create a token from your account to use with the API.
user
string
User ID (starts withuser_
), username or e-mail address.password
string
The password of the account.- Returns:
Promise<Cloudnode.ApiResponse<{session: string}>>
Session token. Also returned inSet-Cookie
header. - Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "IP_REJECTED"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Create an account and session. After signing up, a welcome e-mail is sent to confirm your e-mail address.
Note: Registering an account can only be performed from residential IP. Proxying this endpoint will likely not work. Creating multiple/alternate accounts is not allowed as per the Terms of Service.
username
string
The username to use for the account. Must be between 3 and 20 characters long. Cannot start withuser_
. May contain only letters, numbers, dashes and underscores. Must be unique.email
string
The e-mail address to register. A valid unique non-disposable e-mail that can receive mail is required.password
string
The password to use for the account. Must be at least 15 characters, or 8 characters if it contains a mix of letters, numbers and symbols.- Returns:
Promise<Cloudnode.ApiResponse<{session: string}>>
Session token. Also returned inSet-Cookie
header. - Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "IP_REJECTED"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Get newsletter
id
string
A newsletter ID.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.Newsletter>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
List newsletters
limit
number
The number of newsletters to return per page. No more than 50. Default:10
page
number
The page number. No more than 2³² (4294967296). Default:1
- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<Cloudnode.Newsletter[]>>>
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Create a project. Requires token with scope projects.create.own
.
name
string
Project name. Max 255 characters.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.Project>>
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Delete a project. Requires token with scope projects.delete.own
.
id
string
Project ID.- Returns:
Promise<Cloudnode.ApiResponse<void>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Get a project. Requires token with scope projects.get.own
.
id
string
Project ID.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.Project>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
List projects. Requires token with scope projects.get.own
.
limit
number
The number of projects to return per page. No more than 100. Default:20
page
number
The page number. No more than 2³² (4294967296). Default:1
- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<Cloudnode.Project[]>>>
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Update a project. Requires token with scope projects.update.own
.
id
string
Project ID.name
string
Project name. Max 255 characters.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.Project>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Subscribe to newsletter
newsletter
string
The ID of the newsletter to subscribe to.email
string
Subscriber's email address.data
Record<string, string | number | boolean>
Additional data that this newsletter requires.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.NewsletterSubscription>>
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "CONFLICT"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Unsubscribe from newsletter
id
string
The ID of the subscription to revoke.- Returns:
Promise<Cloudnode.ApiResponse<void>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Get newsletter subscription
id
string
The ID of the subscription to get.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.DatedNewsletterSubscription>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
List newsletter subscriptions. Requires token with scope newsletter.subscriptions.list.own
.
limit
number
The number of subscriptions to return per page. No more than 50. Default:10
page
number
The page number. No more than 2³² (4294967296). Default:1
- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<Cloudnode.DatedNewsletterSubscription[]>>>
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Create token. Requires token with scope tokens.create.own
.
permissions
string[]
List of permissions to grant to the token. You must already have each of these permissions with your current token.lifetime
number
Lifetime of the token in seconds. If null, the token will never expire (not recommended). Max: 31560000 (1 year). Min: 60 (1 minute).note
string
A user-specified note to label the token. Max length: 2⁸ (256) characters.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.Token>>
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Get token details. Requires token with scope tokens.get.own
.
id
string | "current"
The ID of the token to get. Specifycurrent
to get information about the token that was used to authenticate the request.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.Token>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Get a recent request by ID. Requires token with scope tokens.get.own.requests
.
id
string | "current"
The ID of the token. Specifycurrent
to get information about the token that was used to authenticate the request.request
string
The ID of the request.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.Request>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "MODIFICATION_NOT_ALLOWED"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
List tokens of user. Requires token with scope tokens.list.own
.
limit
number
The number of tokens to return per page. No more than 50. Default:10
page
number
The page number. No more than 2³² (4294967296). Default:1
internal
any
Internal tokens are returned as well if this parameter is present.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<Cloudnode.PartialToken[]>>>
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Get list of recent requests made with the token. Requires token with scope tokens.get.own.requests
.
id
string | "current"
The ID of the token. Specifycurrent
to get information about the token that was used to authenticate the request.limit
number
The number of requests to return per page. No more than 50. Default:10
page
number
The page number. No more than 2³² (4294967296). Default:1
- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<Cloudnode.ShortRequest[]>>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Refresh current token. The token that was used to authenticate the request will be deleted. A new token with a new ID but the same permissions will be created and returned. The lifespan of the new token will be the same as the old one, starting from the time of the request. This operation effectively allows a token to be used indefinitely. Requires token with scope token.refresh
.
id
string | "current"
The ID of the token to refresh. Specifycurrent
to refresh the token that was used to authenticate the request.- Returns:
Promise<Cloudnode.ApiResponse<Cloudnode.Token>>
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
Revoke token. Requires token with scope tokens.revoke.own
.
id
string | "current"
The ID of the token to revoke. Specifycurrent
to revoke the token that was used to authenticate the request.- Returns:
Promise<Cloudnode.ApiResponse<void>>
- Throws:
Cloudnode.Error & {code: "RESOURCE_NOT_FOUND"}
- Throws:
Cloudnode.Error & {code: "INVALID_DATA"}
- Throws:
Cloudnode.Error & {code: "MODIFICATION_NOT_ALLOWED"}
- Throws:
Cloudnode.Error & {code: "UNAUTHORIZED"}
- Throws:
Cloudnode.Error & {code: "NO_PERMISSION"}
- Throws:
Cloudnode.Error & {code: "RATE_LIMITED"}
- Throws:
Cloudnode.Error & {code: "INTERNAL_SERVER_ERROR"}
- Throws:
Cloudnode.Error & {code: "MAINTENANCE"}
A client library for the Cloudnode API, written in TypeScript. Documentation
An API response. This class implements the interface provided as T
and includes all of its properties.
_response
Cloudnode.RawResponse
Raw API response
Raw API response
headers
Record<string, string>
The headers returned by the server. (read-only)ok
boolean
A boolean indicating whether the response was successful (status in the range200
–299
) or not. (read-only)redirected
boolean
Indicates whether or not the response is the result of a redirect (that is, its URL list has more than one entry). (read-only)status
number
The status code of the response. (read-only)statusText
string
The status message corresponding to the status code. (e.g.,OK
for200
). (read-only)url
string
The URL of the response. (read-only)
API client compatibility status
COMPATIBLE
"compatible"
Fully compatible (API patch version may differ)OUTDATED
"outdated"
Compatible, but outdated (i.e. existing APIs will work, but you are missing out on new features).INCOMPATIBLE
"incompatible"
API has implemented breaking changes which are not compatible with this client.
Details about your account
id
string
Your user IDpassword
boolean
Whether you have a password setgroup
string
The name of your permission grouppermissions
string[]
A list of all permission that you have access toidentity
AccountIdentity | null
Personal information associated with your account. Requiresaccount.details.identity
to see. Maybe be null if the account is anonymised or you don't have permission to access the account identity.email
PrimaryEmail | null
Your current primary account e-mail address. Requiresaccount.details.email
to see. Maybe be null if you don't have a primary e-mail address or you don't have permission to access the account's e-mail address.
An e-mail address you have added to your account
id
string
The ID of the e-mail addressaddress
string | null
Your e-mail address. May ben null if anonymised.verified
boolean
Whether this e-mail address has been verifiedprimary
boolean
Whether this e-mail address is your primary e-mail addressadded
Date
The date and time when this e-mail address was added to your account
Personal information associated with your account
A newsletter subscription with a creation date
id
string
The ID of the subscription. Can be used to unsubscribe.email
string
The email address of the subscribernewsletter
string
The ID of the newsletter that was subscribed todate
Date
The date the subscription was created
Your current primary account e-mail address with a timestamp of when it was added to your account
id
string
The ID of the e-mail addressaddress
string | null
Your e-mail address. May ben null if anonymised.verified
boolean
Whether this e-mail address has been verifiedadded
Date
The date and time when this e-mail address was added to your account
An API error response.
message
string
A human-readable description of this errorcode
string
Error codefields
Record<string, string | Record<string, string>>
Affected request fields. The key is the name of the input parameter (e.g. from the request body or query string) and the value is a human-readable error message for that field.
A newsletter that you can subscribe to
id
string
The unique identifier for this newslettername
string
The name of this newsletterdata
Record<string, NewsletterData>
Additional data that is required to subscribe to this newsletter
A data field that is required to subscribe to this newsletter
name
string
The name of the fielddescription
string | undefined
Description of the fieldtype
"string" | "number" | "boolean"
The type of datarequired
boolean
Whether this field is required
Your subscription to a newsletter
id
string
The ID of the subscription. Can be used to unsubscribe.email
string
The email address of the subscribernewsletter
string
The ID of the newsletter that was subscribed to
API client options
baseUrl
string
The base URL of the APIautoRetry
boolean
Whether to automatically retry requests that fail temporarily. If enabled, when a request fails due to a temporary error, such as a rate limit, the request will be retried after the specified delay.maxRetryDelay
number
The maximum number of seconds that is acceptable to wait before retrying a failed request. This requiresautoRetry
to be enabled.maxRetries
number
The maximum number of times to retry a failed request. This requiresautoRetry
to be enabled.
Paginated response
items
T[]
The page itemstotal
number
The total number of itemslimit
number
The number of items per pagepage
number
The current page number
A token, however, the permissions
field is not included
id
string
The ID or key of the tokencreated
Date
Date and time when this token was createdexpires
Date | null
Date and time when this token expires. Null if it never expires.internal
string | undefined
Whether this token is for internal use only, e.g. to power a session. In other words, an internal token is one that was not created by the client.metadata
Cloudnode.TokenMetadata
Additional metadata about this token
A permission node
permission
string
The permission node stringdescription
string
User-friendly description of the permission nodenote
string | null
Additional user-friendly information about the permission nodegroup
string | null
A group/category title that can be used to group permissions together
Your current primary account e-mail address
id
string
The ID of the e-mail addressaddress
string | null
Your primary e-mail address. May ben null if anonymised.verified
boolean
Whether this e-mail address has been verified
An isolated group of servers
id
string
The ID of the projectname
string
Project nameuser
string
ID of the user that owns this project
A request
id
string
The ID of the requestmethod
string
The request method (e.g. GET, POST, HEAD, etc.scheme
"http" | "https"
The URL schemehost
string
The requested host nameurl
string
The request URL pathstatus
number
The HTTP status code that was returned to this requestip
string
The IP address of the client that made the request (can be both IPv4 and IPv6)date
Date
The time when the request was receivedresponseTime
number
The time in milliseconds that the request took to processhasEvents
boolean
Whether any server-side error events occurred while processing this requestrequestHeaders
Record<string, string> | null
The request headers that were receivedrequestBody
string | null
The request body that was received (likely parsed and formatted as JSON)responseHeaders
Record<string, string> | null
The headers that were returned by the serverresponseBody
{type: "Buffer", data: number[]} | null
The response body that was returned by the server in response to this request
Overview of a request
id
string
The ID of the requestmethod
string
The request method (e.g. GET, POST, HEAD, etc.scheme
"http" | "https"
The URL schemehost
string
The requested host nameurl
string
The request URL pathstatus
number
The HTTP status code that was returned to this requestip
string
The IP address of the client that made the request (can be both IPv4 and IPv6)date
Date
The time when the request was receivedresponseTime
number
The time in milliseconds that the request took to processhasEvents
boolean
Whether any server-side error events occurred while processing this request
An authentication token
id
string
The ID or key of the tokencreated
Date
Date and time when this token was createdexpires
Date | null
Date and time when this token expires. Null if it never expires.permissions
string[]
Permission scopes that this token holdsinternal
string | undefined
Whether this token is for internal use only, e.g. to power a session. In other words, an internal token is one that was not created by the client.metadata
Cloudnode.TokenMetadata
Additional metadata about this token
Token metadata