1.0.60 • Published 12 months ago

archetype-node-v2 v1.0.60

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

Archetype Node Library

The Archetype Node library provides convenient access to the Archetype API from applications written in Node. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Archetype API.

The SDK has everything you need to build and manage API subscriptions, usage-based billing, tracking metered usage, issue volume based discounts, graduated pricing models and more.

About Archetype

Archetype is the revenue infrastruce that make API monetization quick and painless. It works by integrating powerful, reliable purchase server with cross-platform support. Our open-source framework provides a backend and a wrapper around payment processors like Stripe to save engineers months from having to build custom billing infrastructure for their APIs.

Whether you are building a new API or already have millions of customers, you can use Archetype to:

Sign up to get started.

Documentation

If looking to use our APIs directly, the API reference is here.

With Archetype, you can keep track of all your app transactions in one place — whether your customers are charged through iOS, Android, or the web. As the single source of truth for your API business, we make sure your customers' subscription status is always up to date.

Installation

Explore the docs and view the quickstart guide

You don't need this source code unless you want to modify the package. If you just want to use the package, just run:

yarn add @archetypeapi/node

or

npm install @archetypeapi/node

Requirements

Node 12.x.x+

Usage

The library needs to be configured with your account's app_id and secret key which is available in your Archetype Dashboard. Set archetype.app_id and archetype.secret_key to their values:

const express = require("express");
const router = express.Router();
const { ArchetypeApi } = require("@archetypeapi/node");

const appId = process.env.APP_ID; // find in your Archetype Dashboard
const secretKey = process.env.SECRET_KEY; // find in your Archetype Dashboard

const Archetype = ArchetypeApi(appId, appSecret);

// create customer

const customer = Archetype.Customer.create("CUSTOM_UID");

// list customers
const customers = Archetype.Customer.all()

// log the first customer's email
console.log(customers[0]["email"]);

// retrieve specific Customer
const customer = Archetype.Customer.retrieve("CUSTOM_UID");

// log that customer's email
console.log(customer["email"]);

// Track a Metered Usage

Archetype.BillableMetric.logUsage(
  "YOUR_CUSTOMER_ID",
  "BILLABLE_METRIC_ID",
  100 // amount (Float)
)

// Authorize an Express Request with Archetype Middelware
const express = require('express')
const { Auth } = require('@archetypeapi/node')
const app = express()

const appId = process.env.APP_ID; // find in your Archetype Dashboard
const secretKey = process.env.SECRET_KEY; // find in your Archetype Dashboard

const ArchetypeAuth = Auth(appId, appSecret);

app.get('/a', ArchetypeAuth, (req, res) => {
  res.send('Success!')
})

You can leverage the SDK to create and configure billable metrics, products, token management, authorization and more. Check out the docs for more examples and use cases.

1.0.60

12 months ago

1.0.59

12 months ago

1.0.58

12 months ago

1.0.57

12 months ago

1.0.56

12 months ago

1.0.55

12 months ago

1.0.54

12 months ago

1.0.53

12 months ago

1.0.52

12 months ago

1.0.51

12 months ago

1.0.50

12 months ago

1.0.49

12 months ago

1.0.48

12 months ago

1.0.47

12 months ago

1.0.46

12 months ago

1.0.45

12 months ago

1.0.44

12 months ago

1.0.43

12 months ago

1.0.42

12 months ago

1.0.41

12 months ago

1.0.40

12 months ago

1.0.39

12 months ago

1.0.38

12 months ago

1.0.37

12 months ago

1.0.36

12 months ago

1.0.35

12 months ago

1.0.34

12 months ago

1.0.33

12 months ago

1.0.32

12 months ago

1.0.31

12 months ago

1.0.30

12 months ago

1.0.29

12 months ago

1.0.28

12 months ago

1.0.27

12 months ago

1.0.26

12 months ago

1.0.25

12 months ago

1.0.24

12 months ago

1.0.23

12 months ago

1.0.22

12 months ago

1.0.21

12 months ago

1.0.20

12 months ago

1.0.19

12 months ago

1.0.18

12 months ago

1.0.17

12 months ago

1.0.16

12 months ago

1.0.15

12 months ago

1.0.14

12 months ago

1.0.13

12 months ago

1.0.12

12 months ago

1.0.11

12 months ago

1.0.10

12 months ago

1.0.9

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago