Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@ttab/api-client

Package Overview
Dependencies
Maintainers
6
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ttab/api-client

Browser-friendly JavaScript client for TT Nyhetsbyrån public APIs.

Source
npmnpm
Version
0.8.0
Version published
Weekly downloads
139
40.4%
Maintainers
6
Weekly downloads
 
Created
Source

api-client

Browser-friendly JavaScript client for TT Nyhetsbyrån public APIs.

Version   License   Monthly downloads   Build Status

Content API

See the API documentation for more information.

const Api = require('@ttab/api-client')
const api = Api().token(process.env.TOKEN)

# searching
api.content('text').search({q: 'panda'}).then(function (res) {
  console.log(res)
}).catch(function (err) {
  console.error(err)
})

# streaming updates
var images = api.content('image').stream({q: 'panda'})
images.on('data', function (data) {
  console.log(data)
})
images.on('error', function (err) {
  console.error(err.message)
})
images.start()

# create a mobile notification
api.content('image').notification.mobile({
  title: 'my notification',
  q: 'panda'
}).then(function (res) {
  console.log('created notification', res.id)
})

# create an email notification
api.content('image').notification.email({
  title: 'my notification',
  q: 'panda',
  email: 'panda@example.com'
}).then(function (res) {
  console.log('created notification', res.id)
})

# list all notifications
api.content('_all').notification.list().then(function (res) {
  console.log('my notifications', res)
})

# delete a notification
api.content('_all').notification.delete(id)

# get user agreements
api.user.agreement().then(function (agrs) {
  console.log('my user agreements', agrs)
})

# get the user profile
api.user.profile(['editorial', 'user']).get().then(function (profile) {
  console.log(profile)
})

# update the user profile
api.user.profile(['editorial']).put({
  editorial: true,
})

# register a mobile device
api.user.device(token).register({
  type: 'ios-sandbox',
  model: 'iPhone X'
}.then(function () {
  console.log('registered!')
})

# unregister a mobile device
api.user.device(token).unregister().then(function () {
  console.log('unregistered!')
})

Keywords

api

FAQs

Package last updated on 04 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts