JS Library

Get Started

Add the following code snippet to your JS file

import shapir from "https://shapir.org/shapir.js";

shapir().then(async () => {
	//add your functions here
});

Functions

The following are the functions supported by the Shapir library

Search a website

To search a website, you will need to use the [site].search() function. The search function take one positional parameter whih is the search parameteter and all the other parameters should be specified as an object of keyword arguments

var videos = await youtube.search("Taylot Swift", {'order': 'date'});

Get an object by its ID

To get informaiton about a specific object on agiven website, you need to specify the site, type of the object, and pass its id [site].[type]("[id]")

var video = await youtube.VideoObject("x7xf8kc");
// Get video properties
video.name
video.description
...
await video.comment //this returns a list of comments by calling another API endpoint (we need to prefix it with await)

// Update video properties
video.name = "New Name"
...

Apply methods to objects

// Get the object first then apply the method on it
var video = await youtube.VideoObject("x7xf8kc");
await video.like()

Remove an object

// Get the object first then delete it
var video = await youtube.VideoObject("x7xf8kc");
await video.delete();

Create a new object

await youtube.MusicPlaylist.create({'name':'name playlits', 'description': 'yes it is new!'});

Explore Websites

Choose a website to know what functions are supported by



Examples

Get YouTube video comments

This sample gets the list of comments that belongs to a YouTube video, specified by the videoId.

import shapir from "https://shapir.org/shapir.js";
shapir().then(async () => {

	var video = await youtube.VideoObject("x7xf8kc"); // videoId= x7xf8kc
	var comments = await video.comment //returns a list of comments for this specific

});
Search Seatgeek for music venues

This sample searches Seatgeek for music venues in Boston, USA and for each venue it will show the name, url, and the list of its events.

import shapir from "https://shapir.org/shapir.js";
shapir().then(async () => {

	var venues = await seatgeek.search("Music", {"city":"Boston", "country":"US"})

	for(let v in venues){
		console.log(venues[v].name)
		console.log(venues[v].url)
		console.log(await venues[v].event) //returns a list of events for the venue
	}

});
Update my collection of images in Unsplash

Update the name and description of my image in Unsplash.

import shapir from "https://shapir.org/shapir.js";
shapir().then(async () => {

	var image = await unsplash.ImageObject("bXfQLglc81U"})
	image.name= "New Name"
	image.description= "New Description"

});
App Settings