How to use the habanero.request.request function in habanero

To help you get started, we’ve selected a few habanero examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sckott / habanero / habanero / crossref / crossref.py View on Github external
cr = Crossref()
            cr.types()
            cr.types(ids = "journal")
            cr.types(ids = "journal-article")
            cr.types(ids = "journal", works = True)

            # deep paging
            res = cr.types(ids = "journal-article", works = True, cursor = "*", cursor_max = 120)
            ## use progress bar
            res = cr.types(ids = "journal-article", works = True, cursor = "*", cursor_max = 120, progress_bar = True)

            # field queries
            res = cr.types(ids = "journal-article", works = True, query_bibliographic = 'gender', rows = 100)
            [ x.get('title') for x in res['message']['items'] ]
        '''
        return request(self.mailto, self.ua_string, self.base_url, "/types/", ids,
            query, filter, offset, limit, sample, sort,
            order, facet, select, works, cursor, cursor_max,
            None, progress_bar, **kwargs)
github sckott / habanero / habanero / habanero.py View on Github external
:param facet: [Boolean] Include facet results. Default: false
        :param works: [Boolean] If true, works returned as well. Default: false
        :param kwargs: any additional arguments will be passed on to
            `requests.get`

        :return: Object response class, light wrapper around a dict

        Usage::

            from habanero import Habanero
            hb = Habanero()
            hb.members(ids = 98)
            # get works
            hb.members(ids = 98, works = True)
        '''
        res = request(self.base_url, "/members/", ids,
          query, filter, offset, limit, sample, sort,
          order, facet, works, **kwargs)
        return res
github sckott / habanero / habanero / habanero.py View on Github external
from habanero import Habanero
            hb = Habanero()
            hb.journals(ids = "2167-8359")
            hb.journals()
            hb.journals(ids = "2167-8359", works = True)
            hb.journals(ids = ['1803-2427', '2326-4225'])
            hb.journals(query = "ecology")
            hb.journals(query = "peerj")
            hb.journals(ids = "2167-8359", query = 'ecology', works = True, sort = 'score', order = "asc")
            hb.journals(ids = "2167-8359", query = 'ecology', works = True, sort = 'score', order = "desc")
            hb.journals(ids = "2167-8359", works = True, filter = {'from_pub_date': '2014-03-03'})
            hb.journals(ids = '1803-2427', works = True)
            hb.journals(ids = '1803-2427', works = True, sample = 1)
            hb.journals(limit: 2)
        '''
        res = request(self.base_url, "/journals/", ids,
          query, filter, offset, limit, sample, sort,
          order, facet, works, **kwargs)
        return res
github sckott / habanero / habanero / habanero.py View on Github external
:param sample: [Fixnum] Number of random DOIs to return. Default: 10
        :param kwargs: any additional arguments will be passed on to
            `requests.get`

        :return: [Array] of DOIs

        Usage::

            from habanero import Habanero
            hb = Habanero()
            hb.random_dois(1)
            hb.random_dois(10)
            hb.random_dois(50)
            hb.random_dois(100)
        '''
        res = request(self.base_url, "/works/", None,
            None, None, None, None, sample, None,
            None, None, None, True, **kwargs)
        return [ z['DOI'] for z in res.result['message']['items'] ]
github sckott / habanero / habanero / habanero.py View on Github external
:param facet: [Boolean] Include facet results. Default: false
        :param works: [Boolean] If true, works returned as well. Default: false
        :param kwargs: any additional arguments will be passed on to
            `requests.get`

        :return: Object response class, light wrapper around a dict

        Usage::

            from habanero import Habanero
            hb = Habanero()
            hb.types()
            hb.types(ids = "journal")
            hb.types(ids = "journal", works = True)
        '''
        res = request(self.base_url, "/types/", ids,
            query, filter, offset, limit, sample, sort,
            order, facet, works, **kwargs)
        return res
github sckott / habanero / habanero / habanero.py View on Github external
:param ids: [Array] DOIs (digital object identifier) or other identifiers
        :param kwargs: any additional arguments will be passed on to
            `requests.get`

        :return: list of DOI minting agencies

        Usage::

            from habanero import Habanero
            hb = Habanero()
            hb.registration_agency('10.1371/journal.pone.0033693')
            hb.registration_agency(ids = ['10.1007/12080.1874-1746','10.1007/10452.1573-5125', '10.1111/(issn)1442-9993'])
        '''
        check_kwargs(["query", "filter", "offset", "limit", "sample", "sort",
            "order", "facet", "works"], kwargs)
        res = request(self.base_url, "/works/", ids,
            None, None, None, None, None, None,
            None, None, None, True, **kwargs)
        if res.__class__ != list:
            k = []
            k.append(res)
        else:
            k = res
        return [ z.result['message']['agency']['label'] for z in k ]
