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

@buffedapi/sdk

v1.0.4

Published

Object-Oriented SDK wrapper for the BuffedAPI

Downloads

4

Readme

Buffed API SDK - Javascript

This is the Javascript SDK. You can use this in a node web-server to access the API and manage data and logic for your application.

The application could be a web-app being served by the node application, or it could be some other (android app, desktop game etc) that is using your node app as it's main server.

We do not recommend distributing the Application-Token with instances of your application for security reasons. Better to keep that server-side and program your application to access the server with user credentials (email and password), keeping the Application-Token safely in the server environment.

Installation

Just run:

npm install @buffedapi/sdk

And then import it

const buffedApi = require("@buffedapi/sdk");

And you're ready to go.

Quick-Start guide

The SDK is simple to use. First create a buffed session, supplying Application-Token and ApplicationId if applicable, then login.

CREATE

let buffedSession = new buffedApi.BuffedSession('3298743984234','Ap89efd98yfdv983iuh23');
await buffedSession.login(email,password);

you would obtain these credentials from your user. If this is the first time a user is signing up, you'll want to create an account instead, like so:

let newAccount = new buffedApi.BuffedAccount({username:"NewUser", email:"[email protected]", password:"mypassword"})
await newAccount.save(buffedSession);

Whenever you make a call to the API you will have to supply the buffedSession object. This is because you may have multiple users running multiple sessions simultaneously.

Account creation uses the Application-Token so doesn't matter at this point if a user is not signed in. Or you could do something like this:

let buffedSession = new buffedApi.BuffedSession('3298743984234','Ap89efd98yfdv983iuh23');
let newAccount = new buffedApi.BuffedAccount({username:"NewUser", email:"[email protected]", password:"mypassword"})
await newAccount.saveAndLogin(buffedSession);

Then you can go on to do things like:

let newTeam = new buffedApi.BuffedTeam({name:"Team Name"})
await newTeam.save(buffedSession)

And this will automatically create the team using the token for the user who is logged in with this session.

await buffedSession.adminLogin("[email protected]","securepassword");
let app = new buffedApi.BuffedApplication({name:"Test App"});
await app.save(buffedSession);

Would be a way to create a new application, using the credentials you have from signing up at Buffed API.

READ

You can fetch or fetch_all on most objects:

let applications = await buffedApi.BuffedApplication.fetch_all(buffedSession);
let team = await buffedApi.BuffedTeam.fetch(buffedSession,"f72ac89192b9d81282e9");

UPDATE

You can update existing objects using the save method as well (if it has an object id it will update instead of creating new)

team.name = "New team name";
await team.save(buffedSession);

DELETE

Just call the delete method, and it will delete the resource on the API:

await team.delete(buffedSession);

Further reading

For more information, please visit the Buffed API Docs.