### JavaScript Example: Initialize and Search Brainly Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/AVAILABLE_LANGUAGES.md This JavaScript snippet demonstrates how to initialize the `brainly-scraper-v2` library, create an instance with a specific language code (e.g., 'id' for Indonesia), and perform a search query using the `search` method. It shows the basic setup and promise-based handling of results or errors. ```JavaScript const Brainly = require("brainly-scraper-v2"); // do '.initialize()' (v2.1.0) Brainly.initialize(); const brain = new Brainly("id"); // 'id' - Can be replaced with the country code above. Default to 'id' brain.search("Pythagoras").then(console.log).catch(console.error); ``` -------------------------------- ### Install Brainly Scraper v2 with NPM or Yarn Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/README.md Instructions for installing the brainly-scraper-v2 library, which provides functionalities to retrieve data from Brainly, using either NPM or Yarn package managers. ```shell npm install brainly-scraper-v2 ``` ```shell yarn add brainly-scraper-v2 ``` -------------------------------- ### Install Brainly Scraper V2 Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/index.html Instructions for installing the Brainly Scraper V2 library using npm and yarn package managers. ```Shell npm install brainly-scraper-v2 yarn add brainly-scraper-v2 ``` -------------------------------- ### Example JSON Output for Brainly Search Results Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/README.md Illustrates the structure of the JSON object returned by the `brainly-scraper-v2` library after a successful search query. It includes details about the question, such as content, ID, author, education level, and an array of answers. ```json [ { "question": { "id": 5070014, "content": "Pythagoras nació en el año 580 a.c y murió en el año 501. ¿Que edad tenia Pythagoras Cúando murió?", "closed": true, "created": "[Object]", "attachments": [], "author": "[Object]", "education": "matematicas", "education_level": null, "canBeAnswered": true, "points_answer": "[Object]", "points_question": 10, "grade": "Secundaria", "lastActivity": "2020-09-22T00:22:19.000Z", "verifiedAnswer": true }, "answers": [ "[Object]" ] }, { "..." } ] ``` -------------------------------- ### Brainly Scraper V2 Modules Overview Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalAnswer.html Lists the main modules available in the Brainly Scraper V2 project, including the primary module and GraphQL schemas. ```APIDOC Modules: - Brainly Scraper V2 - v2.2.8 - GraphQLSchemas ``` -------------------------------- ### Set Documentation Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/modules.html This JavaScript snippet initializes the documentation page's theme. It attempts to retrieve a theme preference from the user's local storage and applies it to the document's root element, falling back to 'os' (operating system preference) if no stored theme is found. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### JavaScript: Theme Preference Initialization Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalAuthor.html Initializes the document's theme by attempting to retrieve it from local storage. If no theme is found, it defaults to 'os'. This snippet is typically used for managing user interface theme preferences. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Search Brainly Questions using JavaScript Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/README.md Demonstrates how to initialize the Brainly scraper and perform searches using `searchWithMT` (with machine translation) or `search` methods. It highlights the necessity of providing a correct country code in the constructor to ensure accurate results and avoid errors. ```js const { Brainly } = require("brainly-scraper-v2"); // You should do '.initialize()' for 1st time (v2.1.0 - higher) Brainly.initialize(); const brain = new Brainly("id"); // 'id' - Default to 'id' // You can do brain.searchWithMT("Pythagoras", "es").then(console.log).catch(console.error); // Or (You need to enter correctly country code in the constructor). brain.search("Pythagoras", "es").then(console.log).catch(console.error); ``` -------------------------------- ### Set Documentation Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/CreatedInterface.html This JavaScript snippet sets the theme of the documentation page based on a value stored in local storage, defaulting to 'os' if no theme is found. It targets the `data-theme` attribute of the document's root element. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Initialize Document Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/Comment.html This JavaScript snippet sets the document's data-theme attribute based on a value retrieved from local storage, defaulting to 'os' if no theme is found. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Set Documentation Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalQuestion.html This JavaScript snippet sets the documentation theme based on a value stored in local storage, defaulting to 'os' if no theme is found. It applies the theme to the document's root element. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Set Documentation Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/BaseURLObject.html This JavaScript snippet sets the theme of the documentation page based on a value stored in local storage, defaulting to 'os' if no theme is found. It targets the `dataset.theme` property of the document's root element. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Search Brainly Content using JavaScript Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/index.html Demonstrates how to initialize the Brainly scraper, create an instance with a country code, and perform searches using `searchWithMT` or `search` methods. The output is an array of question and answer objects. ```JavaScript const { Brainly } = require("brainly-scraper-v2"); // You should do '.initialize()' for 1st time (v2.1.0 - higher) Brainly.initialize(); const brain = new Brainly("id"); // 'id' - Default to 'id' // You can do brain.searchWithMT("Pythagoras", "es").then(console.log).catch(console.error); // Or (You need to enter correctly country code in the constructor). brain.search("Pythagoras", "es").then(console.log).catch(console.error); ``` -------------------------------- ### Display Documentation Generation Date Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/modules.html This JavaScript snippet captures the documentation generation timestamp and formats it for display on the page. It sets a global window variable with the timestamp and then uses the Intl.DateTimeFormat API to render it in a user-friendly format based on the navigator's language settings. ```JavaScript window.GENERATION_DATE=1674208396246;document.getElementById('generation-date').innerText=new Intl.DateTimeFormat(navigator.language, {dateStyle: 'medium',timeStyle: 'long'}).format(window.GENERATION_DATE) ``` -------------------------------- ### APIDOC: Static initialize method for scraper resources Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/classes/Brainly.html Initializes the resources required for the Brainly Scraper V2. This method should be called before performing any scraping operations. ```APIDOC initialize(): Promise Returns: Promise ``` -------------------------------- ### Cache Class API Documentation Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/classes/Cache.html Detailed API documentation for the `Cache` class, outlining its structure, constructor, properties, and methods for managing cached Brainly data. ```APIDOC Class Cache: Hierarchy: Cache Defined in: lib/cache.ts:29 Constructors: constructor(): Description: Cache constructor Returns: Cache Defined in: lib/cache.ts:35 Properties: temporaryPath: string Type: Private Defined in: lib/cache.ts:30 Methods: clearAll(): Description: Remove caches data. Returns: void Defined in: lib/cache.ts:46 get(l: CountryList, q: string): Description: Get stored results in cache file. Parameters: l: CountryList - The language. q: string - The question. Returns: undefined | { answers: Answer[]; question: Question; }[] Defined in: lib/cache.ts:55 getQuestionsByLang(lang: CountryList): Description: Get collected question from a language code. Parameters: lang: CountryList - A language code Returns: Record Defined in: lib/cache.ts:112 has(l: CountryList, q: string): Description: The question is already exist on the cache file? Parameters: l: CountryList - The language. q: string - The question Returns: boolean Defined in: lib/cache.ts:97 json(): Description: Return a cache data. Returns: CacheResult Defined in: lib/cache.ts:126 ``` -------------------------------- ### Brainly Class Constructor Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/classes/Brainly.html Details the constructor for the Brainly class, explaining its parameters for country code, cache enablement, and Zadane cookie usage, and its return type. ```APIDOC constructor Signature: new Brainly(country?: CountryList, enabledCache?: boolean, useZadaneCookie?: boolean): Brainly Parameters: country: CountryList = 'id' Description: Application server country code. Invalid code triggers an Error Exception. enabledCache: boolean = true Description: Brainly Cache condition, can be disabled/enabled. useZadaneCookie: boolean = true Description: Use zadane cookie for requests. Returns: Brainly Defined in: lib/main.ts:49 ``` -------------------------------- ### Set Documentation Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/LanguageList.html This JavaScript snippet sets the theme of the documentation page based on a value stored in local storage. If no theme is found, it defaults to 'os'. This ensures consistent user experience across sessions. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Initialize Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/WorkType.html This JavaScript snippet sets the document's theme based on a value retrieved from local storage, defaulting to 'os' if no theme is found. It's typically used for persistent UI theme settings. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### GraphQL Query Schemas Overview Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/assets/README.md Defines the available GraphQL queries for fetching user information, searching questions, and retrieving specific questions by ID. Each schema specifies its required input parameters and the type of data it returns. ```GraphQL FindUserById: Input: userid: ID! Returns: user FindUserByDatabaseID: Input: userid: Int! Returns: user SearchQuery: Input: query: String!, len: Int! Returns: questionSearch FindQuestionById: Input: id: ID! Returns: node ``` -------------------------------- ### Brainly Scraper V2 API Reference Index Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/modules.html This section provides a structured index of the core API elements available in the Brainly Scraper V2 library. It categorizes and lists namespaces, classes, interfaces, and type aliases, serving as a high-level overview of the library's public API surface. ```APIDOC Namespaces: - GraphQLSchemas Classes: - Brainly - Cache Interfaces: - Answer - Author - AuthorQuestionData - BrainlyResponse - Comment - CreatedInterface - OriginalAnswer - OriginalAuthor - OriginalComment - OriginalQuestion - OriginalQuestionAndSimilar - OriginalVerification - Question Type Aliases: - Attachments - BaseURLObject - CacheResult - CountryList - JsonRes - LanguageList - OriginalAttachments - WorkType ``` -------------------------------- ### Brainly Scraper V2 API Reference Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/index.html Detailed API reference for Brainly Scraper V2, listing modules, classes, interfaces, and types available in the library, generated by TypeDoc. ```APIDOC Modules: - Brainly Scraper V2 (v2.2.8) - GraphQLSchemas Classes: - Brainly - Cache Interfaces: - Answer - Author - AuthorQuestionData - BrainlyResponse - Comment - CreatedInterface - OriginalAnswer - OriginalAuthor - OriginalComment - OriginalQuestion - OriginalQuestionAndSimilar - OriginalVerification - Question Types: - Attachments - BaseURLObject - CacheResult - CountryList - JsonRes - LanguageList - OriginalAttachments - WorkType ``` -------------------------------- ### Client-side Documentation Generation Date Script Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalAnswer.html A small JavaScript snippet used in the generated documentation to display the date and time of its generation on the client side. ```JavaScript window.GENERATION_DATE=1674208397447;document.getElementById('generation-date').innerText=new Intl.DateTimeFormat(navigator.language, {dateStyle: 'medium',timeStyle: 'long'}).format(window.GENERATION_DATE) ``` -------------------------------- ### Set TSD Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalQuestionAndSimilar.html This JavaScript snippet sets the theme of the TSD (TypeDoc) documentation based on a value stored in local storage, defaulting to 'os' if no theme is found. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### API Documentation for fetchGraphQLSchemas Function Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/functions/GraphQLSchemas.fetchGraphQLSchemas.html Documents the `fetchGraphQLSchemas` function, which is part of the Brainly Scraper V2 project. This function is asynchronous and returns a Promise. ```APIDOC Function: fetchGraphQLSchemas Signature: fetchGraphQLSchemas(): Promise[] Returns: Promise Defined In: lib/graphql-schemas.ts:51 ``` -------------------------------- ### Display Documentation Generation Date Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/CreatedInterface.html This JavaScript snippet sets a global variable `window.GENERATION_DATE` with a timestamp and then formats this timestamp into a human-readable date and time string, which is then displayed in an HTML element with the ID 'generation-date'. ```JavaScript window.GENERATION_DATE=1674208397434;document.getElementById('generation-date').innerText=new Intl.DateTimeFormat(navigator.language, {dateStyle: 'medium',timeStyle: 'long'}).format(window.GENERATION_DATE) ``` -------------------------------- ### BrainlyResponse Interface API Documentation Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/BrainlyResponse.html Detailed API documentation for the `BrainlyResponse` interface, outlining its structure, hierarchy, and properties, specifically the `node` property which is of type `OriginalQuestionAndSimilar`. ```APIDOC Interface: BrainlyResponse Hierarchy: - BrainlyResponse Properties: - node: OriginalQuestionAndSimilar Description: Represents the original question and similar questions. Source: lib/types.ts:398 ``` ```TypeScript interface BrainlyResponse { node: OriginalQuestionAndSimilar; } ``` -------------------------------- ### GraphQLSchemas Namespace API Reference Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/modules/GraphQLSchemas.html API documentation for the `GraphQLSchemas` namespace, detailing its definition location and available functions. This namespace is crucial for interacting with GraphQL schemas within the Brainly Scraper V2 project. ```APIDOC Namespace GraphQLSchemas Defined in lib/graphql-schemas.ts:1 Functions: actionGraphQLSchemas fetchGraphQLSchemas ``` -------------------------------- ### API Documentation for Cache.set Function Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/classes/Cache.html Documents the 'set' method of the Cache module. This function is responsible for storing the results of a request (answers and question) into a cache file, identified by language and question. ```APIDOC Function: set Description: Store the request results to Cache file. Signature: set(l: CountryList, q: string, res: { answers: Answer[]; question: Question; }[]): void Parameters: l: CountryList Description: The language. q: string Description: The question. res: { answers: Answer[]; question: Question; }[] Description: The result. Returns: void Defined in: lib/cache.ts:74 ``` -------------------------------- ### APIDOC: Brainly Scraper V2 Modules, Classes, and Interfaces Overview Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/LanguageList.html This section provides an overview of the main structural components of the Brainly Scraper V2 project, including its modules, classes, interfaces, and type aliases. It serves as a quick reference for navigating the project's API. ```APIDOC Modules: Brainly Scraper V2 - v2.2.8 GraphQLSchemas Classes: Brainly Cache Interfaces: Answer Author AuthorQuestionData BrainlyResponse Comment CreatedInterface OriginalAnswer OriginalAuthor OriginalComment OriginalQuestion OriginalQuestionAndSimilar OriginalVerification Question Type Aliases/Other Types: Attachments BaseURLObject CacheResult CountryList JsonRes LanguageList OriginalAttachments WorkType ``` -------------------------------- ### Set Document Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalAnswer.html This JavaScript snippet sets the `data-theme` attribute on the document's root element. It attempts to retrieve a theme preference from `localStorage` using the key 'tsd-theme'. If no preference is found or the value is null, it defaults the theme to 'os'. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Set Document Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/Question.html This JavaScript snippet sets the `data-theme` attribute on the document's root element based on a value stored in local storage. If no theme is found in local storage, it defaults to 'os'. This ensures consistent theme application across user sessions. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### OriginalAnswer Class API Reference Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalAnswer.html Details the properties of the OriginalAnswer class, representing an answer object from Brainly, including content, author, attachments, and various metadata like points and rates. ```APIDOC Class: OriginalAnswer Properties: - attachments - author - canComment - comments - content - created - id - isBest - isConfirmed - points - qualityScore - ratesCount - thanksCount - verification ``` -------------------------------- ### APIDOC: Static client method for Axios instance creation Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/classes/Brainly.html Creates an Axios instance configured for the Brainly API based on the specified country code. This instance can be used for making HTTP requests. ```APIDOC client(country: CountryList): AxiosInstance country: CountryList - Country code. Returns: AxiosInstance ``` -------------------------------- ### Set Document Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalComment.html This JavaScript snippet sets the 'data-theme' attribute on the document's root element. It attempts to retrieve a theme preference from local storage using the key 'tsd-theme'. If no value is found, it defaults to 'os'. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Display Documentation Generation Date Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/BaseURLObject.html This JavaScript snippet captures a Unix timestamp representing the documentation generation date, stores it in `window.GENERATION_DATE`, and then formats and displays this date in a human-readable format within an HTML element with the ID 'generation-date'. It uses `Intl.DateTimeFormat` for localization. ```JavaScript window.GENERATION_DATE=1674208397490;document.getElementById('generation-date').innerText=new Intl.DateTimeFormat(navigator.language, {dateStyle: 'medium',timeStyle: 'long'}).format(window.GENERATION_DATE) ``` -------------------------------- ### Display Documentation Generation Date Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/JsonRes.html Initializes a global `GENERATION_DATE` variable with a Unix timestamp. It then formats this timestamp into a human-readable date and time string using `Intl.DateTimeFormat` and displays it within an HTML element with the ID 'generation-date'. ```JavaScript window.GENERATION_DATE=1674208397498;document.getElementById('generation-date').innerText=new Intl.DateTimeFormat(navigator.language, {dateStyle: 'medium',timeStyle: 'long'}).format(window.GENERATION_DATE) ``` -------------------------------- ### Brainly Class Overview and Structure Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/classes/Brainly.html Defines the main Brainly class, its inheritance, and an index of its members including constructors, properties, and methods, providing a high-level view of its API surface. ```APIDOC Class Brainly Hierarchy: - Brainly Defined in: lib/main.ts:21 Index: Constructors: - constructor Properties: - #cookieZadane - cache - country - enabledCache - worker Methods: - findUserById - search - searchById - searchWithMT - client - getBaseURL - getRequestParams - initialize - isValidLanguage ``` -------------------------------- ### Set Documentation Generation Date JavaScript Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalQuestion.html A client-side JavaScript snippet used by the TypeDoc generated documentation to set and display the date and time when the documentation was generated. ```JavaScript window.GENERATION_DATE=1674208397470;document.getElementById('generation-date').innerText=new Intl.DateTimeFormat(navigator.language, {dateStyle: 'medium',timeStyle: 'long'}).format(window.GENERATION_DATE) ``` -------------------------------- ### Set TSD Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/AuthorQuestionData.html This JavaScript snippet sets the theme of the document's root element based on a value stored in local storage. If no theme is found, it defaults to 'os'. This is typically used for UI theme persistence. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Set Document Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/CountryList.html This JavaScript snippet retrieves the theme preference from local storage and applies it to the document's root element's dataset, defaulting to 'os' if no theme is found. This is typically used for persistent UI theme settings. ```javascript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### actionGraphQLSchemas Function API Reference Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/functions/GraphQLSchemas.actionGraphQLSchemas.html Provides the API signature and details for the `actionGraphQLSchemas` function. This function is designed to either write new GraphQL schema content or read existing schema content, optionally taking a Readable stream for input. ```APIDOC Function: actionGraphQLSchemas Signature: actionGraphQLSchemas(action: "write" | "read", contentStream?: Readable): Promise Parameters: action: "write" | "read" - Specifies the operation to perform: 'write' to save a schema or 'read' to retrieve one. contentStream?: Readable - Optional. A Readable stream that provides the content to be written when the 'action' is 'write'. Returns: Promise - A Promise that resolves to `undefined` if the 'write' action is successful, or a `string` containing the GraphQL schema content if the 'read' action is successful. The Promise will reject if an error occurs during the operation. Defined In: lib/graphql-schemas.ts ``` -------------------------------- ### JavaScript: Display Documentation Generation Date Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/OriginalAttachments.html This JavaScript snippet initializes a global variable `window.GENERATION_DATE` with a Unix timestamp and then formats this timestamp into a human-readable date and time string. The formatted date is then inserted into an HTML element with the ID 'generation-date', indicating when the document was generated. ```JavaScript window.GENERATION_DATE=1674208397502;document.getElementById('generation-date').innerText=new Intl.DateTimeFormat(navigator.language, {dateStyle: 'medium',timeStyle: 'long'}).format(window.GENERATION_DATE) ``` -------------------------------- ### Question Interface/Class Properties (APIDOC) Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/Question.html Details the properties available on the `Question` object within the Brainly Scraper V2 API. This includes attributes like content, author, creation date, and various status flags, providing a comprehensive view of a question's data structure. ```APIDOC Question: properties: attachments: Array of attachments (e.g., images, files) author?: User object representing the question's author (optional) canBeAnswered: Boolean indicating if the question can still receive answers closed: Boolean indicating if the question is closed content: String content of the question created: Date/Timestamp when the question was created databaseId: Unique identifier in the database (number) education: String representing the education category educationLevel?: String representing the education level (optional) grade: Number representing the grade level id: Unique identifier (string) lastActivity?: Date/Timestamp of the last activity on the question (optional) pointsAnswer: Number of points awarded for answering the question pointsQuestion: Number of points spent to ask the question similars: Array of similar questions verifiedAnswer: Boolean indicating if the question has a verified answer ``` -------------------------------- ### Set Document Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalVerification.html A JavaScript snippet that sets the `data-theme` attribute on the document's root element. It retrieves the theme preference from `localStorage` using the key 'tsd-theme' and defaults to 'os' if no value is found. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Brainly Scraper V2 Author Module API Reference Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/Author.html Documents the properties available within the Author module of the Brainly Scraper V2 API. This includes various user-related data points such as best answers count, points, friends count, and rank information. ```APIDOC Author: Properties: answerStreak?: boolean avatarUrl?: string bestAnswers: number bestAnswersCount: number created: string databaseId: string friendsCount: number gender: string helpedUsersCount: number id: string points: number questions: number rank: string receivedThanks: number specialRanks: string[] username?: string ``` -------------------------------- ### OriginalQuestionAndSimilar Interface API Reference Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalQuestionAndSimilar.html Defines the `OriginalQuestionAndSimilar` interface, which extends `OriginalQuestion` and includes properties related to a Brainly question and its answers. This interface is crucial for parsing detailed question data from Brainly. ```APIDOC Interface OriginalQuestionAndSimilar Hierarchy: OriginalQuestion OriginalQuestionAndSimilar Defined in: lib/types.ts:302 Properties: answers: { hasVerified: boolean; nodes: OriginalAnswer[]; } Inherited from: OriginalQuestion.answers Defined in: lib/types.ts:296 attachments: OriginalAttachments Inherited from: OriginalQuestion.attachments Defined in: lib/types.ts:282 author: OriginalAuthor Inherited from: OriginalQuestion.author Defined in: lib/types.ts:281 canBeAnswered: boolean Inherited from: OriginalQuestion.canBeAnswered Defined in: lib/types.ts:288 content: string Inherited from: OriginalQuestion.content Defined in: lib/types.ts:280 created: string Inherited from: OriginalQuestion.created Defined in: lib/types.ts:286 eduLevel?: number (Optional) Inherited from: OriginalQuestion.eduLevel Defined in: lib/types.ts:295 grade: { name: string; } Inherited from: OriginalQuestion.grade Defined in: lib/types.ts:289 id: string Inherited from: OriginalQuestion.id Defined in: lib/types.ts:279 isClosed: boolean Inherited from: OriginalQuestion.isClosed Defined in: lib/types.ts:287 lastActivity?: string (Optional) Inherited from: OriginalQuestion.lastActivity Defined in: lib/types.ts:290 ``` -------------------------------- ### Set Document Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/JsonRes.html Sets the `data-theme` attribute on the document's root element. It attempts to retrieve a theme preference from local storage using the key 'tsd-theme' and defaults to 'os' if no stored value is found. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Display Documentation Generation Date Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/WorkType.html This JavaScript snippet sets a global variable for the documentation generation timestamp and formats it for display in an HTML element. It uses 'Intl.DateTimeFormat' for locale-aware date and time formatting. ```JavaScript window.GENERATION_DATE=1674208397505;document.getElementById('generation-date').innerText=new Intl.DateTimeFormat(navigator.language, {dateStyle: 'medium',timeStyle: 'long'}).format(window.GENERATION_DATE) ``` -------------------------------- ### Answer Class API Reference Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/Answer.html Defines the properties available for an Answer object within the Brainly Scraper V2 API, including content, author, timestamps, and various metrics. Properties marked with '?' are optional. ```APIDOC Answer Class Properties: attachments: Array author?: Author canComment: boolean comments: Array confirmed: boolean content: string created: Date databaseId: string id: string isBest: boolean points: number ratesCount: number score: number thanksCount: number verification?: Verification ``` -------------------------------- ### API Documentation for Comment Interface Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/Comment.html Defines the structure of a Comment object, including its properties like author details, content, and various identifiers, as part of the Brainly Scraper V2 API. ```APIDOC Interface Comment Hierarchy: Comment Defined in: lib/types.ts:176 Properties: author?: { avatar: { thumbnailUrl: string; url: string; }; created: string; friends: { count: number; }; id: string; nick: string; points: number; receivedThanks: number; } Description: The comment's author. Defined in: lib/types.ts:184 content: string Description: The comment contents. Defined in: lib/types.ts:188 databaseId: number Description: Database ID Defined in: lib/types.ts:197 deleted?: boolean Description: Comment is already deleted? Defined in: lib/types.ts:192 id: string Description: Comment ID (comment identifier) Defined in: lib/types.ts:180 ``` -------------------------------- ### API Property: OriginalQuestion.similar Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalQuestionAndSimilar.html Represents an array of similar questions, where each entry contains an OriginalQuestion object. This property is defined within the current type. ```APIDOC OriginalQuestion.similar: { question: OriginalQuestion; }[] ``` -------------------------------- ### CreatedInterface API Definition Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/CreatedInterface.html Defines the `CreatedInterface` structure, including its properties `date` (Date type) and `iso` (string type), as part of the Brainly Scraper V2 project. This interface is defined in `lib/types.ts`. ```APIDOC Interface CreatedInterface Hierarchy: - CreatedInterface Defined in: lib/types.ts:392 Properties: date: Date Defined in: lib/types.ts:394 iso: string Defined in: lib/types.ts:393 ``` -------------------------------- ### APIDOC: OriginalAuthor Interface Definition Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalAuthor.html Defines the structure of the OriginalAuthor interface, detailing its properties and their types, including nested objects and arrays. This interface represents the data structure for an author's profile on Brainly. ```TypeScript interface OriginalAuthor { id: string; nick: string; avatar: { thumbnailUrl: string; url: string; }; helpedUsersCount: number; gender: string; created: string; bestAnswersCount: number; answererLevel: string; points: number; friends: { count: number; }; answeringStreak?: { canLotteryPointsBeClaimed: boolean; pointForTommorow: number; pointsForToday: number; progress: number; progressIncreasedToday: boolean; }; bestAnswersCountInLast30Days: number; questions: { count: number; edges: { node: { attachments: [OriginalAttachments]; canBeAnswered: boolean; content: string; created: string; eduLevel?: number; grade: { name: string; }; isClosed: boolean; points: number; pointsForAnswer: number; pointsForBestAnswer: number; subject: { id: string; name: string; }; }; }[]; }; } ``` -------------------------------- ### OriginalAnswer Interface API Definition Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalAnswer.html Defines the `OriginalAnswer` interface, which represents a structured answer object from the Brainly platform. It includes properties for content, author, attachments, comments, various counts (points, rates, thanks), and status flags (isBest, isConfirmed). ```APIDOC Interface OriginalAnswer Hierarchy: - OriginalAnswer Defined in lib/types.ts:308 Properties: - attachments: OriginalAttachments Defined in lib/types.ts:320 - author: OriginalAuthor Defined in lib/types.ts:318 - canComment: boolean Defined in lib/types.ts:321 - comments: { count: number; edges: { node: OriginalComment; }[]; } Defined in lib/types.ts:322 - content: string Defined in lib/types.ts:310 - created: string Defined in lib/types.ts:311 - id: string Defined in lib/types.ts:309 - isBest: boolean Defined in lib/types.ts:312 - isConfirmed: boolean Defined in lib/types.ts:313 - points: number Defined in lib/types.ts:314 - qualityScore: number Defined in lib/types.ts:315 - ratesCount: number Defined in lib/types.ts:317 - thanksCount: number Defined in lib/types.ts:316 - verification: OriginalVerification Defined in lib/types.ts:319 ``` -------------------------------- ### Set Document Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/CacheResult.html This JavaScript snippet sets the `data-theme` attribute on the document's root element based on a value retrieved from local storage. If no theme is found in local storage, it defaults to 'os' (operating system preference). ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Search Brainly Questions by Query Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/classes/Brainly.html This function allows searching for questions on Brainly based on a text query. It returns detailed information including question details, author, answer details, attachments (if any), and ratings. The search behavior is based on the constructor's country code. ```APIDOC search(question: string, language?: CountryList, length?: number, options?: AxiosRequestConfig): Promise<{ answers: Answer[]; question: Question; }[]> Parameters: question: string - A question you want to search. Example: `Pythagoras theory` language: CountryList = 'id' - What language want to search? length: number = 10 - Length array from question list options: AxiosRequestConfig = {} - Custom Axios request options Returns: Promise<{ answers: Answer[]; question: Question; }[]> ``` ```TypeScript brain.search('Pythagoras', 'id', 10).then(console.log); ``` -------------------------------- ### OriginalComment Interface API Documentation Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalComment.html Detailed API documentation for the `OriginalComment` interface, outlining its properties and their respective types, including nested objects like `author` and `avatar`. This interface defines the structure of a comment object. ```APIDOC Interface OriginalComment Hierarchy: OriginalComment Defined in: lib/types.ts:200 Properties: id: string Defined in: lib/types.ts:201 deleted?: boolean (Optional) Defined in: lib/types.ts:202 content: string Defined in: lib/types.ts:203 author: object Defined in: lib/types.ts:204 Properties of author: avatar: object Properties of avatar: thumbnailUrl: string url: string created: string friends: object Properties of friends: count: number id: string nick: string points: number receivedThanks: number ``` -------------------------------- ### API Reference: OriginalQuestion Interface Structure Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalQuestion.html Defines the structure of an OriginalQuestion object retrieved from Brainly, including its properties like answers, author, content, and various metadata. This interface is extended by OriginalQuestionAndSimilar. ```APIDOC Interface OriginalQuestion Hierarchy: OriginalQuestion OriginalQuestionAndSimilar Properties: id: string content: string author: OriginalAuthor attachments: OriginalAttachments points: number pointsForAnswer: number pointsForBestAnswer: number created: string isClosed: boolean canBeAnswered: boolean grade: name: string lastActivity?: string (Optional) subject: id: string name: string eduLevel?: number (Optional) answers: hasVerified: boolean nodes: OriginalAnswer[] ``` -------------------------------- ### AuthorQuestionData Interface API Reference Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/AuthorQuestionData.html Defines the structure of the AuthorQuestionData interface, detailing its properties and their respective data types. This interface represents the data associated with a question asked by an author in the Brainly Scraper V2 project. ```APIDOC Interface AuthorQuestionData Hierarchy: - AuthorQuestionData Defined in: lib/types.ts:376 Properties: attachments: string[] Defined in: lib/types.ts:382 canBeAnswered: boolean Defined in: lib/types.ts:381 closed: boolean Defined in: lib/types.ts:379 content: string Defined in: lib/types.ts:377 created: CreatedInterface Defined in: lib/types.ts:378 education: string Defined in: lib/types.ts:380 educationLevel: number Defined in: lib/types.ts:383 grade: string Defined in: lib/types.ts:389 pointsAnswer: { forBest: number; normal: number; } Defined in: lib/types.ts:384 pointsQuestion: number Defined in: lib/types.ts:388 ``` -------------------------------- ### Brainly Class Properties Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/classes/Brainly.html Documents the properties of the Brainly class, including private members like `#cookieZadane` and `enabledCache`, and public properties such as `cache` and `country`, along with their types and descriptions. ```APIDOC Properties: #cookieZadane: string = '' (Private) Description: Zadane cookie Defined in: lib/main.ts:41 cache: Cache Description: Brainly cache manager instance. Caches saved on /tmp folder, removed on machine reboot. Defined in: lib/main.ts:36 country: CountryList = 'id' Defined in: lib/main.ts:50 enabledCache: boolean = true (Private) Defined in: lib/main.ts:51 worker: Piscina = ... (Private) Description: Brainly worker pool (using npmjs.com/piscina) Defined in: lib/main.ts:25 ``` -------------------------------- ### Set Documentation Generation Date Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/LanguageList.html This JavaScript snippet sets the generation date of the documentation page. It retrieves a timestamp from `window.GENERATION_DATE` and formats it for display in a specific HTML element, providing information on when the documentation was last updated. ```JavaScript window.GENERATION_DATE=1674208397500;document.getElementById('generation-date').innerText=new Intl.DateTimeFormat(navigator.language, {dateStyle: 'medium',timeStyle: 'long'}).format(window.GENERATION_DATE) ``` -------------------------------- ### APIDOC: Static getBaseURL method for country-specific URL Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/classes/Brainly.html Retrieves the base URL for the Brainly site corresponding to the selected country. This is useful for constructing API endpoints. ```APIDOC getBaseURL(country: CountryList): string country: CountryList - A base url of your country selection Returns: string ``` -------------------------------- ### OriginalVerification Interface API Definition Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalVerification.html Defines the structure of the `OriginalVerification` interface, including its hierarchy and the `approval` property with its nested `approver` details (id and nick). This interface is defined in `lib/types.ts`. ```APIDOC Interface OriginalVerification Hierarchy: - OriginalVerification Defined in: lib/types.ts:269 Properties: approval: object Type declaration: approver: object id: string nick: string ``` -------------------------------- ### JavaScript: Set TSD Theme from Local Storage Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/types/OriginalAttachments.html This JavaScript snippet retrieves a theme preference from the browser's local storage and applies it to the document's root element. If no theme is found in local storage, it defaults to 'os'. This is commonly used for persistent UI theme settings. ```JavaScript document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os" ``` -------------------------------- ### Display Documentation Generation Date Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/OriginalVerification.html A JavaScript snippet that sets a global `GENERATION_DATE` timestamp and then formats and displays this date in a specific HTML element with the ID 'generation-date'. The date is formatted according to the user's locale. ```JavaScript window.GENERATION_DATE=1674208397480;document.getElementById('generation-date').innerText=new Intl.DateTimeFormat(navigator.language, {dateStyle: 'medium',timeStyle: 'long'}).format(window.GENERATION_DATE) ``` -------------------------------- ### API Reference: Answer Interface Definition Source: https://github.com/hanifdwyputras/brainly-scraper-v2/blob/develop/docs/interfaces/Answer.html Defines the structure of an Answer object returned by the Brainly Scraper V2, including its properties such as content, author, attachments, and various metadata. This interface represents a single answer to a question. ```APIDOC Interface Answer Hierarchy: Answer Defined in: lib/types.ts:122 Properties: id: string Description: The answer identifier Defined in: lib/types.ts:126 content: string Description: The answer contents. Defined in: lib/types.ts:130 author?: Author Description: The answerer, it could be undefined. Defined in: lib/types.ts:134 isBest: boolean Description: Is this best answer? Defined in: lib/types.ts:138 points: number Description: How many points are awarded to the answerer? Defined in: lib/types.ts:142 confirmed: boolean Defined in: lib/types.ts:143 score: number Defined in: lib/types.ts:144 ratesCount: number Description: The answer's rates count. Defined in: lib/types.ts:148 thanksCount: number Description: The answer's thanks count. Defined in: lib/types.ts:152 attachments: Attachments[] Description: Question attachments, it could be an empty array! Defined in: lib/types.ts:156 created: CreatedInterface Description: When the answer is created? Defined in: lib/types.ts:160 canComment: boolean Description: Can we comment to this answer? Defined in: lib/types.ts:164 verification?: OriginalVerification Defined in: lib/types.ts:165 comments: Comment[] Description: The comments. Defined in: lib/types.ts:169 databaseId: number Description: Database ID Defined in: lib/types.ts:173 ```