Getting started overview
Getting started with the Financial Modeling Prep (FMP) API involves a sequence of steps designed to provide access to its financial data endpoints. The process begins with account registration, followed by obtaining an API key. This key is central to authenticating all subsequent data requests. Once the key is acquired, developers can construct their first API call to retrieve financial information, such as real-time stock prices or historical financial statements. The API supports various programming languages and offers data in JSON and CSV formats, catering to different development environments and integration needs.
The FMP API is designed for developers building applications that require financial data for purposes such as financial analysis, algorithmic trading, or quantitative research. It provides access to a range of data, including stock market, forex, cryptocurrency, and economic indicators. The platform offers a free tier for initial exploration and testing, with paid plans available for increased request volumes and advanced features. Comprehensive documentation is available to guide users through the integration process, including detailed endpoint descriptions and code examples for common use cases.
| Step | What to do | Where |
|---|---|---|
| 1. Sign Up | Create a new user account | Financial Modeling Prep Developer Documentation |
| 2. Get API Key | Locate your unique API key in the dashboard | Financial Modeling Prep Dashboard (after login) |
| 3. Make Request | Construct and execute your first API call | Using a tool like cURL or a programming language (e.g., Python) |
| 4. Explore Docs | Review available endpoints and data models | Financial Modeling Prep API Reference |
Create an account and get keys
To begin using the Financial Modeling Prep API, you need to create an account and obtain your unique API key. This key authenticates your requests and grants access to the available data. The process is initiated by navigating to the Financial Modeling Prep developer documentation page.
- Visit the Financial Modeling Prep Website: Go to the official Financial Modeling Prep developer documentation page.
- Register for an Account: Look for a "Sign Up" or "Register" option. You will typically need to provide an email address and create a password. Some platforms may require email verification.
- Access Your Dashboard: After successful registration and login, you will be directed to your user dashboard. This is where you manage your account settings and API keys.
- Locate Your API Key: Within the dashboard, there should be a section specifically for API keys. Your unique API key will be displayed here. It is a long string of alphanumeric characters. Copy this key, as it will be required for every API request you make. The API key is critical for authenticating your requests and ensuring proper access control, a standard practice in API authentication methods.
It is important to keep your API key secure and avoid exposing it in client-side code or public repositories. If your key is compromised, you can usually regenerate it from your dashboard.
Your first request
After obtaining your API key, you can make your first request to the Financial Modeling Prep API. This example demonstrates how to retrieve the real-time quote for a specific stock ticker using a simple HTTP GET request. We will use the curl command-line tool for this example, which is widely available on most operating systems, and then provide a Python example for programmatic access.
Using cURL
The curl command allows you to make HTTP requests directly from your terminal. Replace YOUR_API_KEY with the actual API key you obtained from your dashboard and AAPL with the stock ticker you wish to query (e.g., MSFT, GOOG).
curl "https://financialmodelingprep.com/api/v3/quote/AAPL?apikey=YOUR_API_KEY"
This command sends a request to the FMP API's quote endpoint for Apple Inc. (AAPL). The API will return a JSON array containing real-time pricing information for the specified ticker. A successful response will look similar to this:
[
{
"symbol": "AAPL",
"name": "Apple Inc.",
"price": 170.12,
"changesPercentage": 0.5,
"change": 0.85,
"dayLow": 169.50,
"dayHigh": 171.20,
"yearHigh": 180.00,
"yearLow": 120.00,
"marketCap": 2700000000000,
"open": 169.70,
"previousClose": 169.27,
"eps": 6.13,
"pe": 27.75,
"earningsAnnouncement": "2024-07-25T16:00:00.000+0000",
"sharesOutstanding": 15800000000,
"timestamp": 1678886400
}
]
Using Python
For programmatic access, Python is a common choice due to its extensive libraries for making HTTP requests and parsing JSON. Ensure you have the requests library installed (pip install requests).
import requests
import json
API_KEY = "YOUR_API_KEY" # Replace with your actual API key
SYMBOL = "AAPL"
url = f"https://financialmodelingprep.com/api/v3/quote/{SYMBOL}?apikey={API_KEY}"
try:
response = requests.get(url)
response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
data = response.json()
print(json.dumps(data, indent=2))
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
This Python script performs the same request as the curl command, retrieves the data, and prints it in a formatted JSON output. This demonstrates a basic pattern for interacting with RESTful APIs, which often involves constructing a URL with parameters, making an HTTP GET request, and parsing the JSON response, as detailed in Mozilla's REST API guide.
Common next steps
After successfully making your first API call, consider these common next steps to further integrate and utilize the Financial Modeling Prep API:
- Explore More Endpoints: The FMP API offers a wide range of endpoints beyond basic quotes, including historical data, financial statements (income statement, balance sheet, cash flow), company profiles, forex data, and cryptocurrency data. Refer to the Financial Modeling Prep API reference for a complete list and detailed descriptions.
- Implement Error Handling: As you integrate the API into applications, implement robust error handling. This includes checking HTTP status codes (e.g., 401 for unauthorized, 404 for not found, 429 for rate limits, 500 for server errors) and parsing error messages from the API response.
- Manage Rate Limits: Be aware of the API's rate limits, which specify how many requests you can make within a given timeframe (e.g., 250 requests/day for the free tier). Implement a strategy to manage your request frequency, such as using exponential backoff for retries or caching data where appropriate, to avoid hitting limits.
- Choose a Paid Plan (if needed): If your application requires higher request volumes or access to premium data, review the Financial Modeling Prep pricing plans. Upgrade to a suitable plan that meets your project's demands.
- Utilize SDKs (if available): While FMP does not provide official SDKs, community-contributed libraries in languages like Python or JavaScript might exist to simplify API interaction. Search GitHub or relevant package managers for existing wrappers.
- Data Storage and Caching: For applications that frequently access the same data, consider implementing a caching mechanism to store data locally. This reduces API calls, improves application performance, and helps stay within rate limits.
- Build a Dashboard or Application: Start building a simple application or dashboard that consumes and visualizes the financial data. This practical application of the API will deepen your understanding and highlight further integration points.
Troubleshooting the first call
Encountering issues during your first API call is common. Here are some troubleshooting steps for typical problems when interacting with the Financial Modeling Prep API:
- Invalid API Key (HTTP 401 Unauthorized):
- Check for typos: Ensure your API key is copied exactly as it appears in your FMP dashboard, without extra spaces or characters.
- Key placement: Verify that the API key is correctly appended as a query parameter (
?apikey=YOUR_API_KEY) in your request URL. - Key status: Confirm your API key is active and has not expired or been revoked in your FMP account dashboard.
- Incorrect Endpoint or Parameters (HTTP 400 Bad Request, HTTP 404 Not Found):
- Review documentation: Double-check the Financial Modeling Prep API documentation for the exact endpoint URL and required parameters for the data you are trying to retrieve.
- Parameter values: Ensure that any parameters you are passing (e.g., stock ticker symbols, dates) are in the correct format and valid for the API.
- URL structure: Verify that the base URL and path segments are correctly formed.
- Rate Limit Exceeded (HTTP 429 Too Many Requests):
- Check usage: If you are on the free tier, you are limited to 250 requests per day. Monitor your dashboard for current usage.
- Wait and retry: If you hit the rate limit, wait for the specified period (e.g., the next day for daily limits) before making further requests.
- Upgrade plan: For higher volumes, consider upgrading to a paid plan, as detailed on the FMP pricing page.
- Network Issues:
- Internet connection: Ensure your device has a stable internet connection.
- Firewall/Proxy: If you are in a corporate network, a firewall or proxy might be blocking outbound requests. Consult your IT department or try making the request from a different network.
- Empty or Unexpected Response:
- Data availability: Some data might not be available for all tickers or timeframes. Check the documentation for data coverage.
- JSON parsing issues: If you are receiving a response but cannot parse it, ensure your code correctly handles JSON data. Use a JSON validator to inspect the raw response if necessary.