Mavo + Shapir
To be ble to connect to Web APIs using Mavo, you will need to add the following attributes to the mv-app
div:
(1) Mavo uses mv-source
to specify the source of the data. So the First thing you need to specify is mv-source="shapir"
.
(2) You will also need to specify the websites ot services that you are retrieving the data from, by using mv-source-service
<head>
...
<script rel="stylesheet" src="https://get.mavo.io/mavo.css"></script>
<script src="https://get.mavo.io/mavo.j"></script>
<script type="module" src="https://shapir.org/mavo-shapir.js"></script>
...
</head>
<body>
<div mv-app="main" mv-source="shapir" mv-source-service="websites names" >
<!-- add your Mavo code here -->
</div>
</body>
If you are intersted in getting an information about a specific object on the web, for example an infomraiton about a video on YouTube or an image on Unsplash, then you can use the following attributes in mv-app div
In addition to using mv-source= "shapir"
and mv-source-service
, you will need to use two additional attributes: mv-source-type
to specify the type of data you want to get (e.g. VideoObject or an ImageObject), and (2) mv-source-id
to specify the id of the object your are getting.
Example
<div mv-app="main" mv-source="shapir" mv-source-service="unsplash" mv-source-type="ImageObject" mv-source-id="DmXLY8TK3OU"></div>
If you are interested in searching a website, for example searching YouTube for videos, then you can use the following attributesmv-app
div
In addition to using mv-source= "shapir"
and mv-source-service
, you will need to use mv-source-search="keywords..."
to specify the term or keywords you are searching for. search
is not the only filter or parameter you can use, some Web APIs offer more parameters (e.g. sort, location, etc). These parameters are specified by each website, please go to the Explore section and choose the website you are intersted in to know more about what other parameters a given website supports.
Example
<div mv-app="main" mv-source="shapir" mv-source-service="dailymotion" mv-source-search="Taylor Swift" mv-source-sort="recent" ></div>
As mentioned in the previous section, whne you search a website, you can use a number of parameters specified by that website to filter the results. For example, you can search etsy using mv-source-search
, and you can also filter the returned results by minimum price mv-source-min_price
and mv-source-max_price
. How did I know this? Go to Explore Sites and choose etsy. You do the same whenever you want to know what sites accept as parameters.
To specify the number of results returned by a search, you add mv-source-numResults
to the mv-app div.
Example
<div mv-app="main" mv-source="shapir" mv-source-service="dailymotion" mv-source-search="Taylor Swift" mv-source-numResults="50"></div>
If you would like to search multiple sites at the same time, you can add multiple sites seperated by comma in mv-source-service
like the following example. Make sure to add sites that return similar data. Otherwise you will not be getting meaningful data.
Example
<div mv-app="main" mv-source="shapir" mv-source-service="youtube, dailymotion" mv-source-search="Taylor Swift" mv-source-sort="recent" mv-source-order="date" ></div>
Get an image information from Unsplash
<div mv-app="main" mv-source="shapir" mv-source-service="unsplash" mv-source-type="ImageObject" mv-source-id="DmXLY8TK3OU">
<h3 property="description"></h3>
<p property="dateModified"></p>
<p property="datePublished" ></p>
<p property="contentRating" ></p>
<p property="url"></p>
<p property="width"></p>
<p property="height"></p>
<p property="contentUrl"></p>
</div>
Search Etsy for products
<div mv-app="main" mv-source="shapir" mv-source-service="etsy" mv-source-search="[search]">
<form mv-action="set(search, searchInput)">
<label>Search: <input property="searchInput" /></label>
<meta property="search" mv-default="Jacket">
<button>Submit</button>
</form>
<p property="name"></p>
<p property="description"></p>
<p property="weight"></p>
<p property="width"></p>
<p property="height"></p>
<p property="productionDate"></p>
<p property="url"></p>
<p property="aggregateRating"></p>
</div>
Search Yelp and Foursquare for seafood resturants and their reviews
Only show the ones that has rating > 4
<div mv-app="main" mv-source="shapir" mv-source-service="yelp, foursquare" mv-source-search="seafood">
<div property="resturant" mv-multiple hidden="[aggregateRating > 4]">
<h3 property="name"></h3>
<p property="aggregateRating"></p>
<p property="priceRange" ></p>
<p property="longitude" ></p>
<p property="latitude"></p>
<p property="siteName"></p> <!-- "siteName" property is added to all the site to show which data came from which site -->
<div property="review" mv-multiple>
<p property="text"></p>
<p property="dateCreated"></p>
<p property="reviewRating" ></p>
</div>
</div>
</div>