@wral/sdk-tag
v0.5.1
Published
A Software Development Kit for working with Studio Tags
Downloads
63
Keywords
Readme
sdk-tag
The sdk-tag
is a JavaScript SDK (Software Development Kit) designed to interact with
an API that generates and validates JWTs.
Installation
You can install the `sdk-tag
npm install @wral/sdk-tag
Usage
To use the sdk-tag
, you first need to import it into your JavaScript or TypeScript project:
import { createClient } from '@wral/sdk-tag';
Then, you can create a client instance with your configuration:
const config = {
baseUrl: 'YOUR_BASE_URL', // Base URL of your API
};
const client = createClient(config);
After creating the client instance, you can use its methods to interact with the API. Here are some examples:
// List tags related to weather
let tags = await client.listTags({ query: 'weather' });
let result = await client.attachTag(tags[0].id, { url: 'https://www.wral.com/weather/' });
API
createClient(config)
Creates a new client instance with the provided configuration.
config
: An object containing API configuration parameters:baseUrl
: The base URL of the API.
Returns a client instance with methods for interacting with the API.
Methods
api: (path, options = {})
: fetch wrapper for the API.listTags({ query, uri } = {})
: list tags by substring of name or a URIputTag(tag)
: create a taggetTag(tagId)
: read a tagdeleteTag(tagId)
: delete a tagattachTag(tagId, resource)
: attach a tag to a resourcedetachTag(tagId, { url })
: detach a tag from a resourcequery({ uri, query } = {})
: query tagged resourcegetTagByName(name)
: get a tag by slugified name