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

matlabcentral

v1.0.7

Published

Use this library to manage requests to MATLAB Central aka MathWorks Community API from your Node.js applications.

Downloads

219

Readme

MATLAB Central Node.js SDK

The toolbox provides easy to use functions that simplify the process of making requests to the MATLAB Central (MathWorks® Community) APIs. Whether you are using the APIs for data-analysis/reporting or for building custom Node.js apps, the library provides for a smooth integration.

Requirements

Use of the MATLAB Central Node.js SDK requires:

  • Node.js 14 or higher

This SDK supports Node.js versions that are either current, or in long-term support status (LTS). The SDK does not end-of-life (EOL) Node.js versions. For more information on Node.js versioning, see https://nodejs.org/en/about/previous-releases.

This SDK is for use with Node.js only. It does not support other usages, such as for web browsers or frontend applications.

Installation

You can quickly install the MATLAB Central Node.js SDK as follows:

npm install matlabcentral

Quick Usage

To create a Node.js application using the matlabcentral SDK, do the following:

  1. Open a new terminal window. Create a new directory for your project and then go to that directory. Alternatively, you could copy the gettingStarted directory inside /examples and proceed to Step 6.
mkdir gettingStarted
cd ./gettingStarted
  1. Use the npm command to create a project definition file (package.json).
npm init

Answer the questions required. You could also take a look at the package.json inside the /examples/gettingStarted directory for help answering any of the questions.

  1. Install the MATLAB Central SDK package.
npm install matlabcentral
  1. Make sure the package.json that was created has following line, if not include it

"type": "module"

This is required as the SDK only supports ESM imports.

  1. In your project directory, create a file named gettingStarted.js with the following content:

import MATLABCentral from 'matlabcentral';

async function executeSearch() {
  try {
    let searchApi = new MATLABCentral.SearchApi();
    let opts = {
        "query": "plotting",
        "scope": "matlab-answers,file-exchange"
    }
    let searchResponse = await searchApi.search(opts);
    console.log("Search API called successfully");
    console.log(searchResponse);
  } catch (e) {
    // e contains two fields:
    // e.reason: which is an instance of ApiError which is the formatted JSON with low-level details about the error
    // e.error: which is the unformatted error with access to the stack trace, request object, response body, headers and so on
    console.log(e.reason);
    console.log(e.error); 
  }
};

executeSearch();

Save the gettingStarted.js file.

  1. Run the script created with the following command
node gettingStarted.js

The above code creates a new instance of the SearchAPI object using the MATLAB Central SDK and calls the search method.

If the request is successful, the code prints 'Search API called successfully.' along with the result items found, on the terminal.

Tests

First, clone this repo locally and cd into the cloned directory.

Next, install dependencies and run tests.

npm install
npm test

SDK Reference

Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- SearchApi | search | GET /v1/search | Search MATLAB Central areas for content matching specified query

Search

The Search collection offers a single method called search which offers a powerful way to programmatically search MATLAB Central.

If you are looking to get data from different MATLAB Central areas like MATLAB Answers, File Exchange, Cody, Community Highlights, Community Contests and Blogs with a single call, this would be the function to use. The function also supports many optional parameters that allow you to further filter the data returned, including limiting the scope to specific MATLAB Central areas.

Contribution

We are excited to hear any feedback you have for us and welcome contributions in the form of issues.

License

The license is available in the License file within this repository.

© 2023 The MathWorks, Inc.