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

medaltv-wrapper

v3.0.4

Published

A simple Node.js wrapper for the Medal.tv Rest API

Downloads

17

Readme

Medal.tv Javascript API Wrapper

This wrapper utilizes Medal.tv's Developer API to return clips to your application!

NPM

Install via NPM

npm i medaltv-wrapper

How do I use this?

You can see below for all the functions. It's expected you know how to work JSON data and basic Javascript.
You will also need a Medal API Key in order to utilize this. Use a public one if this is a public app and visa versa.

See farther below for the format of returned objects.

searchClips - Search via a keyword

searchClips({
    apikey: `pub_xxxxxxxxxxxxxxxxxxxxxxx`,
    limit: '1',
    offset: '0',
    keyword: 'flip reset'
})
.then(clip => console.log(clip))

latestClips - Latest clips from a category or user

const { latestClips } = require('medaltv-wrapper');

latestClips({
    apikey: `pub_xxxxxxxxxxxxxxxxxxxxxxx`,
    limit: '1',
    offset: '0',
    categoryId: 'fortnite',
    userid: '215577'
})
.then(clip => console.log(clip))

trendingClips - Trending clips on the Medal.tv platform

const { trendingClips } = require('medaltv-wrapper');

trendingClips({
    apikey: `pub_xxxxxxxxxxxxxxxxxxxxxxx`,
    limit: '1',
    offset: '0',
    categoryId: `fortnite`
})
.then(clip => console.log(clip))

fetchCategories - Fetch Medal category data

fetchCategories({
    apikey: `pub_xxxxxxxxxxxxxxxxxxxxxxx`,
    categoryId: `minecraft`
})
.then(category => console.log(category))

FAQ

How do I find my user ID?

Medal has primarily transitioned to using usernames to referenced users, however unfortunately the public API is legacy at this point and doesn't support searching by username. However, you can still retrieve your user ID!

  • Open your profile on the web with Chrome's devtools network tab open
  • After it loads, filter the requests for "/api"
  • Look for a set of numbers -- this is your user ID. For example, mine is 215577

If you navigate to https://medal.tv/users/[id] and you're redirected to your profile, you did everything correctly!

What do returned objects look like?

Clip responses will be an array of clip objects. Clip objects look like this;

{
    "contentId": "cidxxxxxxxxx",
    "rawFileUrl": "not_authorized",
    "unbrandedFileUrl": "not_authorized",
    "contentTitle": "this is a sick clip!",
    "contentViews": 123,
    "contentLikes": 123,
    "contentThumbnail": "https://cdn.medal.tv/ugcc/content-thumbnail/xxxxx",
    "categoryId": 12, // categories can be found from /v1/categories
    "videoLengthSeconds": 14,
    "createdTimestamp": 1680399492000, // in ms
    "directClipUrl": "https://medal.tv/clip/id/id",
    "embedIframeCode": "<iframe ...></iframe>", // see more about iframe options on docs.medal.tv
    "credits": "Credits to alexav (https://medal.tv/users/215577)"
}

If you're querying for a category, you'll see this;

{
    "categoryId": 17,
    "categoryName": "Minecraft",
    "alternativeName": "Minecraft",
    "publishedClipCount": 4461683,
    "coverPhoto": "https://cdn.medal.tv/games/background/background-minecraft-17.png",
    "activeSessions": 14784,
    "slug": "minecraft",
    "isGame": true
}

I plan on cleaning this up a bit in a future update and updating the URLs/organizing content engagement info in the script.