🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

optimade

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optimade

Aggregating Optimade client for the online materials databases

1.1.4
Source
npm
Version published
Weekly downloads
14
-17.65%
Maintainers
2
Weekly downloads
 
Created
Source

Aggregating Optimade client for the online materials databases

NPM version NPM downloads

Features

  • discover all the official Optimade databases recursively
  • cache the discovered list (prefetched.json) for future and boost the retrieval performance
  • query them all, in the browser, at the server, everywhere

Install

npm i optimade --save
yarn add optimade

CDN: UNPKG | jsDelivr (available as window.optimade)

If you are not using es6 or CDN, add to your HTML just before closing the body tag:

<script src="/path/to/optimade/dist/index.js"></script>
<!-- OR -->
<script type="module" src="/path/to/optimade/dist/index.mjs"></script>

Usage


const optimadeClient = new Optimade({
    providersUrl: '/path/to/optimade/providers.json'
});

console.log(optimadeClient.providers); // { [id: string]: Provider }[]

const providersMap = await optimadeClient.getProviders(); // { [id: string]: Provider }[]

const providerIds = Object.keys(providersMap); // string[]

const results = await optimadeClient.getStructuresAll(providerIds, YOUR_OPTIMADE_QUERY); // [Structures[], Provider][]

Importing depends on your environment. See also the examples folder. The .html examples are suited for the browser environment, the .js examples are suited for the server environment.

The code is generally isomorphic, however one should additionally take care of downloading the cache or setting the CORS policy for the browsers. Concerning the CORS, the Optimade class constructor accepts the corsProxyUrl parameter, pointing to e.g. a running cors-anywhere proxy instance. This will be valid until all the Optimade providers are supplying the header Access-Control-Allow-Origin $http_origin in their responses. For the server-side environment this is not required.

License

MIT © PaulMaly, Tilde Materials Informatics

FAQs

Package last updated on 15 May 2021

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