def datasets(data="all", type=None, uuid=None, query=None, id=None, limit=100, offset=None, **kwargs): """ Search for datasets and dataset metadata. :param data: [str] The type of data to get. Default: ``all`` :param type: [str] Type of dataset, options include ``OCCURRENCE``, etc. :param uuid: [str] UUID of the data node provider. This must be specified if data is anything other than ``all``. :param query: [str] Query term(s). Only used when ``data = 'all'`` :param id: [int] A metadata document id. References http://www.gbif.org/developer/registry#datasets Usage:: from pygbif import registry registry.datasets(limit=5) registry.datasets(type="OCCURRENCE") registry.datasets(uuid="a6998220-7e3a-485d-9cd6-73076bd85657") registry.datasets(data='contact', uuid="a6998220-7e3a-485d-9cd6-73076bd85657") registry.datasets(data='metadata', uuid="a6998220-7e3a-485d-9cd6-73076bd85657") registry.datasets(data='metadata', uuid="a6998220-7e3a-485d-9cd6-73076bd85657", id=598) registry.datasets(data=['deleted','duplicate']) registry.datasets(data=['deleted','duplicate'], limit=1) """ args = {"q": query, "type": type, "limit": limit, "offset": offset} data_choices = [ "all", "organization", "contact", "endpoint", "identifier", "tag", "machinetag", "comment", "constituents", "document", "metadata", "deleted", "duplicate", "subDataset", "withNoEndpoint", ] check_data(data, data_choices) if len2(data) == 1: return datasets_fetch(data, uuid, args, **kwargs) else: return [datasets_fetch(x, uuid, args, **kwargs) for x in data]
def installations( data="all", uuid=None, q=None, identifier=None, identifierType=None, limit=100, offset=None, **kwargs ): """ Installations metadata. :param data: [str] The type of data to get. Default is all data. If not ``all``, then one or more of ``contact``, ``endpoint``, ``dataset``, ``comment``, ``deleted``, ``nonPublishing``. :param uuid: [str] UUID of the data node provider. This must be specified if data is anything other than ``all``. :param q: [str] Query nodes. Only used when ``data='all'``. Ignored otherwise. :param identifier: [fixnum] The value for this parameter can be a simple string or integer, e.g. identifier=120 :param identifierType: [str] Used in combination with the identifier parameter to filter identifiers by identifier type: ``DOI``, ``FTP``, ``GBIF_NODE``, ``GBIF_PARTICIPANT``, ``GBIF_PORTAL``, ``HANDLER``, ``LSID``, ``UNKNOWN``, ``URI``, ``URL``, ``UUID`` :param limit: [int] Number of results to return. Default: ``100`` :param offset: [int] Record to start at. Default: ``0`` :return: A dictionary References: http://www.gbif.org/developer/registry#installations Usage:: from pygbif import registry registry.installations(limit=5) registry.installations(q="france") registry.installations(uuid="b77901f9-d9b0-47fa-94e0-dd96450aa2b4") registry.installations(data='contact', uuid="b77901f9-d9b0-47fa-94e0-dd96450aa2b4") registry.installations(data='contact', uuid="2e029a0c-87af-42e6-87d7-f38a50b78201") registry.installations(data='endpoint', uuid="b77901f9-d9b0-47fa-94e0-dd96450aa2b4") registry.installations(data='dataset', uuid="b77901f9-d9b0-47fa-94e0-dd96450aa2b4") registry.installations(data='deleted') registry.installations(data='deleted', limit=2) registry.installations(data=['deleted','nonPublishing'], limit=2) registry.installations(identifierType='DOI', limit=2) """ args = { "q": q, "limit": limit, "offset": offset, "identifier": identifier, "identifierType": identifierType, } data_choices = [ "all", "contact", "endpoint", "dataset", "identifier", "tag", "machineTag", "comment", "deleted", "nonPublishing", ] check_data(data, data_choices) def getdata(x, uuid, args, **kwargs): if x not in ["all", "deleted", "nonPublishing"] and uuid is None: stop( "You must specify a uuid if data does not equal all and data does not equal one of deleted or nonPublishing" ) if uuid is None: if x == "all": url = gbif_baseurl + "installation" else: url = gbif_baseurl + "installation/" + x else: if x == "all": url = gbif_baseurl + "installation/" + uuid else: url = gbif_baseurl + "installation/" + uuid + "/" + x res = gbif_GET(url, args, **kwargs) return {"meta": get_meta(res), "data": parse_results(res, uuid)} if len2(data) == 1: return getdata(data, uuid, args, **kwargs) else: return [getdata(x, uuid, args, **kwargs) for x in data]
def nodes(data="all", uuid=None, q=None, identifier=None, identifierType=None, limit=100, offset=None, isocode=None, **kwargs): """ Nodes metadata. :param data: [str] The type of data to get. Default: ``all`` :param uuid: [str] UUID of the data node provider. This must be specified if data is anything other than ``all``. :param q: [str] Query nodes. Only used when ``data = 'all'`` :param identifier: [fixnum] The value for this parameter can be a simple string or integer, e.g. identifier=120 :param identifierType: [str] Used in combination with the identifier parameter to filter identifiers by identifier type: ``DOI``, ``FTP``, ``GBIF_NODE``, ``GBIF_PARTICIPANT``, ``GBIF_PORTAL``, ``HANDLER``, ``LSID``, ``UNKNOWN``, ``URI``, ``URL``, ``UUID`` :param limit: [int] Number of results to return. Default: ``100`` :param offset: [int] Record to start at. Default: ``0`` :param isocode: [str] A 2 letter country code. Only used if ``data = 'country'``. :return: A dictionary References http://www.gbif.org/developer/registry#nodes Usage:: from pygbif import registry registry.nodes(limit=5) registry.nodes(identifier=120) registry.nodes(uuid="1193638d-32d1-43f0-a855-8727c94299d8") registry.nodes(data='identifier', uuid="03e816b3-8f58-49ae-bc12-4e18b358d6d9") registry.nodes(data=['identifier','organization','comment'], uuid="03e816b3-8f58-49ae-bc12-4e18b358d6d9") uuids = ["8cb55387-7802-40e8-86d6-d357a583c596","02c40d2a-1cba-4633-90b7-e36e5e97aba8", "7a17efec-0a6a-424c-b743-f715852c3c1f","b797ce0f-47e6-4231-b048-6b62ca3b0f55", "1193638d-32d1-43f0-a855-8727c94299d8","d3499f89-5bc0-4454-8cdb-60bead228a6d", "cdc9736d-5ff7-4ece-9959-3c744360cdb3","a8b16421-d80b-4ef3-8f22-098b01a89255", "8df8d012-8e64-4c8a-886e-521a3bdfa623","b35cf8f1-748d-467a-adca-4f9170f20a4e", "03e816b3-8f58-49ae-bc12-4e18b358d6d9","073d1223-70b1-4433-bb21-dd70afe3053b", "07dfe2f9-5116-4922-9a8a-3e0912276a72","086f5148-c0a8-469b-84cc-cce5342f9242", "0909d601-bda2-42df-9e63-a6d51847ebce","0e0181bf-9c78-4676-bdc3-54765e661bb8", "109aea14-c252-4a85-96e2-f5f4d5d088f4","169eb292-376b-4cc6-8e31-9c2c432de0ad", "1e789bc9-79fc-4e60-a49e-89dfc45a7188","1f94b3ca-9345-4d65-afe2-4bace93aa0fe"] [ registry.nodes(data='identifier', uuid=x) for x in uuids ] """ args = { "q": q, "limit": limit, "offset": offset, "identifier": identifier, "identifierType": identifierType, } data_choices = [ "all", "organization", "endpoint", "identifier", "tag", "machineTag", "comment", "pendingEndorsement", "country", "dataset", "installation", ] check_data(data, data_choices) def getdata(x, uuid, args, **kwargs): if x != "all" and uuid is None: stop('You must specify a uuid if data does not equal "all"') if uuid is None: if x == "all": url = gbif_baseurl + "node" else: if isocode is not None and x == "country": url = gbif_baseurl + "node/country/" + isocode else: url = gbif_baseurl + "node/" + x else: if x == "all": url = gbif_baseurl + "node/" + uuid else: url = gbif_baseurl + "node/" + uuid + "/" + x res = gbif_GET(url, args, **kwargs) return {"meta": get_meta(res), "data": parse_results(res, uuid)} # Get data if len2(data) == 1: return getdata(data, uuid, args, **kwargs) else: return [getdata(x, uuid, args, **kwargs) for x in data]
def name_usage(key=None, name=None, data="all", language=None, datasetKey=None, uuid=None, sourceId=None, rank=None, shortname=None, limit=100, offset=None, **kwargs): """ Lookup details for specific names in all taxonomies in GBIF. :param key: [fixnum] A GBIF key for a taxon :param name: [str] Filters by a case insensitive, canonical namestring, e.g. 'Puma concolor' :param data: [str] The type of data to get. Default: ``all``. Options: ``all``, ``verbatim``, ``name``, ``parents``, ``children``, ``related``, ``synonyms``, ``descriptions``, ``distributions``, ``media``, ``references``, ``speciesProfiles``, ``vernacularNames``, ``typeSpecimens``, ``root`` :param language: [str] Language, default is english :param datasetKey: [str] Filters by the dataset's key (a uuid) :param uuid: [str] A uuid for a dataset. Should give exact same results as datasetKey. :param sourceId: [fixnum] Filters by the source identifier. :param rank: [str] Taxonomic rank. Filters by taxonomic rank as one of: ``CLASS``, ``CULTIVAR``, ``CULTIVAR_GROUP``, ``DOMAIN``, ``FAMILY``, ``FORM``, ``GENUS``, ``INFORMAL``, ``INFRAGENERIC_NAME``, ``INFRAORDER``, ``INFRASPECIFIC_NAME``, ``INFRASUBSPECIFIC_NAME``, ``KINGDOM``, ``ORDER``, ``PHYLUM``, ``SECTION``, ``SERIES``, ``SPECIES``, ``STRAIN``, ``SUBCLASS``, ``SUBFAMILY``, ``SUBFORM``, ``SUBGENUS``, ``SUBKINGDOM``, ``SUBORDER``, ``SUBPHYLUM``, ``SUBSECTION``, ``SUBSERIES``, ``SUBSPECIES``, ``SUBTRIBE``, ``SUBVARIETY``, ``SUPERCLASS``, ``SUPERFAMILY``, ``SUPERORDER``, ``SUPERPHYLUM``, ``SUPRAGENERIC_NAME``, ``TRIBE``, ``UNRANKED``, ``VARIETY`` :param shortname: [str] A short name..need more info on this? :param limit: [fixnum] Number of records to return. Default: ``100``. Maximum: ``1000``. (optional) :param offset: [fixnum] Record number to start at. (optional) References: http://www.gbif.org/developer/species#nameUsages Usage:: from pygbif import species species.name_usage(key=1) # Name usage for a taxonomic name species.name_usage(name='Puma', rank="GENUS") # All name usages species.name_usage() # References for a name usage species.name_usage(key=2435099, data='references') # Species profiles, descriptions species.name_usage(key=3119195, data='speciesProfiles') species.name_usage(key=3119195, data='descriptions') species.name_usage(key=2435099, data='children') # Vernacular names for a name usage species.name_usage(key=3119195, data='vernacularNames') # Limit number of results returned species.name_usage(key=3119195, data='vernacularNames', limit=3) # Search for names by dataset with datasetKey parameter species.name_usage(datasetKey="d7dddbf4-2cf0-4f39-9b2a-bb099caae36c") # Search for a particular language species.name_usage(key=3119195, language="FRENCH", data='vernacularNames') """ args = { "language": language, "name": name, "datasetKey": datasetKey, "rank": rank, "sourceId": sourceId, "limit": limit, "offset": offset, } data_choices = [ "all", "verbatim", "name", "parents", "children", "related", "synonyms", "descriptions", "distributions", "media", "references", "speciesProfiles", "vernacularNames", "typeSpecimens", "root", ] check_data(data, data_choices) if len2(data) == 1: return name_usage_fetch(data, key, shortname, uuid, args, **kwargs) else: return [ name_usage_fetch(x, key, shortname, uuid, args, **kwargs) for x in data ]
def networks(data="all", uuid=None, q=None, identifier=None, identifierType=None, limit=100, offset=None, **kwargs): """ Networks metadata. Note: there's only 1 network now, so there's not a lot you can do with this method. :param data: [str] The type of data to get. Default: ``all`` :param uuid: [str] UUID of the data network provider. This must be specified if data is anything other than ``all``. :param q: [str] Query networks. Only used when ``data = 'all'``. Ignored otherwise. :param identifier: [fixnum] The value for this parameter can be a simple string or integer, e.g. identifier=120 :param identifierType: [str] Used in combination with the identifier parameter to filter identifiers by identifier type: ``DOI``, ``FTP``, ``GBIF_NODE``, ``GBIF_PARTICIPANT``, ``GBIF_PORTAL``, ``HANDLER``, ``LSID``, ``UNKNOWN``, ``URI``, ``URL``, ``UUID`` :param limit: [int] Number of results to return. Default: ``100`` :param offset: [int] Record to start at. Default: ``0`` :return: A dictionary References: http://www.gbif.org/developer/registry#networks Usage:: from pygbif import registry registry.networks(limit=1) registry.networks(uuid='2b7c7b4f-4d4f-40d3-94de-c28b6fa054a6') """ args = { "q": q, "limit": limit, "offset": offset, "identifier": identifier, "identifierType": identifierType, } data_choices = [ "all", "contact", "endpoint", "identifier", "tag", "machineTag", "comment", "constituents", ] check_data(data, data_choices) def getdata(x, uuid, args, **kwargs): if x != "all" and uuid is None: stop('You must specify a uuid if data does not equal "all"') if uuid is None: url = gbif_baseurl + "network" else: if x == "all": url = gbif_baseurl + "network/" + uuid else: url = gbif_baseurl + "network/" + uuid + "/" + x res = gbif_GET(url, args, **kwargs) return {"meta": get_meta(res), "data": parse_results(res, uuid)} if len2(data) == 1: return getdata(data, uuid, args, **kwargs) else: return [getdata(x, uuid, args, **kwargs) for x in data]