Quickstart

This walkthrough covers discovery, values, reports, historical dates, formats, and saving. It assumes token.key is available locally and excluded from source control.

0. Verify the API in a browser

Before running Python, you can confirm that the production service is online with one known ticker. Open this template, replace YOUR_API_TOKEN in the browser address bar with your token, and reload:

https://api.pacificoindices.com/?token=<YOUR_API_TOKEN>&ticker=BTP0610456

A successful check returns JSON for BTP0610456. This browser form is intended only for a short interactive test: a completed query-token URL is sensitive and can remain in browser history or infrastructure logs. Use token.key and the Python client for the rest of this walkthrough.

1. Import and discover values

Calling request with only a token returns value metadata:

import pacifico

token_path = "token.key"
value_catalog = pacifico.request(token_path)

print(value_catalog.head())
print(value_catalog[["Scenario", "Market", "Group", "Family", "Ticker"]])

Use metadata rather than hard-coding assumptions about the data universe. Availability depends on the API catalog and the caller's access.

2. Request one ticker

bond = pacifico.request(
    token_path,
    ticker="BTP0610456",
)

print(bond)

The DataFrame has one row per returned field, such as price, yield, or duration. The exact rows depend on what is available for the ticker and filters.

3. Narrow the fields

price = pacifico.request(
    token_path,
    ticker="BTP0610456",
    fieldType="Price",
)

fieldType is a string. Unsupported strings silently become “unspecified,” so validate user input in your own application. See Values for every accepted field.

4. Request a historical range

from datetime import date, timedelta

end = date.today()
start = end - timedelta(days=7)

history = pacifico.request(
    token_path,
    ticker="CHILE",
    dateStart=start,
    dateEnd=end,
)

Use a ticker for multi-day history. Selector-dependent server rules can normalize broad or predictive requests; see Dates and history.

5. Discover and request reports

Set document="metadata" to select report metadata:

report_catalog = pacifico.request(
    token_path,
    document="metadata",
)

entity_reports = pacifico.request(
    token_path,
    item="97004000-5",
)

balance_sheet = pacifico.request(
    token_path,
    document="Balance Sheet",
    item="96800570-7",
)

Any report selector changes the request route from values to reports. Report values are typed and expose their type in the Value Type DataFrame column.

6. Choose a return format

as_frame = pacifico.request(
    token_path,
    ticker="BTP0610456",
    format="dataFrame",
)

as_dict = pacifico.request(
    token_path,
    ticker="BTP0610456",
    format="dictionary",
)

as_json = pacifico.request(
    token_path,
    ticker="BTP0610456",
    format="json",
)

Use:

  • dataFrame or df for analysis;
  • dictionary or dict for Python-native traversal;
  • json for exact payload preservation and diagnostics.

7. Save during the request

pacifico.request(
    token_path,
    ticker="BTP0610456",
    fileName="outputs/bond_snapshot",
    format="dataFrame",
)

This writes outputs/bond_snapshot.csv without an index. The parent directory must already exist. JSON and dictionary responses are written to .txt.

8. Make production behavior explicit

For services and scheduled jobs, pass dates, timeout, polling interval, and format explicitly:

from datetime import date

snapshot_date = date.today()

data = pacifico.request(
    token_path,
    ticker="CHILE",
    dateStart=snapshot_date,
    dateEnd=snapshot_date,
    timeOut=600,
    timeFrecuency=1.0,
    format="dataFrame",
)

Explicit dates avoid the import-time default-date behavior in long-running Python processes. Use pacifico.request reference as the contract checklist for shared wrappers.