ams-sdk is a wrapper around ams-api and handles the authentification and query process in just a few steps.
Please refer to AMS API documentation for a detailed description of the API endpoints, including parameters specification.
-
Easy Queries: Query from all AMS API endpoints in two lines of Python code
-
Authentication: SDK takes care of the full authentication process, with just your API key required (given by AMS)
From PyPI (recommended):
pip install ams-sdkAlternatively, directly from repo:
pip install git+https://github.com/alternative-macro-signals/ams-sdk.gitThe following dependencies are necessary to use this SDK:
Python 3.7or higher (likely to work with 3+ but not tested)requests>=2.0.0(installed automatically if needed)
First, initialize the AMSClient with the service URL and API key provided by AMS.
from ams_sdk.client import AMSClientclient = AMSClient(service_url=SERVICE_URL, api_key=API_KEY)Call the authenticate() method to fetch the bearer token required for further requests:
client.authenticate()Use the query_endpoint method to query specific AMS API endpoints:
result = client.query_endpoint("/nbstat", params={
"location": "Japan",
"txt": "rice",
"start": "2023-01-01",
"end": "2025-06-01"
})
print(result)result = client.query_endpoint("/nipi", params={
"location": "China",
"sector": "Food",
})
print(result)Note: see /nbstat
and /nipi endpoints documentations for accepted parameters details.
Transform the /nbstat or /nipi output in a Pandas dataframe:
import pandas as pd
df = pd.DataFrame(result.get('content'))
df['date'] = pd.to_datetime(df['date'])
df = df.set_index('date')
df.sort_index(inplace=True)In order to get 7-day and 30-day rolling balances from /nbstat (similar to the NewsBot app):
df7 = df.rolling(7).mean()
df30 = df.rolling(30).mean()Note: NIPI is already a 30-day rolling diffusion index.
Retrieve Inflation News Balance and News Volumes associated with specific text queries.
Download NIPI data.
📧: support@alternativemacrosignals.com
client.py: Contains theAMSClientclass which offers the core functionality for interacting with the API.utils.py:AMSClientusage examples.setup.py: Handles package configuration and installation details.README.md: Documentation for theams-sdk.
This project is licensed under the MIT License. See the LICENSE file for details.
- Author: Laurent Bilke - laurent@alternativemacrosignals.com
- Repository: GitHub
© 2025 Alternative Macro Signals. All rights reserved. https://alt.ms ![]()