def get_crab_bookmarks(crab_ID): limit = request.args.get("limit") limit = api_utils.expect_int( limit, default=config.API_DEFAULT_CRAB_LIMIT, minimum=0, maximum=config.API_MAX_CRAB_LIMIT, ) offset = request.args.get("offset") offset = api_utils.expect_int(offset, default=0, minimum=0) crab = api_utils.get_crab(crab_ID) if crab: auth = require_auth(request) if auth: if crab.id == auth["crab_id"]: bookmarks = crab.query_bookmarks() bookmarks_json = api_utils.query_to_json(bookmarks) return bookmarks_json else: return abort( 401, description="These bookmarks do not " "belong to the authorized user.", ) else: return abort(401, description="This endpoint requires authentication.") else: return abort(404, description="No Crab with that ID.")
def get_crabtag(crabtag): limit = request.args.get("limit") limit = api_utils.expect_int( limit, default=config.API_DEFAULT_MOLT_LIMIT, minimum=0, maximum=config.API_MAX_MOLT_LIMIT, ) offset = request.args.get("offset") offset = api_utils.expect_int(offset, default=0, minimum=0) since = api_utils.expect_timestamp(request.args.get("since")) since_id = request.args.get("since_id") molts = api_utils.get_molts_with_tag(crabtag, since=since, since_id=since_id) molts_json = api_utils.query_to_json(molts, limit=limit, offset=offset) return molts_json
def get_molt_quotes(molt_ID): limit = request.args.get("limit") limit = api_utils.expect_int( limit, default=config.API_DEFAULT_MOLT_LIMIT, minimum=0, maximum=config.API_MAX_MOLT_LIMIT, ) offset = request.args.get("offset") offset = api_utils.expect_int(offset, default=0, minimum=0) since = api_utils.expect_timestamp(request.args.get("since")) since_id = request.args.get("since_id") quotes = api_utils.get_molt_quotes(molt_ID, since=since, since_id=since_id) quotes_json = api_utils.query_to_json(quotes, limit=limit, offset=offset) return quotes_json
def get_crab_following(crab_ID): limit = request.args.get("limit") limit = api_utils.expect_int( limit, default=config.API_DEFAULT_CRAB_LIMIT, minimum=0, maximum=config.API_MAX_CRAB_LIMIT, ) offset = request.args.get("offset") offset = api_utils.expect_int(offset, default=0, minimum=0) crab = api_utils.get_crab(crab_ID) if crab: following = api_utils.get_crab_following(crab) following_json = api_utils.query_to_json(following, limit=limit, offset=offset) return following_json else: return abort(404, description="No Crab with that ID.")
def get_timeline(username): limit = request.args.get("limit") limit = api_utils.expect_int( limit, default=config.API_DEFAULT_MOLT_LIMIT, minimum=0, maximum=config.API_MAX_MOLT_LIMIT, ) offset = request.args.get("offset") offset = api_utils.expect_int(offset, default=0, minimum=0) since = api_utils.expect_timestamp(request.args.get("since")) since_id = request.args.get("since_id") crab = api_utils.get_crab_by_username(username) if crab: molts = api_utils.get_timeline(crab, since=since, since_id=since_id) molts_json = api_utils.query_to_json(molts, limit=limit, offset=offset) return molts_json else: return abort(404, description="No Crab with that username.")