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

the-one-sdk-sbm

v1.1.0

Published

Official SDK for "The one API"

Downloads

20

Readme

Lord of the Rings SDK

Getting started

Install

To install a SDK, simply run the following command

npm install the-one-sdk-sbm

Initializing

You need to set up an access token at: https://the-one-api.dev/account

You can use mine, but keep it a secret 🤫: SQb886IdnjD6GPZB3FsH

then import and initialize an instance of the SDK on your code:

import {TheOne} from 'the-one-sdk-sbm'

const TheOneSDK = new TheOne(access_token)

Examples

Getting a list of all movies

const page = 1
const result = await TheOneSDK.movies.list(page)
//You can iterate through all movies on the paginator or access the pagination information.
console.log(result.paginator.total) //print total results
console.log(result.paginator.pages) //print total pages
result.movies.forEach((movie) => console.log(movie.name)) //print all movie names

You can also filter the list by any attribute of the movie

const page = 1

const result = await TheOneSDK.movies.list(page,
    {
        attr: 'budgetInMillions',
        operator: '>=',
        value:'200'
    }, {
        attr: 'name',
        operator: 'contains',
        value: 'Lord'
    })

Getting a specific movie

const movieId = "5cd95395de30eff6ebccde5b"
const movie = await TheOneSDK.movies.get(movieId)
console.log(movie.name)

getting a list of quotes from a specific movie

const movieId = "5cd95395de30eff6ebccde5b"
const page = 1
const result = await TheOneSDK.movies.getQuotes(movieId, page)

console.log(result.paginator.total) //print total results
console.log(result.paginator.pages) //print total pages
result.quotes.forEach((quote) => console.log(quote.dialog)) //print all quotes

Getting a list of all quotes

const page = 1
const result = await TheOneSDK.quotes.list(page)
//the result structure is the same than when getting a list of quotes for a movie
console.log(result.paginator.total) //print total results
console.log(result.paginator.pages) //print total pages
result.quotes.forEach((quote) => console.log(quote.dialog)) //print all quotes

You can also filter the list by any attribute of the quote

const page = 1

const result = await TheOneSDK.quotes.list(page,
    {
        attr: 'dialog',
        operator: 'notContains',
        value:'Ring'
    })

Getting a specific quote

const quoteId = "5cd96e05de30eff6ebcce9ba"
const quote = await TheOneSDK.quotes.get(quoteId)
console.log(quote.dialog)

Types

Movie = {
    _id: string,
    name: string,
    runtimeInMinutes: number,
    budgetInMillions: number,
    boxOfficeRevenueInMillions: number,
    academyAwardNominations: number,
    academyAwardWins: number,
    rottenTomatoesScore: number,
}

MovieQuote = {
    _id: number,
    dialog: string,
    movie: string,
    character: string,
}

Paginator = {
    total: number,
    results: number,
    limit: number,
    offset: number,
    page: number,
    pages: number
}

MovieQuotePaginator = {
    quotes: MovieQuote[],
    paginator: Paginator
}

MoviePaginator = {
    movies: Movie[],
    paginator: Paginator
}

Filter = {
    attr: string,
    operator: '=' | '!=' | '<' | '<=' | '>' | '>=' | 'contains' | 'notContains'
    value: any
}