Untitled Note

Of course. Moving from web scraping to a dedicated API (Application Programming Interface) is an excellent step for creating a more robust and reliable automation. An API provides structured data (usually in a format like JSON), which is much easier and more stable to work with in a script or a Shortcut than parsing raw HTML.


Based on my search, here are several public APIs and data sources that you can explore to programmatically access Canadian mutual fund pricing on your Apple devices.



Understanding the Landscape


While there are many financial data APIs, high-quality, real-time data often comes at a cost. However, several services offer "freemium" tiers that are perfectly suitable for personal use, providing end-of-day pricing for free or with generous limits.


The primary challenge will be confirming if a specific service has comprehensive coverage of the Canadian mutual fund codes you need (e.g., TDB900, CIG598, etc.).


Recommended API & Data Source Options


Here is a breakdown of potential services, from free/freemium to professional-grade.


1. EODHD (EOD Historical Data)

This is a strong candidate as it explicitly mentions mutual funds and offers a free plan. Their "All-World" packages suggest good international coverage.


Canadian Coverage: Likely, but you'll need to test your specific fund codes with their API. They often use a standardized format like FUNDCODE.CANADA.

Pricing: Offers a free API tier that is often sufficient for personal portfolio tracking (e.g., a certain number of API calls per day).

How to Use: You would sign up for a free API key and use it in an Apple Shortcut to call their data endpoint.

Website: EOD Historical Data - Mutual Funds API


2. Financial Modeling Prep (FMP)

FMP is another popular service with extensive data and a developer-friendly API.


Canadian Coverage: Good, but you should verify your specific funds. Their documentation will provide details on how to format tickers for Canadian securities.

Pricing: Also operates on a freemium model. The free plan provides a good number of daily requests for end-of-day data.

How to Use: Similar to EODHD, you get an API key and construct a URL to fetch the data for your fund.

Website: Financial Modeling Prep - Mutual Fund API


3. Fundata Canada Inc.

This is a specialized Canadian provider. If you need the most accurate and comprehensive Canadian data, this is likely the source, but it's geared towards professional and enterprise clients.


Canadian Coverage: Excellent. This is their specialty.

Pricing: Likely expensive and subscription-based. Probably not suitable for a personal project unless you require enterprise-grade data.

How to Use: They provide "Data Feeds" for their clients.

Website: Fundata Canada Inc.



How to Use an API with Apple Shortcuts


Using an API is a significant upgrade from the web scraping method. Instead of parsing messy HTML with Regex, you get clean, structured JSON.


Here’s the revised workflow for your Shortcut:


[ ] 1. Get an API Key:

Sign up for a free account with a service like EODHD or Financial Modeling Prep.

Find your personal API key in your account dashboard.


[ ] 2. Construct the API URL:

Read the service's documentation to find the correct URL structure. It will typically look something like this:

```

https://eodhd.com/api/real-time/TDB900.CAN?apitoken=YOURAPI_KEY&fmt=json

```

Use the URL action in Shortcuts to build this link, substituting your fund code and API key.


[ ] 3. Fetch the API Data:

Use the Get Contents of URL action. This will fetch the data from the API.


[ ] 4. Parse the JSON Data (The Easy Part):

The API will return data in JSON format, which looks like this:

```json

{

  "code": "TDB900.CAN",

  "timestamp": 1653163200,

  "gmtoffset": 0,

  "open": 45.18,

  "high": 45.25,

  "low": 45.15,

  "close": 45.21,

  "volume": 0,

  "previousClose": 45.18,

  "change": 0.03,

  "change_p": 0.0664

}

```

In Shortcuts, add the Get Dictionary from Input action.

Then, use the Get Value for Key action to pull the specific value you want, such as close. This is far more reliable than a Regex pattern.


[ ] 5. Format and Save:

From here, the process is the same as before: use Text and Append to File actions to save the date, fund code, and the extracted price to your CSV file in iCloud Drive.


Summary: Web Scraping vs. API


| Feature | Web Scraping (Previous Method) | Using an API (This Method) |

| :--- | :--- | :--- |

| Reliability | Low. Fails if the website's HTML layout changes. | High. The data structure is guaranteed to be consistent. |

| Complexity | Medium. Requires tricky Regular Expressions (Regex). | Low. Parsing JSON with Shortcut's dictionary actions is simple. |

| Cost | Free. | Freemium. Free for personal use, but may have daily limits. |

| Data Quality | Good, but unstructured. | Excellent, structured, and often includes more than just the price (e.g., daily change). |


For a robust and low-maintenance solution, leveraging a free API tier is the superior technical choice. It will make your automation more reliable and easier to manage in the long run.

Chunk Created with Chunk

Start thinking in

connected pieces.

Upgrade when you're ready.

No credit card required · Available on iOS, macOS, and Web