github sckott / habanero / habanero / crossref / crossref.py View on Github external
cr.journals(limit: 2)

            # cursor - deep paging
            res = cr.journals(ids = "2167-8359", works = True, cursor = "*", cursor_max = 200)
            sum([ len(z['message']['items']) for z in res ])
            items = [ z['message']['items'] for z in res ]
            items = [ item for sublist in items for item in sublist ]
            [ z['DOI'] for z in items ][0:50]
            ## use progress bar
            res = cr.journals(ids = "2167-8359", works = True, cursor = "*", cursor_max = 200, progress_bar = True)

            # field queries
            res = cr.journals(ids = "2167-8359", works = True, query_bibliographic = 'fish', filter = {'type': 'journal-article'})
            [ x.get('title') for x in res['message']['items'] ]
        '''
        return request(self.mailto, self.ua_string, self.base_url, "/journals/", ids,
          query, filter, offset, limit, sample, sort,
          order, facet, select, works, cursor, cursor_max, None,
          progress_bar, **kwargs)
github sckott / habanero / habanero / crossref / crossref.py View on Github external
Optionally, pass a query string, e.g., `facet=type-name:*` or `facet=license=*`
            See Facets_ for options.
        :param kwargs: additional named arguments passed on to `requests.get`, e.g., field
            queries (see examples and FieldQueries_)

        :return: A dict

        Usage::

            from habanero import Crossref
            cr = Crossref()
            cr.licenses()
            cr.licenses(query = "creative")
        '''
        check_kwargs(["ids", "filter", "works"], kwargs)
        res = request(self.mailto, self.ua_string, self.base_url, "/licenses/", None,
            query, None, offset, limit, None, sort,
            order, facet, None, None, None, None, **kwargs)
        return res
github sckott / habanero / habanero / crossref / crossref.py View on Github external
sum([ len(z['message']['items']) for z in res ])
            items = [ z['message']['items'] for z in res ]
            items = [ item for sublist in items for item in sublist ]
            [ z['DOI'] for z in items ][0:50]
            ## use progress bar
            res = cr.funders(ids = '10.13039/100000001', works = True, cursor = "*", cursor_max = 200, progress_bar = True)

            # field queries
            res = cr.funders(ids = "10.13039/100000001", works = True, query_container_title = 'engineering', filter = {'type': 'journal-article'})
            eds = [ x.get('editor') for x in res['message']['items'] ]
            [ z for z in eds if z is not None ]

            # filters (as of this writing, only 1 filter is avail., "location")
            cr.funders(filter = {'location': "Sweden"})
        '''
        return request(self.mailto, self.ua_string, self.base_url, "/funders/", ids,
          query, filter, offset, limit, sample, sort,
          order, facet, select, works, cursor, cursor_max, None,
          progress_bar, **kwargs)
github sckott / habanero / habanero / crossref / crossref.py View on Github external
res = cr.members(ids = 98, works = True, cursor = "*")
            sum([ len(z['message']['items']) for z in res ])
            items = [ z['message']['items'] for z in res ]
            items = [ item for sublist in items for item in sublist ]
            [ z['DOI'] for z in items ][0:50]
            ## use progress bar
            res = cr.members(ids = 98, works = True, cursor = "*", cursor_max = 500, progress_bar = True)

            # field queries
            res = cr.members(ids = 98, works = True, query_author = 'carl boettiger', limit = 7)
            [ x['author'][0]['family'] for x in res['message']['items'] ]

            # filters (as of this writing, 4 filters are avail., see filter_names())
            res = cr.members(filter = {'has_public_references': True})
        '''
        return request(self.mailto, self.ua_string, self.base_url, "/members/", ids,
            query, filter, offset, limit, sample, sort,
            order, facet, select, works, cursor, cursor_max,
            None, progress_bar, **kwargs)