const ZeitApiClient = require("zeit-api-client")
const ZEIT_TOKEN = "your_zeit_now_token" // process.env.ZEIT_TOKEN
const zeitApi = new ZeitApiClient({token:ZEIT_TOKEN})
Get the authenticated user
Official Documentation: https://zeit.co/docs/api#endpoints/user
const user = zeitApi.getUser()
Create a new deployment with all the required and intended data.
Official Documentation: https://zeit.co/docs/api#endpoints/deployments/list-deployments
(Object)
Name | Description |
---|---|
data.name String
|
A string with the project name used in the deployment URL. The name string has a max length of 52 characters. |
data.files Array
|
A list of objects with the files to be deployed. |
data.version Number
|
The version of Now Platform to use. Must have the value of 2. |
data.meta Object
|
An object containing the deployment's metadata. Multiple key-value pairs can be attached to a deployment. For example, { "foo": "bar" }. |
data.env Object
|
An object containing the deployment's environment variable names and values. Secrets can be referenced by prefixing the value with @. |
data.builds Array
|
A list of Build objects used to build sources in a deployment. For example, { [{ "src": "*.php", "use": "@now/php" }] }. |
data.routes Array
|
A list of routes objects used to rewrite paths to point towards other internal or external paths. For example; [{ "src": "/docs", "dest": "https://docs.zeit.co" }] . |
data.regions Array
|
An array of the regions the deployment should be deployed to. For example, ["sfo", "bru"] . |
data.public Boolean
|
Whether a deployment's source and logs are available publicly. |
data.target String
|
Either not defined, staging or production. If staging, a staging alias in the format
|
data.alias Array
|
Aliases that will get assigned when the deployment is READY and the target is production. The client needs to make a GET request to this API to ensure the assignment. |
const deploymentData = {
"name": "my-instant-deployment",
"version": 2,
"files": [
{
"file": "index.html",
"data": "<!doctype html>\n<html>\n <head>\n <title>A simple deployment with the Now API!</title>\n </head>\n <body>\n <h1>Welcome to a simple static file</h1>\n <p>Deployed with <a href=\"https://zeit.co/docs/api\">ZEIT's Now API</a>!</p>\n </body>\n</html>"
}
]
}
const newDeployment = zeitApi.createDeployment(deploymentData)
Fetch all deployments
Official Documentation: https://zeit.co/docs/api#endpoints/deployments/list-deployments
(Object)
Name | Description |
---|---|
options.limit Number
|
Maximum number of deployments to list from a request. (default: 5, max: 100) |
options.from Timestamp
|
Get the deployment created after this Date timestamp. (default: current time) |
options.projectId String
|
Filter deployments from the given
projectId
|
options.meta-null String
|
[KEY]
Filter deployments by the given meta key value pairs. e.g.,
meta-githubDeployment=1
|
Fetch single deployment by id
Official Documentation: https://zeit.co/docs/api#endpoints/deployments/get-a-single-deployment
(String)
deployment id
Fetch a list of deployments files
Official Documentation: https://zeit.co/docs/api#endpoints/deployments/list-deployment-files
(String)
deployment id
Fetch a single file by deployment and file id
Official Documentation: https://zeit.co/docs/api#endpoints/deployments/list-deployment-files
(String)
deployment id
(any)
Delete a single deployment by id
Official Documentation: https://zeit.co/docs/api#endpoints/deployments/delete-a-deployment
(String)
deployment id
Get the logs of a deployment by its ID.
Official Documentation: https://zeit.co/docs/api#endpoints/logs
(String)
deployment id
Fetch all aliases
Official Documentation: https://zeit.co/docs/api#endpoints/aliases/list-all-the-aliases
Fetch a deployment's aliases
Official Documentation: https://zeit.co/docs/api#endpoints/aliases/list-aliases-by-deployment
(String)
Id of deployment to fetch aliases from
Fetch all secrets
Official Documentation: https://zeit.co/docs/api#endpoints/secrets/list-all-the-secrets
Fetch all teams
Official Documentation: https://zeit.co/docs/api#endpoints/teams/list-all-your-teams
Fetch all projects
Official Documentation: https://zeit.co/docs/api#endpoints/projects/get-all-projects