npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@thomasravnholt/umbracoclient

v0.1.2

Published

A JavaScript client for interacting with the Umbraco Content Delivery API.

Downloads

40

Readme

What is UmbracoClient

UmbracoClient is a JavaScript package providing a convenient interface for interacting with the Umbraco Content Delivery API. It supports various operations such as fetching content by ID, name, route, content type, or multiple IDs, as well as media fetching capabilities. It also offers customizable query parameters for sorting, filtering, expanding, language selection, and more.

Installation

npm i @thomasravnholt/umbracoclient

Setup

Import createUmbracoClient from the package:

import { createUmbracoClient } from '@thomasravnholt/umbracoclient';

Create an instance of the client:

const umbracoClient = createUmbracoClient(
    'https://your-umbraco-domain.com',
    'your-optional-api-key'
);

Usage

Fetch Content by ID

umbracoClient.getContentById('content-id', options).then((data) => console.log(data));

Fetch Multiple Contents by IDs

umbracoClient.getContentByIds(['id1', 'id2'], options).then((data) => console.log(data));

Fetch Content by Name

umbracoClient.getContentByName('content-name', options).then((data) => console.log(data));

Fetch Content by Route

umbracoClient.getContentByRoute('content-route', options).then((data) => console.log(data));

Fetch Content by Type

umbracoClient.getContentByType('content-type', options).then((data) => console.log(data));

Fetch Media by ID

umbracoClient.getMediaById('media-id', options).then((data) => console.log(data));

Fetch Media by Path

umbracoClient.getMediaByPath('media-path', options).then((data) => console.log(data));

Fetch Media Items

umbracoClient.getMediaItems(options).then((data) => console.log(data));

Options

Customize requests using options:

  • sort: Define sorting order and type.
  • expand: Specify properties to expand in the response.
  • filter: Apply filters to the content or media.
  • language: Request content or media in a specific language.
  • preview: Fetch unpublished content or media (requires API key).
  • fetch: Options like 'ancestors', 'children', or 'descendants' for content.
  • fetchIdOrPath: ID or path for fetch operations.
  • skip: Number of items to skip (for pagination).
  • take: Number of items to take (for pagination).

Example

Fetch blog posts sorted by creation date in descending order:

const options = {
    sort: { type: 'createDate', order: 'desc' },
    expand: ['property1', 'property2'],
    filter: 'contentTypeAlias',
    language: 'en-US',
    preview: true,
    skip: 0,
    take: 10
};

umbracoClient.getContentByType('blogPost', options).then((data) => console.log(data));

Replace placeholders like 'your-umbraco-domain.com' and 'content-id' with actual values relevant to your Umbraco instance.