def tag_section(self, tag, tab='top', **kwargs):
        """
        Get a tag feed section

        :param tag: tag text (without '#')
        :param tab: One of 'top', 'recent', 'places'
        :kwargs:
            **extract**: return the array of media items only
            **page**: for pagination
            **next_media_ids**: array of media_id (int) for pagination
            **max_id**: for pagination
        :return:
        """
        valid_tabs = ['top', 'recent', 'places']
        if tab not in valid_tabs:
            raise ValueError('Invalid tab: {}'.format(tab))

        extract_media_only = kwargs.pop('extract', False)
        endpoint = 'tags/{tag!s}/sections/'.format(
            **{'tag': compat_urllib_parse.quote(tag.encode('utf8'))})

        params = {
            'supported_tabs': json.dumps(valid_tabs, separators=(',', ':')),
            'tab': tab,
            'include_persistent': True,
        }

        # explicitly set known paging parameters to avoid triggering server-side errors
        if kwargs.get('max_id'):
            params['max_id'] = kwargs.pop('max_id')
        if kwargs.get('page'):
            params['page'] = kwargs.pop('page')
        if kwargs.get('next_media_ids'):
            params['next_media_ids'] = json.dumps(kwargs.pop('next_media_ids'), separators=(',', ':'))
        kwargs.pop('max_id', None)
        kwargs.pop('page', None)
        kwargs.pop('next_media_ids', None)

        params.update(kwargs)
        results = self._call_api(endpoint, params=params, unsigned=True)
        extracted_medias = []
        if self.auto_patch:
            for s in results.get('sections', []):
                for m in s.get('layout_content', {}).get('medias', []):
                    if m.get('media'):
                        ClientCompatPatch.media(m['media'], drop_incompat_keys=self.drop_incompat_keys)
                        if extract_media_only:
                            extracted_medias.append(m['media'])
        if extract_media_only:
            return extracted_medias
        return results

        Get a tag feed section

        :param tag: tag text (without '#')
        :param tab: One of 'top', 'recent', 'places'
        :kwargs:
            **extract**: return the array of media items only
            **page**: for pagination
            **next_media_ids**: array of media_id (int) for pagination
            **max_id**: for pagination
        :return:
        
instagram_private_api/endpoints/tags.py