Files
yankee-gnome-twitch-api/docs/api/twitch/twitchdata.com/stub.md
2025-02-06 12:51:43 -05:00

2.5 KiB

TwitchTrackerStubController API Documentation

This document outlines the functionalities provided by the TwitchTrackerStubController class.

Note: This API provides stubbed data, meaning it simulates real data from twitchtracker.com but doesn't interact with the actual website.

Base URL: http://localhost:8888/twitchtracker.com/channel/stub

CORS: Enabled

Endpoints

1. GET /rankings

  • Description: This endpoint retrieves a single page (50 channels) of stubbed Twitch channel rankings data.
  • Response: String containing HTML data representing the rankings table.

Example Usage:

GET http://localhost:8888/twitchtracker.com/channel/stub/rankings

2. GET /load/

  • Description: This endpoint fetches and returns a list of 1000 stubbed Twitch channels with their rankings.
  • Response: List of TwitchChannel objects containing channel information.

Example Usage:

GET http://localhost:8888/twitchtracker.com/channel/stub/load/

Implementation Details:

  • This endpoint calculates the number of pages required to retrieve 1000 channels based on the channelsPerTwitchTrackerPage constant (default 50).
  • It then iterates through each page number and calls the loadSingleTwitchTrackerPageByNumber endpoint to retrieve the data.
  • Finally, it combines all retrieved channels into a single list and returns it.

3. GET /load/{pageNumber}

  • Description: This endpoint retrieves a single page (50 channels) of stubbed Twitch channel rankings data based on the provided page number.
  • Path Variable: pageNumber (integer) - Specifies the desired page number.
  • Response: List of TwitchChannel objects containing channel information for the requested page.

Example Usage:

GET http://localhost:8888/twitchtracker.com/channel/stub/load/2

Implementation Details:

  • This endpoint fetches a single page of stubbed HTML data representing the rankings table.
  • It then parses the HTML and converts it into a list of TwitchChannel objects using the twitchTrackerService.convert_html_list_twitch_channels method.
  • Finally, it saves each retrieved channel to the database using the twitchChannelService.save method. (This behavior might be specific to your application's use case.)

Additional Notes:

  • The sleepRandomly method introduces a random delay between page fetches to simulate realistic network behavior.
  • This documentation assumes familiarity with Spring annotations like @GetMapping, @PathVariable, and @Autowired.