Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@umbraco/headless-client

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@umbraco/headless-client

Node.js client library for the Umbraco Headless APIs

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
736
decreased by-18.94%
Maintainers
4
Weekly downloads
 
Created
Source

Umbraco.Headless.Client.NodeJs

Node.js client library for the Umbraco Headless APIs

Install

> npm install @umbraco/headless-client

Usage

Create a client, then call commands on it


// client.ts
import {Client} from '@umbraco/headless-client'

const client = new Client({
  projectAlias: 'headless-house-of-code',
  language: 'en-US'
})

client.setAPIKey(`FF00FF1133FF==`)
export default client

// rootLinks.ts
async function rootLinks(client: Client) {
  const rootContent = await client.delivery.content.root()

  const childPages = rootContent.map(child => ({
    url: child._url,
    name: child.name
  }))

  return childPages
}

function linkGenerator(links: {url: string, name: string}[]) {
  return links.map(link => {
    return `<a href="${link.url}">${link.name}</a>`
  })
}

async function main() {
  const rootLinks = await rootLinks(require('./client').default)
  const links = linkGenerator(rootLinks)
  console.log(links)
}

Available clients

All client calls will return an instance of ApiRequest class.

For fetching content the promise method must be called example below:

client.delivery.content.root()
  .then(response => {
    console.log(response)
  })

Content Delivery

Content

client.delivery.content.root()
client.delivery.content.byId(id: string)
client.delivery.content.byUrl(url: string)
client.delivery.content.children(url: string)
client.delivery.content.ancestors(id: string)
client.delivery.content.descendants(id: string)

// TS Example:
import {ContentResponseElement} from '@umbraco/headless-client'

client.delivery.content.root<T extends ContentResponseElement>(): ApiRequest<T>

Media

client.delivery.media.root()
client.delivery.media.byId(id: string)
client.delivery.media.children(id: string)

Content Management

Content
client.management.content.root()
client.management.content.byId(id: string)
client.management.content.children(id: string)
client.management.content.create(body: CreateContentBody)
client.management.content.publish(id: string)
client.management.content.unPublish(id: string)
client.management.content.update(id: string, body: ContentResponseElement)
client.management.content.delete(id: string)
Content Type
client.management.contentType.all()
client.management.contentType.byAlias(alias: string)
Media
client.management.media.root()
client.management.media.byId(id: string)
client.management.media.children(id: string)
client.management.media.create(body: any)
client.management.media.update(id: string, body: any)
client.management.media.delete(id: string)
Media Type
client.management.mediaType.all()
client.management.mediaType.byAlias()
Language
client.management.language.all()
client.management.language.byISOCode(isoCode: string)
client.management.language.create(data: CreateContentLanguageType)
client.management.language.update(isoCode: string, data: CreateContentLanguageType)
client.management.language.delete(isoCode: string)
Relation
client.management.relation.byId(id: string)
client.management.relation.byAlias(alias: string)
client.management.relation.byChild(id: string)
client.management.relation.byParent(id: string)
client.management.relation.create(data: any)
client.management.relation.delete(id: string)
Relation Type
client.management.relationType.byAlias(alias: string)
Member
client.management.member.byUsername(username: string)
client.management.member.create(data: ContentCreateMemberType)
client.management.member.update(username: string, data: ContentCreateMemberType)
client.management.member.addGroup(username: string, groupName: string)
client.management.member.removeGroup(username: string, groupName: string)
client.management.member.delete(username: string)
Member Group
client.management.memberGroup.byName(name: string)
client.management.memberGroup.create(data: ContentMemberCreateGroupType)
client.management.memberGroup.delete(name: string)
Member Type
client.management.memberType.all()
client.management.memberType.byAlias(alias: string)

Keywords

FAQs

Package last updated on 07 Nov 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc