Movida API Client
JavaScript/TypeScript client library for Bebanjo's Movida API
Installation
npm install @bbcstudios/movida-client
Usage
import { MovidaApi } from '@bbcstudios/movida-client'
const client = MovidaApi.create({
baseUrl: 'https://staging-movida.bebanjo.net/api',
username: 'my_username',
password: 'my_password',
})
// Fetch a single resource
const results = await client.getTitleById(123)
// Expand related resources
const results = await client.getTitleById(123, { expand: ['metadata'] })
// Fetch a paginated list of resources
const results = await client.getTitles({ page: 2, perPage: 50 })
Typings
The package includes TypeScript definitions for core data types returned by the API. Some types such as metadata and
publication payloads have a dynamic schema which is configured by Bebanjo per account. By default these are returned as
a permissive Record
type, but this can be specified using type parameters on the relevant methods e.g.
interface CustomMetadata {
appleId: string
}
const results = await client.getTitleMetadata<CustomMetadata>(123)
Raw HTTP access
You can also use the HttpClient
class for direct access to raw XML request/responses, while still handling
authentication and rate limiting.
import { HttpClient } from '@bbcstudios/movida-client'
const client = new HttpClient({
baseUrl: 'https://staging-movida.bebanjo.net/api',
username: 'my_username',
password: 'my_password',
})
const httpResponse = await client.get('/titles/123')