### Practical Examples: Fetching Stock Quotes Source: https://github.com/comnextoficial/documenta-oes/blob/main/index.md Demonstrates how to retrieve stock quotes for multiple assets using cURL, Python, and JavaScript. Each example shows how to include the authentication token and specify query parameters for data range and interval. ```cURL curl -H "Authorization: Bearer SEU_TOKEN" \ "https://brapi.dev/api/quote/ITUB4,BBDC4?range=1mo&interval=1d" ``` ```Python import requests token = "SEU_TOKEN" tickers = "ITUB4,BBDC4" url = f"https://brapi.dev/api/quote/{tickers}" response = requests.get( url, headers={"Authorization": f"Bearer {token}"}, params={"range": "1mo", "interval": "1d"} ) if response.status_code == 200: data = response.json() print(data['results']) else: print(f"Erro: {response.status_code}") ``` ```JavaScript const token = 'SEU_TOKEN'; const tickers = 'ITUB4,BBDC4'; const url = `https://brapi.dev/api/quote/${tickers}?range=1mo&interval=1d`; async function fetchQuotes() { try { const response = await fetch(url, { headers: { 'Authorization': `Bearer ${token}` } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); console.log(data.results); } catch (error) { console.error('Falha ao buscar cotações:', error); } } fetchQuotes(); ``` -------------------------------- ### Examples: Fetching Financial Data with cURL Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes.md These examples demonstrate various ways to use the `/api/quote` endpoint to retrieve financial data for B3 assets using `curl` commands, showcasing simple quotes, historical data, fundamental data, dividends, and additional modules. ```shell curl -X GET "https://brapi.dev/api/quote/PETR4,VALE3?token=SEU_TOKEN" ``` ```shell curl -X GET "https://brapi.dev/api/quote/MGLU3?range=1mo&interval=1d&token=SEU_TOKEN" ``` ```shell curl -X GET "https://brapi.dev/api/quote/ITSA4?fundamental=true÷nds=true&token=SEU_TOKEN" ``` ```shell curl -X GET "https://brapi.dev/api/quote/WEGE3?modules=summaryProfile,balanceSheetHistory&token=SEU_TOKEN" ``` -------------------------------- ### cURL Examples for Listing and Filtering B3 Asset Quotes Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes_list.md These cURL commands demonstrate how to retrieve a paginated list of B3 asset quotes from the `/api/quote/list` endpoint. Examples include filtering by sector and volume, and searching by ticker and ordering by name. An authentication token is required. ```Shell curl -X GET "https://brapi.dev/api/quote/list?sector=Finance&sortBy=volume&sortOrder=desc&limit=10&page=1&token=SEU_TOKEN" ``` ```Shell curl -X GET "https://brapi.dev/api/quote/list?search=ITUB&sortBy=name&sortOrder=asc&token=SEU_TOKEN" ``` -------------------------------- ### Example JSON Response for Stock Data Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md Illustrates the structure of a typical JSON response from the brapi.dev API when querying stock information, including details like symbol, name, price, and market capitalization. ```JSON { "results": [ { "symbol": "PETR4", "shortName": "PETROBRAS PN", "longName": "Petróleo Brasileiro S.A. - Petrobras", "currency": "BRL", "regularMarketPrice": 38.50, "regularMarketDayHigh": 39.00, "regularMarketDayLow": 38.20, "regularMarketChange": 0.30, "regularMarketChangePercent": 0.78, "regularMarketTime": "2024-10-26T17:08:00.000Z", "marketCap": 503100000000, "regularMarketVolume": 45678901, "logourl": "https://icons.brapi.dev/logos/PETR4.png" } ] } ``` -------------------------------- ### Example API Response for Stock Data Source: https://github.com/comnextoficial/documenta-oes/blob/main/index.md This JSON structure illustrates a typical successful response from the brapi.dev API when querying stock market data, showing fields like symbol, price, and market capitalization. ```JSON { "results": [ { "symbol": "PETR4", "shortName": "PETROBRAS PN", "longName": "Petróleo Brasileiro S.A. - Petrobras", "currency": "BRL", "regularMarketPrice": 38.50, "regularMarketDayHigh": 39.00, "regularMarketDayLow": 38.20, "regularMarketChange": 0.30, "regularMarketChangePercent": 0.78, "regularMarketTime": "2024-10-26T17:08:00.000Z", "marketCap": 503100000000, "regularMarketVolume": 45678901, "logourl": "https://icons.brapi.dev/logos/PETR4.png" } ] } ``` -------------------------------- ### Fetch Available Inflation Countries via GET Request Source: https://github.com/comnextoficial/documenta-oes/blob/main/inflacao_available.md Example API calls to retrieve a list of countries with available inflation data, filtered by a search term. These examples demonstrate how to make a GET request to the `/api/v2/inflation/available` endpoint, requiring an Authorization Bearer token. ```cURL curl -X GET "https://brapi.dev/api/v2/inflation/available?search=bra" \ -H "Authorization: Bearer " ``` ```JavaScript fetch("https://brapi.dev/api/v2/inflation/available?search=bra", { headers: { "Authorization": "Bearer " } }) ``` ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://brapi.dev/api/v2/inflation/available?search=bra" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```Python import requests url = "https://brapi.dev/api/v2/inflation/available?search=bra" response = requests.request("GET", url, headers = { "Authorization": "Bearer " }) print(response.text) ``` -------------------------------- ### Fetch Stock Quotes with brapi.dev API in Multiple Languages Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md Practical examples demonstrating how to retrieve stock quotes for multiple tickers (ITUB4, BBDC4) using cURL, Python, and JavaScript. The examples show how to include the Authorization header and specify query parameters like `range` and `interval`. ```cURL curl -H "Authorization: Bearer SEU_TOKEN" \ "https://brapi.dev/api/quote/ITUB4,BBDC4?range=1mo&interval=1d" ``` ```Python import requests token = "SEU_TOKEN" tickers = "ITUB4,BBDC4" url = f"https://brapi.dev/api/quote/{tickers}" response = requests.get( url, headers={"Authorization": f"Bearer {token}"}, params={"range": "1mo", "interval": "1d"} ) if response.status_code == 200: data = response.json() print(data['results']) else: print(f"Erro: {response.status_code}") ``` ```JavaScript const token = 'SEU_TOKEN'; const tickers = 'ITUB4,BBDC4'; const url = `https://brapi.dev/api/quote/${tickers}?range=1mo&interval=1d`; async function fetchQuotes() { try { const response = await fetch(url, { headers: { 'Authorization': `Bearer ${token}` } }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); console.log(data.results); } catch (error) { console.error('Falha ao buscar cotações:', error); } } fetchQuotes(); ``` -------------------------------- ### Sample Market Data Structure (IBOVESPA Index) Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes.md Example JSON structure for market data, including index details like two-hundred day averages, market cap, daily changes, historical prices, and valid ranges/intervals for data retrieval. ```JSON { "symbol": "^BVSP", "currency": "BRL", "twoHundredDayAverage": 111633.99, "twoHundredDayAverageChange": 3522.0781, "twoHundredDayAverageChangePercent": 0.03155023, "marketCap": null, "shortName": "IBOVESPA", "longName": "IBOVESPA", "regularMarketChange": 986.4375, "regularMarketChangePercent": 0.8640104, "regularMarketTime": "2023-10-09T20:19:00.000Z", "regularMarketPrice": 115156.07, "regularMarketDayHigh": 115218.65, "regularMarketDayRange": "113448.18 - 115218.65", "regularMarketDayLow": 113448.18, "regularMarketVolume": 0, "regularMarketPreviousClose": 114169.63, "regularMarketOpen": 114168.99, "averageDailyVolume3Month": 10704804, "averageDailyVolume10Day": 10880020, "fiftyTwoWeekLowChange": 18159.07, "fiftyTwoWeekLowChangePercent": 0.1872127, "fiftyTwoWeekRange": "96997.0 - 123010.0", "fiftyTwoWeekHighChange": -7853.9297, "fiftyTwoWeekHighChangePercent": -0.0638479, "fiftyTwoWeekLow": 96997, "fiftyTwoWeekHigh": 123010, "priceEarnings": null, "earningsPerShare": null, "logourl": "https://brapi.dev/favicon.svg", "updatedAt": "2023-10-10T00:45:08.312Z", "historicalDataPrice": [ { "date": 1696338000, "open": 115055, "high": 115056, "low": 113151, "close": 113419, "volume": 11104800, "adjustedClose": 113419 } ], "validRanges": [ "1d", "5d", "1mo", "3mo", "6mo", "1y", "2y", "5y", "10y", "ytd", "max" ], "validIntervals": [ "1m", "2m", "5m", "15m", "30m", "60m", "90m", "1h", "1d", "5d", "1wk", "1mo", "3mo" ], "dividendsData": {} } ``` -------------------------------- ### API Reference: GET /api/v2/currency/available Source: https://github.com/comnextoficial/documenta-oes/blob/main/moedas_available.md Detailed API documentation for the endpoint that lists available fiat currencies. It specifies the HTTP method, path, required headers, and optional query parameters for filtering and authentication. ```APIDOC GET /api/v2/currency/available Headers: Authorization: Type: Bearer Required: Yes Description: Authentication via HTTP Authorization header. Use the format Authorization: Bearer YOUR_TOKEN. Obtain your token at brapi.dev/dashboard. In: header Query Parameters: search: Type: string Required: Optional Description: Term to filter the list by currency name (partial, case-insensitive). token: Type: string Required: Yes (if not added as Authorization header) Description: Your personal Brapi API authentication token. Can be sent as Query Parameter (?token=YOUR_TOKEN) or HTTP Header (Authorization: Bearer YOUR_TOKEN). Both methods are accepted, but at least one must be used. Obtain your token at brapi.dev/dashboard. ``` -------------------------------- ### brapi.dev API Endpoints Overview Source: https://github.com/comnextoficial/documenta-oes/blob/main/index.md This section lists the main API endpoints available for various financial data categories, including stocks, cryptocurrencies, currencies, inflation, and the SELIC interest rate. The paths are inferred from the documentation structure and the provided cURL example. ```APIDOC API Endpoints: Stocks: GET /api/quote/{symbol}: Get quote, dividends, and financial data for a specific stock. GET /api/quote/list: Get quotes for all available stocks. Cryptocurrencies: GET /api/crypto: Get quote for cryptocurrencies. GET /api/crypto/available: List available cryptocurrencies. Currencies: GET /api/currency: Get quote for currencies. GET /api/currency/available: List available currencies. Inflation: GET /api/inflation: Get inflation data. GET /api/inflation/available: List available countries for inflation data. SELIC Interest Rate: GET /api/selic: Get SELIC interest rate data. GET /api/selic/available: List available countries for SELIC interest rate data. ``` -------------------------------- ### Fetch PETR4 Stock Quote using cURL Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md This example demonstrates how to make your first API request to brapi.dev using cURL. It fetches the quote for PETR4. Remember to replace 'SEU_TOKEN' with your actual API key obtained from the dashboard. ```Shell curl --request GET \ --url 'https://brapi.dev/api/quote/PETR4' \ --header 'Authorization: Bearer SEU_TOKEN' ``` -------------------------------- ### Get Stock Quote (PETR4) using cURL Source: https://github.com/comnextoficial/documenta-oes/blob/main/index.md Demonstrates how to make your first API request to brapi.dev using cURL to retrieve the quote for PETR4. This command requires an API token for authorization, which should replace 'SEU_TOKEN'. ```curl curl --request GET \ --url 'https://brapi.dev/api/quote/PETR4' \ --header 'Authorization: Bearer SEU_TOKEN' ``` -------------------------------- ### API Endpoint: GET /api/quote/list Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes_list.md Documentation for the `/api/quote/list` endpoint, which allows retrieving and filtering a paginated list of B3 asset quotes. Authentication via a Bearer token in the `Authorization` header is required. ```APIDOC GET /api/quote/list Headers: Authorization: Required. Bearer In: header Description: Authentication via HTTP Authorization header. Use format Authorization: Bearer YOUR_TOKEN. Obtain your token at https://brapi.dev/dashboard. ``` -------------------------------- ### Sample Financial Data Structure (Balance Sheet & Dividends) Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes.md Example JSON structure for financial data, including balance sheet details (current assets, liabilities, equity) and dividend information (cash, stock, subscriptions). ```JSON { "shortTermInvestments": 26397000000, "netReceivables": 22080000000, "inventory": 41550000000, "otherCurrentAssets": 12756000000, "totalCurrentAssets": 135212000000, "longTermInvestments": 4081000000, "propertyPlantEquipment": 843917000000, "otherAssets": 989585000000, "totalAssets": 1124797000000, "accountsPayable": 37659000000, "shortLongTermDebt": 68783000000, "otherCurrentLiab": 4418000000, "longTermDebt": 304684000000, "otherLiab": 3284000000, "totalCurrentLiabilities": 194808000000, "totalLiab": 1124797000000, "commonStock": 205432000000, "retainedEarnings": null, "treasuryStock": null, "otherStockholderEquity": -2457000000, "totalStockholderEquity": 367514000000, "netTangibleAssets": null, "goodWill": null, "intangibleAssets": 13961000000, "deferredLongTermAssetCharges": null, "deferredLongTermLiab": 9100000000, "minorityInterest": 1508000000, "capitalSurplus": null } ], "dividendsData": { "cashDividends": [ { "assetIssued": "BRPETRACNPR6", "paymentDate": "2023-11-22T13:00:00.000Z", "rate": 1.345348, "relatedTo": "4º Trimestre/2023", "approvedOn": "2023-11-22T13:00:00.000Z", "isinCode": "BRPETRACNPR6", "label": "DIVIDENDO", "lastDatePrior": "2023-11-22T13:00:00.000Z", "remarks": "" } ], "stockDividends": [], "subscriptions": [] } } ``` -------------------------------- ### brapi API: Get All Stock Quotes Endpoint Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes.md Retrieves a list of all available stock quotes from the brapi API. ```APIDOC Endpoint: /docs/acoes/list Method: GET Description: Cotação de todas as ações disponíveis na brapi (Quote for all available stocks in brapi). ``` -------------------------------- ### Example Successful API Response for Stock Data Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes_list.md Illustrates a successful API response containing stock and index data, including pagination details and available filters such as sectors and stock types. This snippet demonstrates the structure of a typical successful data retrieval. ```json { "indexes": [ { "stock": "^BVSP", "name": "IBOVESPA" } ], "stocks": [ { "stock": "PETR4", "name": "PETROBRAS PN", "close": 36.71, "change": 3.26, "volume": 87666300, "market_cap": 497695817728, "logo": "https://icons.brapi.dev/icons/PETR4.svg", "sector": "Energy Minerals", "type": "stock" } ], "availableSectors": [ "Energy Minerals", "Finance", "..." ], "availableStockTypes": [ "stock", "fund", "bdr" ], "currentPage": 1, "totalPages": 5, "itemsPerPage": 10, "totalCount": 45, "hasNextPage": true } ``` -------------------------------- ### Get Brazil Prime Rate for Specific Period (cURL) Source: https://github.com/comnextoficial/documenta-oes/blob/main/taxa-basica-de-juros.md Example cURL request to retrieve the Brazilian prime rate (SELIC) between December 2021 and January 2022, ordered by date in descending order. Requires an authentication token. ```bash curl -X GET "https://brapi.dev/api/v2/prime-rate?country=brazil&start=01/12/2021&end=01/01/2022&sortBy=date&sortOrder=desc&token=SEU_TOKEN" ``` -------------------------------- ### API Reference: Get Inflation Data Endpoint Source: https://github.com/comnextoficial/documenta-oes/blob/main/inflacao.md Detailed API documentation for the `/api/v2/inflation` endpoint, allowing retrieval of historical inflation data. Covers authentication methods, query parameters, their types, descriptions, and constraints for making requests. ```APIDOC GET /api/v2/inflation Headers: Authorization: Type: Bearer Required: Yes Description: Authentication via HTTP Authorization header. Use the format Authorization: Bearer YOUR_TOKEN. In: header Query Parameters: country: Type: string Optional: Yes Default: "brazil" Description: Name of the country for which to fetch inflation data. Use lowercase. Consult /api/v2/inflation/available for the list of supported countries. historical: Type: boolean Optional: Yes Default: false Description: Boolean (true or false). Defines whether historical data should be included. The exact behavior in conjunction with start/end should be verified. start: Type: string Optional: Yes Pattern: "^\\d{2}/\\d{2}/\\d{4}$" Format: "date" Description: Start date of the desired period for historical data, in DD/MM/YYYY format. Required if end is specified. end: Type: string Optional: Yes Pattern: "^\\d{2}/\\d{2}/\\d{4}$" Format: "date" Description: End date of the desired period for historical data, in DD/MM/YYYY format. Required if start is specified. sortBy: Type: string Optional: Yes Default: "date" Value in: "date" | "value" Description: Field by which the inflation results will be ordered. sortOrder: Type: string Optional: Yes Default: "desc" Value in: "asc" | "desc" Description: Direction of sorting: asc (ascending) or desc (descending). Default: desc. Requires sortBy to be specified. token: Type: string Required: Yes (if not added as "Authorization" header) Description: Your personal Brapi API authentication token. Can be sent as a Query Parameter (?token=YOUR_TOKEN) or HTTP Header (Authorization: Bearer YOUR_TOKEN). Both methods are accepted, but at least one must be used. ``` -------------------------------- ### Fetch Historical Inflation Data with cURL Source: https://github.com/comnextoficial/documenta-oes/blob/main/inflacao.md Demonstrates how to retrieve historical inflation data for a specific country using the brapi.dev API. Examples show filtering by date range and sorting, as well as fetching the most recent data. ```curl curl -X GET "https://brapi.dev/api/v2/inflation?country=brazil&start=01/01/2022&end=31/12/2022&sortBy=value&sortOrder=asc&token=SEU_TOKEN" ``` ```curl curl -X GET "https://brapi.dev/api/v2/inflation?country=brazil&token=SEU_TOKEN" ``` -------------------------------- ### API Endpoint: Get Cryptocurrency Quotes Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes_list.md Documentation for retrieving real-time quotes for all available cryptocurrencies on the brapi platform. This endpoint allows users to access current market prices and related data for various digital assets. ```APIDOC GET /cryptocurrencies Description: Retrieve quotes for all available cryptocurrencies on brapi. ``` -------------------------------- ### API Endpoint: Get Prime Rate (SELIC) Details Source: https://github.com/comnextoficial/documenta-oes/blob/main/taxa-basica-de-juros.md Detailed API documentation for the `/api/v2/prime-rate` endpoint, including required authentication headers and available query parameters for filtering and sorting prime interest rate data. ```APIDOC GET /api/v2/prime-rate Headers: Authorization: Type: string (Bearer ) Required: Yes Description: Authentication via HTTP Authorization header. Format: Authorization: Bearer YOUR_TOKEN. Obtain your token at brapi.dev/dashboard. In: header Query Parameters: country: Type: string Optional: Yes Default: "brazil" Description: The country for which to obtain prime rate information. Default is 'brazil'. Available countries can be listed via /api/v2/prime-rate/available. historical: Type: boolean Optional: Yes Default: false Description: Defines whether historical data will be returned. If true, returns the complete historical series. If false (default) or omitted, returns only the most recent value. start: Type: string (date, DD/MM/YYYY) Optional: Yes Description: Start date for the search period in DD/MM/YYYY format. Useful when historical=true to restrict the historical series period. end: Type: string (date, DD/MM/YYYY) Optional: Yes Description: End date for the search period in DD/MM/YYYY format. Defaults to current date. Useful when historical=true to restrict the historical series period. sortBy: Type: string Optional: Yes Default: "date" Values: "date" | "value" Description: Field by which results will be ordered. Defaults to 'date'. sortOrder: Type: string Optional: Yes Default: "desc" Values: "asc" | "desc" Description: Defines whether the order will be ascending (asc) or descending (desc). Defaults to 'desc'. token: Type: string Required: Yes (if not in Authorization header) Description: Your personal Brapi API authentication token. Can be sent as a query parameter (?token=YOUR_TOKEN) or HTTP header (Authorization: Bearer YOUR_TOKEN). At least one method must be used. Obtain your token at brapi.dev/dashboard. ``` -------------------------------- ### API Endpoint: Get Stock Quotes, Dividends, and Financial Data Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes_list.md Documentation for retrieving stock quotes, dividends, and comprehensive financial data for available stocks on the brapi platform. This endpoint provides detailed information essential for market analysis and investment tracking. ```APIDOC GET /stocks Description: Retrieve quotes, dividends, and financial data for available stocks on brapi. ``` -------------------------------- ### API Endpoint: Get Detailed Financial Asset Data Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes.md This endpoint is the primary method to obtain detailed information about one or more financial assets (stocks, FIIs, ETFs, BDRs, indices) listed on B3, identified by their respective tickers. It supports current quotes, historical data, fundamental data, dividends, and additional modules. ```APIDOC GET /api/quote/{tickers} Description: Main endpoint to get detailed information about one or more financial assets (stocks, FIIs, ETFs, BDRs, indices) listed on B3. Authentication: Required. Via query parameter 'token' or 'Authorization: Bearer your_token' header. Functionalities: - Current Quote: Latest price, daily variation, highs, lows, volume. - Historical Data: Request historical price series using 'range' and 'interval' parameters. - Fundamental Data: Optionally include basic fundamental data (P/L, EPS) with 'fundamental=true'. - Dividends: Optionally include dividend and JCP history with 'dividends=true'. - Additional Modules: Request deeper financial datasets via the 'modules' parameter. Parameters: - tickers (path): string. Comma-separated list of asset tickers (e.g., PETR4,VALE3). - token (query/header): string. Your authentication token. (Required) - range (query): string. Historical data range (e.g., 1mo, 1y). - interval (query): string. Historical data interval (e.g., 1d, 1wk). - fundamental (query): boolean. Set to 'true' to include basic fundamental data. - dividends (query): boolean. Set to 'true' to include dividend history. - modules (query): string. Comma-separated list of additional data modules (e.g., summaryProfile,balanceSheetHistory). ``` -------------------------------- ### API Error Response: Invalid SortBy Field Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes_list.md Shows an API error response when an invalid 'sortBy' parameter is provided in the request. The message lists the valid options for sorting, such as name, close, change, and market cap, guiding the user to correct their query. ```json { "error": true, "message": "Campo 'sortBy' inválido. sortBy válidos: name, close, change, change_abs, volume, market_cap_basic, sector" } ``` -------------------------------- ### brapi API: General Introduction Endpoint Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes.md Provides an overview and general introduction to the brapi API. ```APIDOC Endpoint: /docs Method: GET Description: General introduction to the brapi API. ``` -------------------------------- ### brapi.dev API Core Concepts and Usage Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md Outlines fundamental concepts for interacting with the brapi.dev API, including the base URL, how to query multiple assets in a single request, and the use of the `modules` parameter for additional data. ```APIDOC Core Concepts: Base URL: All requests use the base URL https://brapi.dev/api. Multiple Assets: Most endpoints allow querying multiple assets by separating tickers with commas (e.g., PETR4,VALE3,MGLU3). Additional Modules: Use the 'modules' parameter to enrich responses with fundamental data and more (available based on your plan). ``` -------------------------------- ### API Authentication Methods and Best Practices Source: https://github.com/comnextoficial/documenta-oes/blob/main/index.md Outlines the recommended methods for authenticating requests to the brapi.dev API, emphasizing the use of the `Authorization` header for security. It also includes a note on client-side token exposure and advises against exposing tokens on the client-side. ```HTTP Header Authorization: Bearer SEU_TOKEN ``` ```Query Parameter ?token=SEU_TOKEN ``` -------------------------------- ### List All Available Fiat Currencies (brapi.dev API) Source: https://github.com/comnextoficial/documenta-oes/blob/main/moedas_available.md This `curl` command retrieves a complete list of all fiat currencies supported by the brapi.dev API. It requires an authentication token, which should replace 'YOUR_TOKEN' in the URL. ```shell curl -X GET "https://brapi.dev/api/v2/currency/available?token=YOUR_TOKEN" ``` -------------------------------- ### brapi.dev API Authentication Methods Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md Explains the recommended authentication methods for the brapi.dev API, primarily via the `Authorization` header with a Bearer token, and an alternative using a query parameter. Emphasizes the importance of not exposing the token client-side. ```APIDOC Authentication: Recommended Method: Header Header Name: Authorization Value: Bearer SEU_TOKEN Alternative Method: Query Parameter Parameter Name: token Value: SEU_TOKEN Security Warning: Never expose your token in client-side code (frontend). For web applications, make API calls from your backend. ``` -------------------------------- ### API Endpoints: Inflation (Inflação) Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md Overview of available API endpoints for retrieving inflation data and listing all available countries for inflation data. ```APIDOC GET /api/inflation/{country} Description: Get inflation data for a specific country. Path Parameters: country (string): The country code. GET /api/inflation/available Description: List all available countries for inflation data. ``` -------------------------------- ### API Endpoints: Currencies (Moedas) Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md Overview of available API endpoints for retrieving currency quotes and listing all available currencies. ```APIDOC GET /api/currency/{symbol} Description: Get quote for a specific currency. Path Parameters: symbol (string): The currency symbol. GET /api/currency/available Description: List all available currencies. ``` -------------------------------- ### API Endpoints: Basic Interest Rate (SELIC) Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md Overview of available API endpoints for retrieving the basic interest rate (SELIC) and listing all available countries for SELIC data. ```APIDOC GET /api/selic/{country} Description: Get basic interest rate (SELIC) for a specific country. Path Parameters: country (string): The country code. GET /api/selic/available Description: List all available countries for SELIC data. ``` -------------------------------- ### Search Fiat Currencies by Name (brapi.dev API) Source: https://github.com/comnextoficial/documenta-oes/blob/main/moedas_available.md This `curl` command filters the list of available fiat currencies to include only those whose names contain 'Euro', demonstrating the `search` query parameter. An authentication token is required, replacing 'YOUR_TOKEN'. ```shell curl -X GET "https://brapi.dev/api/v2/currency/available?search=Euro&token=YOUR_TOKEN" ``` -------------------------------- ### API Endpoints: Cryptocurrencies (Criptomoedas) Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md Overview of available API endpoints for retrieving cryptocurrency quotes and listing all available cryptocurrencies. ```APIDOC GET /api/crypto/{symbol} Description: Get quote for a specific cryptocurrency. Path Parameters: symbol (string): The cryptocurrency symbol. GET /api/crypto/available Description: List all available cryptocurrencies. ``` -------------------------------- ### Explore brapi.dev API Data Endpoints Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md A categorized list of the main data endpoints available through the brapi.dev API, covering financial instruments like stocks, cryptocurrencies, currencies, and economic indicators such as inflation and the SELIC rate. ```APIDOC Available Endpoints: Stocks and Funds: Obtain quotes, historical data, dividends, and fundamentals for Stocks, FIIs, ETFs, and BDRs. Cryptocurrencies: Access quotes and information for major market cryptocurrencies. Currencies (Exchange): Consult updated exchange rates for over 50 currency pairs. Inflation: Access historical series of inflation indicators like IPCA and IGP-M. SELIC Rate: Consult the historical series of Brazil's basic interest rate. ``` -------------------------------- ### API Endpoints: Stocks (Ações) Source: https://github.com/comnextoficial/documenta-oes/blob/main/https___brapi.dev_docs.md Overview of available API endpoints for retrieving stock-related data, including quotes, dividends, financial data, and a list of all available stocks. ```APIDOC GET /api/quote/{symbol} Description: Get quote, dividends, and financial data for a specific stock. Path Parameters: symbol (string): The stock symbol (e.g., PETR4). GET /api/quote/list Description: Get quotes for all available stocks. ``` -------------------------------- ### API Error Response: Rate Limit Exceeded Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes.md JSON response indicating that the user has exceeded the request limit for their current plan, suggesting an upgrade. ```JSON { "error": true, "message": "Você atingiu o limite de requisições para o seu plano. Por favor, considere fazer um upgrade para um plano melhor em brapi.dev/dashboard" } ``` -------------------------------- ### API Error Response: Stock Not Found Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes.md JSON response when a requested stock symbol (e.g., 'G3X') is not found by the API. ```JSON { "error": true, "message": "Não encontramos a ação G3X" } ``` -------------------------------- ### API Response Schema: Available Countries (200 OK) Source: https://github.com/comnextoficial/documenta-oes/blob/main/inflacao_available.md Defines the successful response body for the endpoint listing available countries. It includes a list of country names in lowercase. TypeScript definitions are also available for this structure. ```APIDOC countries: array Lista de nomes de países (em minúsculas) para os quais há dados de inflação disponíveis (ex: `brazil`, `usa`, `argentina`). ``` ```JSON { "countries": [ "brazil" ] } ``` -------------------------------- ### API Response Schema: Country Not Found (404) Source: https://github.com/comnextoficial/documenta-oes/blob/main/inflacao_available.md Defines the error response body specifically when no country is found matching the search criteria. It provides a concise error message. TypeScript definitions are also available. ```APIDOC message: string ``` ```JSON { "message": "Country not found" } ``` -------------------------------- ### API Response Schema: Generic Error (401/404) Source: https://github.com/comnextoficial/documenta-oes/blob/main/inflacao_available.md Defines the standard error response body for API requests, indicating if an error occurred and providing a descriptive message. This schema is used for various error conditions like invalid tokens. TypeScript definitions are also available. ```APIDOC error: Required boolean Indica se a requisição resultou em erro. Sempre `true` para este schema. message: Required string Mensagem descritiva do erro ocorrido. ``` ```JSON { "error": true, "message": "O seu token é inválido, por favor, verifique o seu token em brapi.dev/dashboard" } ``` -------------------------------- ### API Error Response: Invalid Range Parameter Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes.md JSON response for an API request with an invalid 'range' parameter, listing valid options for the user. ```JSON { "error": true, "message": "Campo 'range' inválido. Ranges válidos: 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max" } ``` -------------------------------- ### API Error Response: Invalid Authentication Token Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes.md JSON response for an API request with an invalid or expired authentication token, prompting the user to verify their token. ```JSON { "error": true, "message": "O seu token é inválido, por favor, verifique o seu token em brapi.dev/dashboard" } ``` -------------------------------- ### API Error Response: Invalid Token Source: https://github.com/comnextoficial/documenta-oes/blob/main/acoes_list.md Demonstrates an API error response indicating an invalid authentication token, prompting the user to verify it on the brapi.dev dashboard. This error typically occurs when the provided token is missing or incorrect, preventing access to protected resources. ```json { "error": true, "message": "O seu token é inválido, por favor, verifique o seu token em brapi.dev/dashboard" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.