@culturekit/culturekit-js
v0.1.50
Published
JavaScript client for CultureKit.
Downloads
1,216
Readme
culturekit-js
JavaScript client for CultureKit.
Usage
First of all, you need to install the package:
npm install @culturekit/culturekit-js
Then you'll be able to import the package and create a client:
import { createClient } from '@culturekit/culturekit-js';
// Creates a singleton CultureKit client which you can use to interact with CultureKit
const culturekit = createClient({
apiUrl: 'https://api.xyz.com',
});
UMD
You can use plain <script>
s to import culturekit-js from CDNs:
<script src="https://cdn.jsdelivr.net/npm/@culturekit/culturekit-js"></script>
or even:
<script src="https://unpkg.com/@culturekit/culturekit-js"></script>
Note: Please make sure to pin the used version to prevent breaking.
Then you can use it from a global culturekit
variable:
<script>
const { createClient } = culturekit;
const _culturekit = createClient({
apiUrl: 'https://api.xyz.com',
});
console.log('CultureKit Instance: ', _culturekit);
// ...
</script>
ESM
You can use type="module" <script>
s to import culturekit-js from CDNs:
<script type="module">
import { createClient } from 'https://cdn.jsdelivr.net/npm/@culturekit/culturekit-js/+esm';
const culturekit = createClient({
apiUrl: 'https://api.xyz.com',
});
console.log('CultureKit Instance: ', culturekit);
// ...
</script>
Note: Please make sure to pin the used version to prevent breaking.
General
Set locale (optional)
const locale = 'nl'; // ISO 639-1 string
culturekit.setLocale(locale);
Or alternatively, you can set the locale through query params.
const locale = 'nl'; // ISO 639-1 string
culturekit.schedule.productions.list({ locale });
Schedule
Productions
Retrieve a production
const { rawData, error } = await culturekit.schedule.productions.get(
'de21ad60-6b14-4432-b87e-8f728d5d7007'
);
console.log(rawData);
Retrieve productions list
const query = {};
const { rawData, error, previous, next } =
await culturekit.schedule.productions.list(query);
console.log(rawData);
Events
Retrieve an event
const { rawData, error } = await culturekit.schedule.events.get(
'de21ad60-6b14-4432-b87e-8f728d5d7007'
);
console.log(rawData);
Retrieve events list
const query = {};
const { rawData, error, previous, next } =
await culturekit.schedule.events.list(query);
console.log(rawData);
Venues
Retrieve a venue
const { rawData, error } = await culturekit.schedule.venues.get(
'de21ad60-6b14-4432-b87e-8f728d5d7007'
);
console.log(rawData);
Retrieve venues list
const query = {};
const { rawData, error, previous, next } =
await culturekit.schedule.venues.list(query);
console.log(rawData);