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

catalog-it

v0.0.2

Published

Tool to download Socrata data and keep revisions on S3

Downloads

3

Readme

Catalog It

Tool to download all datasets from a Socrata data portal and keep revisions on S3.

Specifically, Catalog It maintains a list of all "datasets" (this is a specific type on Socrata), looks for the last modified date from the dataset headers, and then uploads a copy of that data if it has changed.

Command line

Install: npm install catalog-it -g

Use catalog-it --help to show this help page.

  Usage: catalog-it [options] [command]


  Commands:

    update|u    Fetch the list of datasets.
    changed|c   Look at each dataset to see what has changed.
    data|d      Archive data that has changed.
    one|o <id>  Get one dataset; more useful for testing.

  Options:

    -h, --help                    output usage information
    -V, --version                 output the version number
    -c, --catalog <catalog>       The domain where the data catalog is location, for instance: "nycopendata.socrata.com"
    -b, --bucket <bucket>         S3 bucket
    -p, --profile [profile]       Name of the profile in .aws/credentials to use.  Overrides key options
    --access-key-id [key]         AWS access key to use.  It is suggest to use the AWS_ACCESS_KEY_ID instead
    --secret-access-key [key]     AWS secret key to use.  It is suggest to use the AWS_SECRET_ACCESS_KEY instead
    -a, --acl [acl]               ACL of items, defaults to "private"; should be "private", "public-read", "public-read-write", or "authenticated-read"
    -C, --concurrency [int]       Concurrency of fetching datasets and uploading to S3, defaults to 5
    -f, --format [format]         Format of data download, defaults to "csv"; should be "csv" or "json"
    -r, --prefix [path]           The path prefix for S3 items; for example: "backups/catalogs"
    -t, --timeout [milleseconds]  Timeout for uploads and downloads in milliseconds, defaults to 100000 (Socrata can be slow)
    -P, --path [path]             Path to directory where cache will live, defauls to "HOME/.catalog-it"
    -o, --config [path]           Path to environment variable file as defined by the "dotenv" module.
    --compress                    Compress with gzip when uploading to S3 (saves space); this is the default;
    --no-compress                 Do not compress with gzip when uploading to S3 (saves space).
    --bucket-create               Attempt to create the bucket on start; this is the default.
    --no-bucket-create            Do not attempt to create the bucket on start.

The command line will also look for environment variables and use those if they are not provided by the command line. Each environment variable should be prefixed with CATALOG_IT_. The command line will also try to read in an .env file if it exists, or the file provided by the --config option.

Module

Install: npm install catalog-it --save

Catalog It can also be used as a JS module. Simply include and use the same options as the command line except that the option properties are camelcase and the config option is not used.

const CatalogIt = require('catalog-it');
let c = new CatalogIt({
  catalog: 'something.catalog.com',
  bucket: 'my-s3.bucket',
  profile: 'default'
});

The module also supports using environment variables but will not read in any file.

Properties and methods

  • catalog: Current catalog in memory.
  • updateCatalog(function(error, catalog) { ... }): Gets new catalog and updates existing.
  • scanHeaders(function(errors, updates) { ... }): Gets info from headers to determine what needs changing. This function will skip network errors.
  • scanData(function(errors, updates) { ... }): Gets new data and archives to S3. This function will skip network errors.

Scheduling

Scheduling can happen however you like, but here is a cron example that runs once a week on Sunday at 2AM. This updates the list of datasets, determines which ones have changed, and then archives the data.

0 2 * * 0 catalog-it u && catalog-it c && catalog-it d;