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 🙏

© 2026 – Pkg Stats / Ryan Hefner

strapi-client

v1.0.0

Published

An http client to easily access Strapi.io API.

Readme

strapi-client

An http client to easily access Strapi.io API.



Usage


Create an instance

const StrapiClient = require('strapi-client')
const strapi = new StrapiClient('http://localhost:1337')

Login to the API

login(identifier, password)

const { jwt, user } = await strapi.login('uname', 'pword')
console.log('Token:', jwt)
console.log('User:', user)

If the login succeeds, the token will automatically be applied to the Authorization header.


Get currently authenticated user

currentUser(token)

const user = await strapi.currentUser()

token is optional. If a user has recently logged in, the token is automatically applied to the Authorization header.

Persistence of the token should be managed by the developer. To reauthenticate a user, just pass the token to the currentUser() method.

const user = await strapi.currentUser('efghijk1234567...')

Register an account

register(data)

let newUser = {
  email: '[email protected]',
  username: 'uname',
  password: 'pword'
}

const { jwt, user } = strapi.register(newUser)

console.log('Token:', jwt)
console.log('User:', user)

Count the entries of a content-type

count(contentType, query)

const numberOfUsers = await strapi.count('users')

query is optional. It accepts an object that is passed as HTTP params along with the GET request. See Strapi's documentation about Parameters.


Create an entry

create(contentType, data)

const article = await strapi.create('articles', {
  title: 'Welcome to Strapi Client!',
  content: 'Strapi-client helps us do CRUD easily.'
})

Returns the created entry.


Get a list or a specific entry

get(contentType, id | query)

// Get a specific user
const user = await strapi.get('users', 2)

// Get a list of users
const users = await strapi.get('users')

query is optional. See the definition of this argument above. If a number is passed instead of an object, the method will return an object containing the entry of the given ID. Otherwise, will return an array of entries of the content-type.


Update an entry

update(contentType, id, updatedData)

const updatedArticle = await strapi.update('articles', 12, {
  title: 'Strapi Client - CRUD made simple!'
})

Returns the updated entry.


Delete an entry

delete(contentType, id)

const deletedArticle = await strapi.delete('articles', 12)

Returns the deleted entry.



Note:

  • All method returns a Promise.reject if a server or connectivity issue occurs.
  • If the api fails to perform a request, it will return an object containing the error information.


TODO:

  • Improve the documentation.
  • Add other necessary methods.
  • Find support and contributions. :P