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

ckan-ts

v1.1.0

Published

A fully tested TypeScript wrapper for CKAN API endpoints, designed to provide coherent vocabulary & outputs, regardless of implementation

Downloads

116

Readme

ckan-ts

ckan-ts is a fully tested and documented TypeScript wrapper for retrieving data from v3 CKAN APIs asynchronously. Its main aim is to provide parsed outputs using a coherent and consistent vocabulary across all resource types, and handle non-standard data provided by different organizations.

Usage

Install ckan-ts with npm i ckan-ts or yarn add ckan-ts.

Using ckan-ts is very simple. For instance, the following checks whether or not a site is functional, and retrieves its first 100 datasets if it is:

import CKAN from "ckan-ts";
const parser = new CKAN("https://demo.ckan.org/api/3/");
const isAvailable = await parser.available();
if(isAvailable){
	const datasets = await parser.datasets({limit: 100});
}

For the most part, ckan-ts is intended to retrieve data from unauthenticated endpoints. However, you can also pass it headers to use throughout, i.e.

const parser = new CKAN("https://demo.ckan.org/api/3/", {
	requestOptions: {
		headers: {} // the desired http headers go here
	}
});

Documentation

Full documentation

Currently supported methods:

Search:

  • .autocompleteDataset(query, limit): searches for a dataset, and returns its autocomplete results.
  • .autocompleteFormat(query, limit): searches for a file format, and returns its autocomplete results.
  • .autocompleteGroup(query, limit): searches for a group, and returns its autocomplete results.
  • .autocompleteOrganization(query, limit): searches for an organization, and returns its autocomplete results.
  • .autocompleteTag(query, limit): searches for a tag, and returns its autocomplete results.
  • .autocompleteUser(query, limit): searches for a user, and returns its autocomplete results
  • .searchDataset(query, options): searches for a given dataset with additional options, and returns its details.
  • .searchDatasetRawResult(query, options): searches for a given dataset with additional options, and returns the CKAN search output (including count).
  • .searchResource(query, options): searches for a given resource with additional options, and returns its detaisl.

Lists:

  • .datasets(settings?): returns the IDs of all datasets on the server.
  • .detailedDatasets(settings?): returns information about all datasets on the server, including their included resources.
  • .detailedGroups(settings?): returns information about all groups on the server.
  • .detailedOrganizations(settings?): returns information about all organizations on the server.
  • .detailedTags(settings?): returns information about all tags on the server.
  • .detailedUsers(settings?): returns a list of users on the server with detailed information.
  • .groups(settings?): returns the IDs of all groups on the server.
  • .licenses(): returns all the licenses used across datasets.
  • .organizations(settings?): returns the IDs of all organizations on the server.
  • .tags(settings?): returns the name of all tags on the server.
  • .users(settings?): returns a list of user IDs on the server.
  • .vocabularies(): returns a list of vocabularies on the server.

Single items:

  • .dataset(id): returns the metadata of a dataset with a given ID.
  • .group(id, settings?): returns information pertaining to a group.
  • .organization(id, settings?): returns information pertaining to an organization.
  • .resource(id): returns the metadata of a resource with a given ID.
  • .user(id): returns information about a given user.
  • .vocabulary(id): returns information about a given vocabulary.

Miscellaneous:

  • .action(action, data?, method?): carries out a generic action. Used in case it has not been implemented in the CKAN-TS yet.
  • .available(): checks whether an API endpoint is currently available.

For more information about these methods, check the documentation.

Full documentation

License

ckan-ts is released under the MIT license. For more information, see the LICENSE file.