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

sdk-publish-test-01

v2.6.1

Published

OpenAPI client for timeside

Downloads

2

Readme

Timeside API SDK / client

Timeside API: https://github.com/Ircam-WAM/TimeSide

Features :

  • Typescript
  • Javascript
  • Node.js
  • Fetch API

Install

npm install --save @ircam/timeside-sdk

# If you need to polyfill Fetch (for Node / older browsers), you may use
npm install --save cross-fetch

API Docs

This SDK is generated from the OpenAPI Schema of available here.

Example

Initialize on Node

import crossFetch from 'cross-fetch'
import formDataNode from 'formdata-node'
import {
  TimesideApi,
  ServerSideConfiguration
} from '@ircam/timeside-sdk'

// Polyfill FormData because SDK use `new FormData` which is not available in Node.
// @ts-ignore
global.FormData = formDataNode

const api = new TimesideApi(ServerSideConfiguration({
  // Use sandbox endpoint
  basePath: 'https://sandbox.wasabi.telemeta.org',
  // Credentials (get from environment)
  username: process.env.TIMESIDE_API_USER,
  password: process.env.TIMESIDE_API_PASS,
  // Ponyfill fetchApi
  fetchApi: crossFetch
}))

Initialize on the browser

Initialize a raw client to make raw calls (login, refreshToken etc..).

import {
  TimesideApi,
  Configuration,
  AutoRefreshConfiguration,
  LocalStorageJWTToken,
  JWTToken
} from '@ircam/timeside-sdk'

const urlConfig = {
  basePath: 'https://sandbox.wasabi.telemeta.org'
}

// rawApi is the the api without jwt middlewares
// Use it for login or routes where you don't need authentication
const rawApi = new TimesideApi(new Configuration(urlConfig))

Init a persistent token to save it to browser's local storage. By default, the token is saved in the 'timeside-api-token' local storage's key. You can provide an string parameter to LocalStorageJWTToken constructor to change it.

// This helper saves the JWTToken to window.localStorage
// You may also implements your own way of storing your Token
// by implementing the PersistentJWTToken interface
const persistentToken = new LocalStorageJWTToken()

// Check if a token already exist and parse it
persistentToken.init()

// Configuration to auto-refresh access token when expired
const config = AutoRefreshConfiguration(urlConfig, persistentToken)
const api = new TimesideApi(new Configuration(config))

Login and save the JWT Token

async function login (username, password) {
  const tokenObtainPair = { username, password }
  const token = await rawApi.createTokenObtainPair({ tokenObtainPair })
  persistentToken.token = JWTToken.fromBase64(token.access, token.refresh)
}

Make some API calls (Browser or Node)


async function callApi () {
  // List items
  const items = await api.listItems({})
  console.log(items)
  const itemUuid = items[0].uuid

  // Get the item's Waveform
  const waveform = await api.retrieveItemWaveform({ uuid: itemUuid })
  console.log(waveform)

  // Create an item
  const item = {
    title: 'Unknown Song',
    description: 'Some great song!'
  }
  const item = await api.createItem({ body })
  console.log(item)

  // And get/create :
  // Annotations, Analysis, AnalysisResult,
  // Transcode, Visualization (like Spectrogram) etc..
  // ...
}

Integration examples

If you are looking for some implementation examples, here's a list of project that uses this SDK.

Timeside player (browser)

Timeside Player uses this SDK to provide a player from Timeside API. You may be interested in the src/utils/api.ts file

Timeside scripts (node)

Timeside Scripts host Node.JS scripts.

Authors