Welcome to the Finance API, a service providing detailed information on stocks from markets worldwide. This API allows users to query specific stock data or obtain standardized details.
- Query data for any stock using various identifiers. For example, "btc", "BTC-USD", "BTC-BRL" for Bitcoin, or "facebook", "META", "META:NASDAQ" for Meta/Facebook stock. Identifiers are case-insensitive, meaning "btc", "Btc", and "BTC" will all return the same results.
- Access detailed information including price, currency, exchange, and a summary of the stock's background.
To query information on a specific stock, use the API endpoint as follows:
curl http://localhost:8080/api/v1/stock/<stockName>
Replace with the stock's identifier. For example, for Bitcoin, you can use btc, btc-usd, or btc-brl if you're interested in its value in Brazilian Real.
- Requesting Bitcoin Information Request:
curl http://localhost:8080/api/v1/stock/btc
Response:
{
"success": true,
"data": {
"name": "Bitcoin to United States Dollar",
"price": 39475.9,
"currency": "USD",
"exchange": "Cryptocurrency",
"about": "Bitcoin is the first decentralized cryptocurrency. Nodes in the peer-to-peer bitcoin network verify transactions through cryptography and record them in a public distributed ledger, called a blockchain, without central oversight.",
"link": "https://www.google.com/finance/quote/BTC-USD"
}
}
- Requesting Fundo Investimento Imobiliario Iridium Recebiveis Imobiliarios Information
Request:
curl http://localhost:8080/api/v1/stock/irdm11
Response:
{
"success": true,
"data": {
"name": "FI Imobiliario Iridium Recebiveis Imobiliarios",
"price": 76.74,
"currency": "BRL",
"exchange": "BVMF",
"about": "Founded in 2017, Iridium Recebiveis Imobiliarios focuses on real estate investments.",
"link": "https://www.google.com/finance/quote/IRDM11:BVMF"
}
}
The API provides informative error messages to assist in troubleshooting. Here are some examples of the error responses:
- When a stock name is invalid or not found:
{
"success": false,
"message": "Invalid stock name 123abcd"
}
- When the stock's information cannot be retrieved due to a processing error or if the stock is not found on the source site:
{
"success": false,
"message": "Stock not found at https://www.google.com/finance/quote/exampleStockName"
}
Ensure that your application handles these errors gracefully to improve user experience.