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

samcart-api

v1.0.1

Published

A typescript/javascript api for connecting to SamCart.

Downloads

2

Readme

Easy, Quick and "It just Works"

Its 2022, and programming the internet just got easier. If you read further you'll find out how to "just make it happen".

The Story

I get it, you were just accepted into the beta program for SamCart's api, and you want to integrate the api immediately. That's my story, and after one beer and a few minutes of "tap tap tap" I am in business, all typed and scripted, and ready to go.

But you don't have to worry about doing any of that "tap tap tap" to get the api up and going. Why?

This SamCart api WORKS

I know how fast the internet moves. I promise that I can't promise anything. But I do promise that this currently works, and its very easy to update it. I don't have any testimonials, other than I just went "wooo it works!" and then wrote this README. That, in my humble opinion, should be good enough to prove it works.

The Offer

Look this is an amazing deal.

  • I do all the foundational work and provide an api that is "holy goodness" easy to maintain and maybe you help maintain it from time to time. At least if it breaks...
  • I provide this free of charge (because its GPLv3), maybe you'll decide other people's freedom is just as valuable as your own and not try to lock others out.
  • You just do a simple "npm install samcart-api", and you say "Hey, this Mike guy is pretty cool"

Do We have a deal?

If so, just follow along with the instructions... I promise, it'll be painfree.

Installation instructions

npm install samcart-api

That's it!

How To use it.

I am not going to go into full depth of SamCart's api. It is available on their website. Click Here

Overall this is how it works

  • You create a new Configuration() object using your apiKey.
  • You create an instance of the part of the api that you want to use, passing in your new handy dandy configuration.
  • You call the functions that are available on that api.

That's it.

Example (non es6)

const { Configuration, ProductsApi } = require('samcart-api')

const configuration = new Configuration({ apiKey: "insert-your-api-key-here"})
const productsApi = new ProductsApi(configuration)
await productsApi.getProducts()
    .then(axiosResponse => {
      return axiosResponse.data
    })
    .then(console.log)

This example prints off all of the products in your account. Cool right!

Example ES6

import { Configuration, ProductsApi } from 'samcart-api'

const configuration = new Configuration({ apiKey: "insert-your-api-key-here"})
const productsApi = new ProductsApi(configuration)
await productsApi.getProducts()
    .then(axiosResponse => {
      return axiosResponse.data
    })
    .then(console.log)

Everything works the same, except that its ES6 syntax.

Building from scratch

So I have what should be every command to generate this Api from scratch. If you do...

npm run build

It will pull down the latest api spec, generate bindings, and then put them in the dist folder for javascript and typescript users alike.

If you do...

npm run dist

It'll do everything the build does, plus push it to npm.

For the future...

You may be shocked by the devDependencies. These are provided (free of charge), for the motivator who is interested in creating unit tests and BDD tests to ensure that the api works as expected... (or proving samcart changed everything up and wrecked everyone). I like these tools, I use them. Maybe you might too.