Skip to content

dominicpam89/chem-handler-api-v2

Repository files navigation

# Introduction

The purpose of creating this middleware app or API gateway is to streamline data from multiple API services. In the chem-handler-api-v2, the services included are:

  • Self-hosted service (main backend)
  • PubChem API

With this setup, the frontend application will be able to connect
to a single source to retrieve the required data.

# Self-hosted service (main backend)

Currently, the self-hosted service is not connected to a real backend. Instead, it is connected to a mock API that returns a response object of a Compound, structured as follows:

class Compound{ pk: number; trivial_name: string; cas_number: string; inci_name: string; smiles: string; comedogenicity_class: number; }

## Usage:

Get response list of all compounds

GET https://chem-handler-api-v2.vercel.app/compounds

Get Response one of compounds registered in mock API json

GET https://chem-handler-api-v2.vercel.app/compounds/:id

Example: GET https://chem-handler-api-v2.vercel.app/compounds/150

# PubChem Service (3rd Party Service)

This service primarily returns responses obtained from the request body to the PubChem database. It utilizes an interceptor to transform the original records into a more useful format.

## Usage:

### Search by CID:

### Get by CID full records POST https://chem-handler-api-v2.vercel.app/pubchem/cid Content-Type: application/json

{ "id": 12, "operationType": "fullRecords" }

Get response by CID filtered by property

POST https://chem-handler-api-v2.vercel.app/pubchem/cid Content-Type: application/json

{ "id": 1, "operationType": "property", "propertyName": "MolecularWeight" }

Get response by CID filtered by multiple properties

POST https://chem-handler-api-v2.vercel.app/pubchem/cid Content-Type: application/json

{ "id": 1, "operationType": "property", "propertyName": "MolecularWeight,MolecularFormula,HBondDonorCount" }

Get response by CID filtered only synonyms

POST https://chem-handler-api-v2.vercel.app/pubchem/cid Content-Type: application/json

{ "id": 1, "operationType": "synonyms" }

Get response by CID filtered only PNG

GET https://chem-handler-api-v2.vercel.app/pubchem/cid/3/image

### Search by Name:

### Get by name full records POST https://chem-handler-api-v2.vercel.app/pubchem/name Content-Type: application/json

{ "name": "glucose", "operationType": "fullRecords" }

Get response by name filtered by property

POST https://chem-handler-api-v2.vercel.app/pubchem/name Content-Type: application/json

{ "name": "glucose", "operationType": "property", "propertyName": "MolecularWeight" }

Get response by name filtered by multiple properties

POST https://chem-handler-api-v2.vercel.app/pubchem/name Content-Type: application/json

{ "name": "glucose", "operationType": "property", "propertyName": "MolecularWeight,MolecularFormula,HBondDonorCount" }

Get response by name filtered only synonyms

POST https://chem-handler-api-v2.vercel.app/pubchem/name Content-Type: application/json

{ "name": "glucose", "operationType": "synonyms" }

Get response by name filtered only PNG

GET https://chem-handler-api-v2.vercel.app/pubchem/name/glucose/image

### Search by Smiles:

### Get by name full records POST https://chem-handler-api-v2.vercel.app/pubchem/smiles Content-Type: application/json

{ "smiles": "CCCC", "operationType": "fullRecords" }

Get response by name filtered by property

POST https://chem-handler-api-v2.vercel.app/pubchem/smiles Content-Type: application/json

{ "smiles": "CCCC", "operationType": "property", "propertyName": "MolecularWeight" }

Get response by name filtered by multiple properties

POST https://chem-handler-api-v2.vercel.app/pubchem/smiles Content-Type: application/json

{ "smiles": "CCCC", "operationType": "property", "propertyName": "MolecularWeight,MolecularFormula,HBondDonorCount" }

Get response by name filtered only synonyms

POST https://chem-handler-api-v2.vercel.app/pubchem/smiles Content-Type: application/json

{ "smiles": "CCCC", "operationType": "synonyms" }

Get response by name filtered only PNG

GET https://chem-handler-api-v2.vercel.app/pubchem/smiles/CCCC/image

You can locate the folder at: src/pubchem/interceptors/pubchem-response.interceptor.ts
This file is primarily responsible for transforming the original records obtained from PubChem.

About

API Gateway for pubchem and compounds API service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published