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

repl-talk.js

v1.2.0

Published

An easy to use API to access data relating to users and posts on https://repl.it.

Downloads

4

Readme

Description

repl-talk.js allows you to interface with user and post related data from https://repl.it quick and easy. Please note that this is NOT and official API for https://repl.it. I will, however, try my best to keep this API running smooth, both for https://repl.it's servers and you.

Installing

Installing repl-talk.js is super easy! In your command line/terminal, write the following:

npm install repl-talk.js

After pressing the enter key and waiting for it to install, you are ready to use the package!

Getting Started

After we install repl-talk.js, we can start to use it. First, let's require it and create the client that we will use to access the API:

const replit = require("repl-talk.js");
const client = new replit.Client();

Now we have our client, we can use client.login(username, password, callback) to "login" to the API. While we aren't logging into the API services, we are making sure that you have a valid https://repl.it account. Without an account, you will not be able to use the API. So let's login:

client.login("ExampleAccountUsername", "ExampleAccountPassword", data => {
    // Next lot of code will go here
});

I feel that it is important to say a few things. The account username and password, along with any other data you may use is not recorded in anyway by the API. However, your account's id is sent with the request header, so that https://repl.it knows who has sent the request. We do this to ensure that any API abuse can be caught and handled by the professionals at https://repl.it. Apart from this, your account is only used to verify that you are registered with https://repl.it.

If you wish, you may get the data which the query to log you in returns. This can give you more information than if you were to simply query you username or id.

Calls

Let's look at an example call:

client.user(username, callback [, items])

As of the latest update, there are no longer a client.users and client.posts. It has been simplified down to the new names found below.

Callbacks

The callback for every function will return data, which will contain the data for the query. These callbacks look like this:

client.user("ExampleUsername",  data => {
    // Callback code here
});

Items

Items allow you to select what you want to be returned by the API. You may only need some data, not all of it. Not only does this make the JSON easier to use, but it also makes the requests faster to complete. Here is how you would do this:

client.user("ExampleUsername",  data => {
    // Callback code here
}, ["id", "username", "karma"]);

The different things you can put in this array are the same as the ones listed below each call. The default items for each query will now only get useful data, you can still get any data you want as normal, or use a constant below to get it all.

Queries

client.user(id, callback [, items])

This is the most basic way to get the details of a user. By using their id, we ensure that we will be getting the right user very time.

~~client.username~~: No longer exists as client.user can take both usernames (as strings) or ids (as integers).

  • username
  • firstName
  • lastName
  • bio
  • isVerified
  • displayName
  • fullName
  • url
  • isLoggedIn
  • isSubscribed
  • karma

client.repl(id, callback [, items])

This will get a repl based on its id. This will look like a UUID (if your id is not working, try removing the two letters at the front).

  • id
  • language
  • isPrivate
  • isStarred.
  • title
  • description
  • folderId
  • isRenamed
  • languageDisplayName
  • timeCreated
  • timeUpdated
  • pinnedToProfile
  • files
  • hostedUrl
  • terminalUrl

client.enterprise(id, callback [, items])

This will get the data for the enterprise with the given id.

  • id
  • startDate
  • endDate
  • teacherSeats
  • studentSeats

client.organization(id, callback [, items])

This will get the data for the organisation with the given id.

  • id
  • name
  • country
  • postalCide
  • state
  • city
  • googlePlaceId
  • timeCreated
  • timeUpdated
  • timeDeleted

client.post(id, callback [, items])

This will get the data for the post with the given id.

  • id
  • title
  • body
  • voteCount
  • commentCount
  • isPinned
  • isLocked
  • timeCreated
  • timeUpdated
  • url
  • isAnnouncement
  • isAnswered
  • isAnswerable
  • preview

client.board(id, callback [, items])

This will get the data for the board with the given id.

  • id.
  • name
  • description
  • titleCta
  • bodyCta
  • replRequired
  • timeCreated
  • timeUpdated
  • url

client.comment(id, callback [, items])

This will get the data for the comment with the given id.

  • id
  • body
  • voteCount
  • timeCreated
  • timeUpdated
  • url
  • isAnswer
  • preview

client.query(use, callback)

This one is for advanced users only, who how the Schema for the GraphQL API which https://repl.it uses. To use this, you will need to parse in an Object with the following details:

client.query({
    "from": "user",
    "using": {"id": 1},
    "get": ["id", "username", "karma"]
}, data => {});

Items

client.roles([items])

This will return a string to be put in the items of client.user:

  • id
  • key
  • name
  • tagline

client.languages([items])

This will return a string to be put in the items of client.user:

  • id
  • displayName
  • key
  • category
  • tagline
  • icon
  • isNew

client.posts([items])

This will return a string to be put in the items of client.user, :

  • id
  • title
  • body
  • voteCount
  • commentCount
  • isPinned
  • isLocked
  • timeCreated
  • timeUpdated
  • url
  • isAnnouncement
  • isAnswered
  • isAnswerable
  • preview

client.comments([items])

This will return a string to be put in the items of client.user:

  • id
  • body
  • voteCount
  • timeCreated
  • timeUpdated
  • url
  • isAnswer
  • preview

client.from(use)

This will return a string to be used in the valid queries items. This is for advanced users, and will most likely be used in conjunction with manual queries. Once again, you will need prior knowledge of the GraphQL API to use this one effectively. You will have to parse in an Object with the following details:

client.from({
    "from": "roles",
    "get": ["id", "name", "tagline"]
});

Constants

client.board(id, callback [, items])

Along with client.board comes constants which defines the different board ids. These include:

  • client.ASK
  • ~~client.SHARE~~ (I'm still not aware of the id for this board)
  • client.ANNOUNCEMENTS
  • client.CHALLENGE
  • client.LEARN

All

Each query comes with a constant that can be used in its items argument. This will allow you to get all the data from a query. Here are these constants:

  • client.ALL_FROM_USER
  • client.ALL_FROM_REPL
  • client.ALL_FROM_ENTERPRISE
  • client.ALL_FROM_ORGANIZATION
  • client.ALL_FROM_POST
  • client.ALL_FROM_BOARD
  • client.ALL_FROM_COMMENT
  • client.ALL_FROM_ROLE
  • client.ALL_FROM_LANGUAGE

Errors

The error system is still not amazing, however, it does now log the errors to the console for you. You'll know now when there is an error with your query as there will be a message starting with:

> repl-talk.js error: ...

This will give you some insight into what went wrong so it is easier to fix.