Giter VIP home page Giter VIP logo

ncbi-entrez-api's Introduction

Introduction

The NCBI Entrez API is a powerful resource for scientists, researchers, and engineers. The api allows consistent access patterns to over 40 databases. This module is a wrapper that allows calls to be made to the NCBI Entrez API.

Install

npm install ncbi-entrez-api

Quick ES6 example

import {DB, dbFactory} from 'ncbi-entrez-api'

let gene = dbFactory(DB.GENE) //DB.GENE is the mapping for 'gene'
gene.einfo({ format: 'json' }, function(err, response, data) {
	console.log(data)
})

Quick CommonJS example

var NcbiApi = require('ncbi-entrez-api')

var gene = NcbiApi.dbFactory(NcbiApi.DB.GENE)
gene.einfo({ format: 'json' }, function(err, response, data) {
	console.log(data)
})

Streaming

We use request - which provides both callback and streaming style api calls.

import fs from 'fs'
import {DB, dbFactory} from 'ncbi-entrez-api'

let gene = dbFactory(DB.GENE)
gene.info({ format: 'json'}).pipe(fs.createWriteStream('myFile.json'))

All methods

var NcbiApi = require('ncbi-entrez-api')

//Constants mapping to available databases
//console.log to see your options
console.log(NcbiApi.DB)


//Create an instance of a db fetcher
var gene = NcbiApi.dbFactory(NcbiApi.DB.GENE)


//Call any of the following endpoints
//options - Required for each endpoint
//callback - optional. Without a callback will receive a stream
gene.einfo(options, callback)
gene.epost(options, callback)
gene.elink(options, callback)
gene.espell(options, callback)
gene.esearch(options, callback)
gene.esummary(options, callback)
gene.efetch(options, callback)

API Options

For a list of all api specific options, see http://www.ncbi.nlm.nih.gov/books/NBK25499/

Returning JSON

einfo, esummary, and efetch are the only 3 endpoints that currently return JSON. The rest return XML by default.

options = {retmode: 'json'}

Examples

var NcbiApi = require('ncbi-entrez-api')

var protein = NcbiApi.dbFactory(NcbiApi.DB.PROTEIN)
var callback = function(err, response, data) {
	console.log(data)
}

protein.einfo({
	retmode: 'json'
}, callback)

protein.epost({
	ids: ['id_1', 'id_2']
}, callback)

protein.elink({
	dbFrom: 'homologene',
	ids: ['id_1', 'id_2']
}, callback)

protein.espell({
	term: 'organism[homo]'
}, callback)

protein.esearch({
	term: 'organism[homo]',
	retmode: 'json'
}, callback)

protein.esummary({
	ids: ['id_1', 'id_2'],
	retmode: 'json'
}, callback)

protein.efetch({
	ids: ['id_1', 'id_2'],
	rettype: 'fasta',
	retmode: 'text'
}, callback)

efetch

efetch pulls down full records in various formats. Each database supports different data formats.

Use options.retmode and options.rettype to control the format.

See more options here.

ncbi-entrez-api's People

Contributors

csenn avatar tsaidavid avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.