sharetribe-flex-sdk
Version:
Sharetribe SDK for JavaScript
82 lines (57 loc) • 2.18 kB
Markdown
Use Sharetribe Marketplace API with ease.
[](https://dl.circleci.com/status-badge/redirect/gh/sharetribe/flex-sdk-js/tree/master)
* [What is it?](
* [Installation](
* [Usage](
* [Examples](
* [Documentation](
* [License](
The SDK is the **easiest** way to interact with Sharetribe Marketplace API
and Asset Delivery API.
It handles **groundwork** such as authentication, renewing
authentication tokens and serializing and deserializing data to and from
JavaScript data structures.
This lets you to **concentrate on building your marketplace
front-end** instead of setting up the necessary boilerplate to
communicate with the API.
Yarn:
```sh
yarn add sharetribe-flex-sdk
```
```js
const sharetribeSdk = require('sharetribe-flex-sdk');
// Create new SDK instance
// To obtain a client ID, see Applications in Console
const sdk = sharetribeSdk.createInstance({
clientId: '<Your Client ID here>'
});
// Query first 5 listings
sdk.listings
.query({ perPage: 5 })
.then(res => {
// Print listing titles
res.data.data.forEach(listing => {
console.log(`Listing: ${listing.attributes.title}`)
});
})
.catch(res => {
// An error occurred
console.log(`Request failed with status: ${res.status} ${res.statusText}`);
});
```
Client ID is required to create a new SDK instance.
See [this article](https://www.sharetribe.com/docs/background/applications/)
to learn how to create an application and get the client ID.
See [examples/](https://github.com/sharetribe/flex-sdk-js/tree/master/examples/) directory in Github repository.
[](https://sharetribe.github.io/flex-sdk-js/).
See [CHANGELOG.md](https://github.com/sharetribe/flex-sdk-js/tree/master/CHANGELOG.md).
Distributed under [The Apache License, Version 2.0](https://github.com/sharetribe/flex-sdk-js/tree/master/LICENSE)