npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zeit-api-client

v0.1.5

Published

Api client for Zeit Now integrations based on @zeit/integration-utils

Downloads

2

Readme

zeit-api-client

NPM

API client for ZEIT Now and ZEIT Integrations

Related Links

Install

npm install --save zeit-api-client
# or 
yarn add zeit-api-client

Usage

Basic

const ZeitApiClient = require("zeit-api-client")
// import ZeitApiClient from "zeit-api-client"

const zeitApi = new ZeitApiClient({token:process.env.ZEIT_TOKEN})
const latestDeployments = await zeitApi.getDeployments({limit:5})
console.log(latestDeployments[0])

Within an integration

const { withUiHook, htm } = require("@zeit/integration-utils");
const ZeitApiClient  = require("zeit-api-client")
module.exports = withUiHook(async ({ payload, zeitClient }) => {
  const zeitApi = new ZeitApiClient({token:payload.token})
  const latestDeployments = await zeitApi.getDeployments()
  return htm`
    <Page>
      <H1>Latest Deployments</H1>
      <Code>
        ${JSON.stringify(latestDeployments, null, 2)}
      </Code>
    </Page>
  `;
});

Documentation

View Documentation

ZeitApiClient

Parameters

Examples

const ZeitApiClient = require("zeit-api-client")
const ZEIT_TOKEN = "your_zeit_now_token" // process.env.ZEIT_TOKEN
const zeitApi = new ZeitApiClient({token:ZEIT_TOKEN})

getUser

Get the authenticated user

Official Documentation: https://zeit.co/docs/api#endpoints/user

Examples

const user = zeitApi.getUser()

createDeployment

Create a new deployment with all the required and intended data.

Official Documentation: https://zeit.co/docs/api#endpoints/deployments/list-deployments

Parameters

  • data Object
    • 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 ..now.sh will be assigned. If production, any aliases defined in alias will be assigned.
    • 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.

Examples

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&apos;s Now API</a>!</p>\n    </body>\n</html>"
    }
  ]
}
const newDeployment = zeitApi.createDeployment(deploymentData)

uploadFile

Uploads a file and returns its size and sha if successful (currently only works in node). Returned object can be used with createDeployment() files section

Official Documentation: https://zeit.co/docs/api#endpoints/deployments/upload-deployment-files

Parameters

  • options Object
    • options.filePath String Path pf file to upload

Returns Object fileData

Returns String fileData.sha sha1 hash of uploaded file

Returns String fileData.size size in bytes of uploaded file

getDeployments

Fetch all deployments

Official Documentation: https://zeit.co/docs/api#endpoints/deployments/list-deployments

Parameters

  • options Object
    • 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

getDeployment

Fetch single deployment by id

Official Documentation: https://zeit.co/docs/api#endpoints/deployments/get-a-single-deployment

Parameters

  • deploymentId String deployment id

getDeploymentFiles

Fetch a list of deployments files

Official Documentation: https://zeit.co/docs/api#endpoints/deployments/list-deployment-files

Parameters

  • deploymentId String deployment id

getDeploymentFile

Fetch a single file by deployment and file id

Official Documentation: https://zeit.co/docs/api#endpoints/deployments/list-deployment-files

Parameters

  • deploymentId String deployment id
  • fileId

deleteDeployment

Delete a single deployment by id

Official Documentation: https://zeit.co/docs/api#endpoints/deployments/delete-a-deployment

Parameters

  • deploymentId String deployment id

getLogs

Get the logs of a deployment by its ID.

Official Documentation: https://zeit.co/docs/api#endpoints/logs

Parameters

  • deploymentId String deployment id

getAliases

Fetch all aliases

Official Documentation: https://zeit.co/docs/api#endpoints/aliases/list-all-the-aliases

Parameters

  • options Object
    • options.limit Number Maximum number of aliases to list from a request. (default: 5, max: 100)
    • options.from Timestamp Get the aliases created after this Date timestamp. (default: current time)
    • options.projectId String Filter aliases from the given projectId

getDeploymentAliases

Fetch a deployment's aliases

Official Documentation: https://zeit.co/docs/api#endpoints/aliases/list-aliases-by-deployment

Parameters

  • deploymentId String Id of deployment to fetch aliases from

getSecrets

Fetch all secrets

Official Documentation: https://zeit.co/docs/api#endpoints/secrets/list-all-the-secrets

getTeams

Fetch all teams

Official Documentation: https://zeit.co/docs/api#endpoints/teams/list-all-your-teams

getProjects

Fetch all projects

Official Documentation: https://zeit.co/docs/api#endpoints/projects/get-all-projects

Parameters

  • options Object
    • options.limit Number Limit the number of projects returned
    • options.from Timestamp The updatedAt point where the list should start.
    • options.search String Search projects by the name field.

getDomains

Fetch all domains

Official Documentation: https://zeit.co/docs/api#endpoints/domains/list-all-the-domains

Parameters

  • options

getCertificates

Fetch all certificates

Official Documentation: https://zeit.co/docs/api#endpoints/certificates/list-all-the-certificates

Parameters

  • options

getWebhooks

Fetch all webhooks

Official Documentation: https://zeit.co/docs/api#endpoints/webhooks/list-all-webhooks

License

MIT © Luka Kakia