https://github.com/citrineinformatics/public_search
Public Search Helper Methods
https://github.com/citrineinformatics/public_search
Last synced: about 1 year ago
JSON representation
Public Search Helper Methods
- Host: GitHub
- URL: https://github.com/citrineinformatics/public_search
- Owner: CitrineInformatics
- License: apache-2.0
- Created: 2018-01-23T01:39:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T10:23:28.000Z (over 3 years ago)
- Last Synced: 2024-04-11T15:43:17.647Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 604 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Public Search API Interface
This lib contains very specific wrappers around Citrination's public API.
In specific, it consists of 3 exposed methods.
See source code on [github](https://github.com/CitrineInformatics/public_search)
### General Usage
`npm install citrine-public-search`
`yarn add citrine-public-search`
Then just reference the package, `require('citrine-public-search')`.
The returned object literal will have the 3 methods described below
bound to it.
### Results Page
```javascript
const citrinePublicSearch = require('citrine-public-search')
const userInput = ;
const = citrinePublicSearch.getResultsPageData(userInput);
```
###### UserRequestObject
The UserRequestObject is an array of Input objects
See src/models/input on github for Input definitions.
An example of this object can be found in examples/resultsPage
###### Result
See models/result for implementation details. The `data` key corresponds to an
arbitrary object, which changes depending on endpoint.
An example of the `data` field of `Result` for the ResultsPage request can be found in examples/resultsPage/response
###### Suggested Results
In addition to the main page results, I also provide a suggestedInput array for the links at the bottom of the mockups.
The link should make a request to `getResultsPageData` with the provided `suggestedInput` and the only argument. Upon receipt, the page should update with the new values.
### Dataset Page
```javascript
const citrinePublicSearch = require('citrine-public-search')
const datasetId = ;
const = citrinePublicSearch.getDatasetPageData(datasetId);
```
###### DatasetId
The ID of the dataset you are requesting, as a `number` primitive
###### Result
See models/result for implementation details. The `data` key corresponds to an
arbitrary object, which changes depending on endpoint.
An example of the `data` field of `Result` for the DatasetPage request can be found in examples/datasetPage/response
### Material Page
```javascript
const citrinePublicSearch = require('citrine-public-search')
const chemicalFormula = ;
const = citrinePublicSearch.getMaterialPageData(datasetId);
```
###### ChemicalFormula
Just a `string` that represents a Chemical Formula. See examples/materialPage/request*.json for examples
###### Result
See models/result for implementation details. The `data` key corresponds to an
arbitrary object, which changes depending on endpoint.
An example of the `data` field of `Result` for the MaterialPage request can be found in examples/materialPage/response*.json
Note that, depending on the material you are searching for, you may not get back certain values. For example, `request.json` doesn't return dois, imageUrls, or processDefinitions, while `request2.json` doesn't return any table data (unlikely but can occur) or composition. Be prepared to handle disparate data cases, but expect top level keys to always be served consistently.