Categorygithub.com/lborcard/ncbi-api-go
repositorypackage
0.0.0-20240921071441-4cf13d170a11
Repository: https://github.com/lborcard/ncbi-api-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Go API client for openapi

NCBI Datasets is a resource that lets you easily gather data from NCBI.

The Datasets version 2 API is still in alpha, and we're updating it often to add new functionality, iron out bugs and enhance usability. For some larger downloads, you may want to download a dehydrated zip archive, and retrieve the individual data files at a later time.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: v2alpha
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/GIT_USER_ID/GIT_REPO_ID"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://api.ncbi.nlm.nih.gov/datasets/v2alpha

ClassMethodHTTP requestDescription
BioSampleApiBioSampleDatasetReportGet /biosample/accession/{accessions}/biosample_reportGet BioSample dataset reports by accession(s)
GeneApiDownloadGenePackageGet /gene/id/{gene_ids}/downloadGet a gene dataset by gene ID
GeneApiDownloadGenePackagePostPost /gene/downloadGet a gene dataset by POST
GeneApiGeneChromosomeSummaryGet /gene/taxon/{taxon}/annotation/{annotation_name}/chromosome_summaryGet summary of chromosomes for a particular taxon's annotation
GeneApiGeneCountsForTaxonGet /gene/taxon/{taxon}/countsGet gene counts by taxonomic identifier
GeneApiGeneCountsForTaxonByPostPost /gene/taxon/countsGet gene counts by taxonomic identifier
GeneApiGeneDownloadSummaryByIdGet /gene/id/{gene_ids}/download_summaryGet gene download summary by GeneID
GeneApiGeneDownloadSummaryByPostPost /gene/download_summaryGet gene download summary
GeneApiGeneLinksByIdGet /gene/id/{gene_ids}/linksGet gene links by gene ID
GeneApiGeneLinksByIdByPostPost /gene/linksGet gene links by gene ID
GeneApiGeneMetadataByAccessionGet /gene/accession/{accessions}Get gene metadata by RefSeq Accession
GeneApiGeneMetadataByPostPost /geneGet gene metadata as JSON
GeneApiGeneMetadataByTaxAndSymbolGet /gene/symbol/{symbols}/taxon/{taxon}Get gene metadata by gene symbol
GeneApiGeneOrthologsByIdGet /gene/id/{gene_id}/orthologsGet gene orthologs by gene ID
GeneApiGeneOrthologsByPostPost /gene/orthologsGet gene orthologs by gene ID
GeneApiGeneReportsByIdGet /gene/id/{gene_ids}Get gene reports by GeneID
GeneApiGeneReportsByTaxonGet /gene/taxon/{taxon}Get gene reports by taxonomic identifier
GenomeApiAnnotationReportFacetsGet /genome/accession/{accession}/id/{annotation_ids}/annotation_summaryGet genome annotation report summary information
GenomeApiAnnotationReportFacetsByPostPost /genome/annotation_summaryGet genome annotation report summary information
GenomeApiAssemblyAccessionsForSequenceAccessionGet /genome/sequence_accession/{accession}/sequence_assembliesGet assembly accessions for a sequence accession
GenomeApiAssemblyAccessionsForSequenceAccessionByPostPost /genome/sequence_assembliesGet assembly accessions for a sequence accession
GenomeApiAssemblyRevisionHistoryByGetGet /genome/accession/{accession}/revision_historyGet revision history for assembly by accession
GenomeApiAssemblyRevisionHistoryByPostPost /genome/revision_historyGet revision history for assembly by accession
GenomeApiCheckAssemblyAvailabilityGet /genome/accession/{accessions}/checkCheck the validity of genome accessions
GenomeApiCheckAssemblyAvailabilityPostPost /genome/checkCheck the validity of many genome accessions in a single request
GenomeApiCheckmHistogramByTaxonGet /genome/taxon/{species_taxon}/checkm_histogramGet CheckM histogram by species taxon
GenomeApiCheckmHistogramByTaxonByPostPost /genome/checkm_histogramGet CheckM histogram by species taxon
GenomeApiDownloadAssemblyPackageGet /genome/accession/{accessions}/downloadGet a genome dataset by accession
GenomeApiDownloadAssemblyPackagePostPost /genome/downloadGet a genome dataset by post
GenomeApiDownloadGenomeAnnotationPackageGet /genome/accession/{accession}/annotation_report/downloadGet an annotation report dataset by accession
GenomeApiDownloadGenomeAnnotationPackageByPostPost /genome/annotation_report/downloadGet an annotation report dataset by accession
GenomeApiGenomeAnnotationDownloadSummaryGet /genome/accession/{accession}/annotation_report/download_summaryPreview feature dataset download
GenomeApiGenomeAnnotationDownloadSummaryByPostPost /genome/annotation_report/download_summaryPreview feature download by POST
GenomeApiGenomeAnnotationReportGet /genome/accession/{accession}/annotation_reportGet genome annotation reports by genome accession
GenomeApiGenomeAnnotationReportByPostPost /genome/annotation_reportGet genome annotation reports by genome accession
GenomeApiGenomeDatasetReportGet /genome/accession/{accessions}/dataset_reportGet dataset reports by accessions
GenomeApiGenomeDatasetReportByPostPost /genome/dataset_reportGet dataset reports by accessions
GenomeApiGenomeDatasetReportsByAssemblyNameGet /genome/assembly_name/{assembly_names}/dataset_reportGet dataset reports by assembly name (exact)
GenomeApiGenomeDatasetReportsByBioprojectGet /genome/bioproject/{bioprojects}/dataset_reportGet dataset reports by bioproject
GenomeApiGenomeDatasetReportsByBiosampleIdGet /genome/biosample/{biosample_ids}/dataset_reportGet dataset reports by biosample id
GenomeApiGenomeDatasetReportsByTaxonGet /genome/taxon/{taxons}/dataset_reportGet dataset reports by taxons
GenomeApiGenomeDatasetReportsByWgsGet /genome/wgs/{wgs_accessions}/dataset_reportGet dataset reports by wgs accession
GenomeApiGenomeDownloadSummaryGet /genome/accession/{accessions}/download_summaryPreview genome dataset download
GenomeApiGenomeDownloadSummaryByPostPost /genome/download_summaryPreview genome dataset download by POST
GenomeApiGenomeLinksByAccessionGet /genome/accession/{accessions}/linksGet assembly links by accessions
GenomeApiGenomeLinksByAccessionByPostPost /genome/linksGet assembly links by accessions
GenomeApiGenomeSequenceReportGet /genome/accession/{accession}/sequence_reportsGet sequence reports by accessions
GenomeApiGenomeSequenceReportByPostPost /genome/sequence_reportsGet sequence reports by accessions
OrganelleApiDownloadOrganellePackageGet /organelle/accession/{accessions}/downloadGet a organelle data package by accesions
OrganelleApiDownloadOrganellePackageByPostPost /organelle/downloadGet a organelle data package by post
OrganelleApiOrganelleDatareportByAccessionGet /organelle/accessions/{accessions}/dataset_reportGet Organelle dataset report by accession
OrganelleApiOrganelleDatareportByPostPost /organelle/dataset_reportGet Organelle dataset report by http post
OrganelleApiOrganelleDatareportByTaxonGet /organelle/taxon/{taxons}/dataset_reportGet Organelle dataset report by taxons
ProkaryoteApiDownloadProkaryoteGenePackageGet /protein/accession/{accessions}/downloadGet a prokaryote gene dataset by RefSeq protein accession
ProkaryoteApiDownloadProkaryoteGenePackagePostPost /protein/accession/downloadGet a prokaryote gene dataset by RefSeq protein accession by POST
TaxonomyApiDownloadTaxonomyPackageGet /taxonomy/taxon/{tax_ids}/downloadGet a taxonomy data package by tax ID
TaxonomyApiDownloadTaxonomyPackageByPostPost /taxonomy/downloadGet a taxonomy data package by tax_id
TaxonomyApiTaxNameQueryGet /taxonomy/taxon_suggest/{taxon_query}Get a list of taxonomy names and IDs given a partial taxonomic name
TaxonomyApiTaxNameQueryByPostPost /taxonomy/taxon_suggestGet a list of taxonomy names and IDs given a partial taxonomic name
TaxonomyApiTaxonomyDataReportGet /taxonomy/taxon/{taxons}/dataset_reportUse taxonomic identifiers to get taxonomic data report
TaxonomyApiTaxonomyDataReportPostPost /taxonomy/dataset_reportUse taxonomic identifiers to get taxonomic names data report by post
TaxonomyApiTaxonomyFilteredSubtreeGet /taxonomy/taxon/{taxons}/filtered_subtreeUse taxonomic identifiers to get a filtered taxonomic subtree
TaxonomyApiTaxonomyFilteredSubtreePostPost /taxonomy/filtered_subtreeUse taxonomic identifiers to get a filtered taxonomic subtree by post
TaxonomyApiTaxonomyImageGet /taxonomy/taxon/{taxon}/imageRetrieve image associated with a taxonomic identifier
TaxonomyApiTaxonomyImageMetadataGet /taxonomy/taxon/{taxon}/image/metadataRetrieve image metadata associated with a taxonomic identifier
TaxonomyApiTaxonomyImageMetadataPostPost /taxonomy/image/metadataRetrieve image metadata associated with a taxonomic identifier by post
TaxonomyApiTaxonomyImagePostPost /taxonomy/imageRetrieve image associated with a taxonomic identifier by post
TaxonomyApiTaxonomyLinksGet /taxonomy/taxon/{taxon}/linksRetrieve external links associated with a taxonomic identifier.
TaxonomyApiTaxonomyLinksByPostPost /taxonomy/linksRetrieve external links associated with a taxonomic identifier.
TaxonomyApiTaxonomyMetadataGet /taxonomy/taxon/{taxons}Use taxonomic identifiers to get taxonomic metadata
TaxonomyApiTaxonomyMetadataPostPost /taxonomyUse taxonomic identifiers to get taxonomic metadata by post
TaxonomyApiTaxonomyNamesGet /taxonomy/taxon/{taxons}/name_reportUse taxonomic identifiers to get taxonomic names data report
TaxonomyApiTaxonomyNamesPostPost /taxonomy/name_reportUse taxonomic identifiers to get taxonomic names data report by post
TaxonomyApiTaxonomyRelatedIdsGet /taxonomy/taxon/{tax_id}/related_idsUse taxonomic identifier to get related taxonomic identifiers, such as children
TaxonomyApiTaxonomyRelatedIdsPostPost /taxonomy/related_idsUse taxonomic identifier to get related taxonomic identifiers, such as children
VersionApiVersionGet /versionRetrieve service version
VirusApiSars2ProteinDownloadGet /virus/taxon/sars2/protein/{proteins}/downloadDownload SARS-CoV-2 protein and CDS datasets by protein name
VirusApiSars2ProteinDownloadPostPost /virus/taxon/sars2/protein/downloadDownload SARS-CoV-2 protein and CDS datasets by protein name by POST request
VirusApiSars2ProteinSummaryGet /virus/taxon/sars2/protein/{proteins}Summary of SARS-CoV-2 protein and CDS datasets by protein name
VirusApiSars2ProteinSummaryByPostPost /virus/taxon/sars2/proteinSummary of SARS-CoV-2 protein and CDS datasets by protein name
VirusApiSars2ProteinTableGet /virus/taxon/sars2/protein/{proteins}/tableGet SARS-CoV-2 protein metadata in a tabular format.
VirusApiVirusAccessionAvailabilityGet /virus/accession/{accessions}/checkCheck available viruses by accession
VirusApiVirusAccessionAvailabilityPostPost /virus/checkCheck available viruses by accession
VirusApiVirusAnnotationReportsByAcessionsGet /virus/accession/{accessions}/annotation_reportGet virus annotation report by accession
VirusApiVirusAnnotationReportsByPostPost /virus/annotation_reportGet virus annotation report by POST
VirusApiVirusAnnotationReportsByTaxonGet /virus/taxon/{taxon}/annotation_reportGet virus annotation report by taxon
VirusApiVirusGenomeDownloadGet /virus/taxon/{taxon}/genome/downloadDownload a virus genome dataset by taxon
VirusApiVirusGenomeDownloadAccessionGet /virus/accession/{accessions}/genome/downloadDownload a virus genome dataset by accession
VirusApiVirusGenomeDownloadPostPost /virus/genome/downloadGet a virus genome dataset by post
VirusApiVirusGenomeSummaryGet /virus/taxon/{taxon}/genomeGet summary data for virus genomes by taxon
VirusApiVirusGenomeSummaryByPostPost /virus/genomeGet summary data for virus genomes by post
VirusApiVirusGenomeTableGet /virus/taxon/{taxon}/genome/tableGet virus genome metadata in a tabular format.
VirusApiVirusReportsByAcessionsGet /virus/accession/{accessions}/dataset_reportGet virus metadata by accession
VirusApiVirusReportsByPostPost /virusGet virus metadata by POST
VirusApiVirusReportsByTaxonGet /virus/taxon/{taxon}/dataset_reportGet virus metadata by taxon

Documentation For Models

Documentation For Authorization

ApiKeyAuth

  • Type: API key
  • API key parameter name: api_key
  • Location: URL query string

Note, each API key must be added to a map of map[string]APIKey where the key is: api_key and passed in as the auth context for each request.

ApiKeyAuthHeader

  • Type: API key
  • API key parameter name: api-key
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: api-key and passed in as the auth context for each request.

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author