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

@formbricks/api

v1.9.0

Published

Formbricks-api is an api wrapper for the Formbricks client API

Downloads

7,442

Readme

@formbricks/api - API Wrapper for Formbricks

This is the official API wrapper for Formbricks. It is used to interact with the Formbricks API. To know more about Formbricks, visit Formbricks.com.

The direct API documentation can be found in our official docs here. To interact with the Formbricks API, you need to have an environment ID. You can get it from the Formbricks dashboard at app.formbricks.com.

Installation

npm install @formbricks/api

Usage

Init

import { FormbricksAPI } from "@formbricks/api";

const api = new FormbricksAPI({
  apiHost: `https://app.formbricks.com`, // If you have self-hosted Formbricks, change this to your self hosted instance's URL
  environmentId: "<environment-id>", // Replace this with your Formbricks environment ID
});

The API client is now ready to be used across your project. It can be used to interact with the following models:

Display

  • Create a Display

    await api.client.display.create({
      surveyId: "<your-survey-id>", // required
      userId: "<your-user-id>", // optional
      responseId: "<your-response-id>", // optional
    });

Response

  • Create a Response

    await api.client.response.create({
      surveyId: "<your-survey-id>", // required
      finished: boolean, // required
      data: {
        questionId: "<answer-to-this-question-in-string>",
        anotherQuestionId: 123, // answer to this question in number
        yetAnotherQuestionId: ["option1", "option2"], // answer to this question in array,
      }, // required
    
      userId: "<your-user-id>", // optional
      singleUseId: "<your-single-use-id>", // optional
      ttc: {
        questionId: 123, // optional
      }, // optional
      meta: {
        source: "<your-source>", // optional
        url: "<your-url>", // optional
        userAgent: {
          browser: "<your-browser>", // optional
          device: "<your-device>", // optional
          os: "<your-os>", // optional
        },
        country: "<your-country>", // optional
      }, // optional
    });
  • Update a Response

    await api.client.response.update({
      responseId: "<your-response-id>", // required
      finished: boolean, // required
      data: {
        questionId: "<answer-to-this-question-in-string>",
        anotherQuestionId: 123, // answer to this question in number
        yetAnotherQuestionId: ["option1", "option2"], // answer to this question in array,
      }, // required
      ttc: {
        questionId: 123, // optional
      }, // optional
    });

Action

  • Create an Action

    await api.client.action.create({
      name: "<your-action-name>", // required
      properties: {
        key1: "value1",
        key2: "value2",
        key3AsNumber: 123,
      }, // required
    
      personId: "<your-person-id>", // optional
      sessionId: "<your-session-id>", // optional
    });

People

  • Create a Person

    await api.client.people.create({
      userId: "<your-user-id>", // required
    });
  • Update a Person

    await api.client.people.update(personId: "<your-person-id>", // required
    {
      attributes: {
        key1: "value1",
        key2: "value2",
        key3AsNumber: 456,
      }, // required
    }

Storage

  • Upload a file

    await api.client.storage.uploadFile(
      file: File, // required (of interface File of the browser's File API)
      {
        allowedFileTypes: ["file-type-allowed", "for-example", "image/jpeg"], // optional
        surveyId: "<your-survey-id>", // optional
    
      } // optional
    );

If you have any questions or need help, feel free to reach out to us on our Discord