Skip to main content

Python SDK for the Alternative Macro Signals API

Project description

AMS-SDK

Python Version License

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.


Features ✨

  • 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)


Installation 🛠️

From PyPI (recommended):

pip install ams-sdk

Alternatively, directly from repo:

pip install git+https://github.com/alternative-macro-signals/ams-sdk.git

Requirements 📋

The following dependencies are necessary to use this SDK:

  • Python 3.7 or higher (likely to work with 3+ but not tested)
  • requests>=2.0.0 (installed automatically if needed)

Usage 📖

Initialization

First, initialize the AMSClient with the service URL and API key provided by AMS.

from ams_sdk.client import AMSClient
client = AMSClient(service_url=SERVICE_URL, api_key=API_KEY)

Authentication

Call the authenticate() method to fetch the bearer token required for further requests:

client.authenticate()

Querying Endpoints

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)
# Query Entropy data (returns all 3 signs: p_neg, p_pos, p_neu)
result = client.query_endpoint("/nipi", params={
 "metric": "Entropy",
 "location": "US",
 "sector": "All",
 "start": "2024-01-01"
})

# Query single entropy sign
result = client.query_endpoint("/nipi", params={
 "metric": "Entropy",
 "location": "US",
 "sign": "p_pos"  # p_neg, p_pos, or p_neu
})

Note: see /nbstat and /nipi endpoints documentations for accepted parameters details.

Output

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.

Entropy output: When querying with metric=Entropy, the response contains 3 rows per date (one for each sign: p_neg, p_pos, p_neu) unless filtered with the sign parameter. The meta.metric_2 field identifies which sign each row represents.


API endpoints callable from AMSClient 🌐

/nbstat API Status

Retrieve Inflation News Balance and News Volumes associated with specific text queries.

/nipi API Status

Download NIPI, NVI, or Entropy data. Use the metric parameter to select:

  • NIPI (default): News Inflation Pressure Index (30-day rolling diffusion index)
  • NVI: News Volume Index
  • Entropy: Raw entropy values (building blocks of NIPI). Use sign parameter to filter: p_neg, p_pos, p_neu

We welcome suggestions! 💡

📧: support@alternativemacrosignals.com


Project Structure 📂

  • client.py: Contains the AMSClient class which offers the core functionality for interacting with the API.
  • utils.py: AMSClient usage examples.
  • setup.py: Handles package configuration and installation details.
  • README.md: Documentation for the ams-sdk.

License 📜

This project is licensed under the MIT License. See the LICENSE file for details.


Author


© 2025 Alternative Macro Signals. All rights reserved. https://alt.ms Alternative Macro Signals Logo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ams_sdk-1.0.8.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ams_sdk-1.0.8-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ams_sdk-1.0.8.tar.gz.

File metadata

  • Download URL: ams_sdk-1.0.8.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.3 Linux/6.17.0-1014-nvidia

File hashes

Hashes for ams_sdk-1.0.8.tar.gz
Algorithm Hash digest
SHA256 b3f90188861f9881a5db8ec7dbc86fc986cbf93d5935e29e36d527d27a5d1634
MD5 05f2e05e5fa50a9e6aada698ed81b862
BLAKE2b-256 75c226006f47e342a40584f1c25f56d26eaa26db525f2b085014908c5086129e

See more details on using hashes here.

File details

Details for the file ams_sdk-1.0.8-py2.py3-none-any.whl.

File metadata

  • Download URL: ams_sdk-1.0.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.12.3 Linux/6.17.0-1014-nvidia

File hashes

Hashes for ams_sdk-1.0.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 92e76f68a11282ba84eb58bf99bbc511f0794abdddb03a35c99b377265d4f2fb
MD5 0cc4775f3604a2eb9845fd2d6283b9af
BLAKE2b-256 d57d45863698c42b18461fc8d83832196aee1bb32d23560a155d8dbf6e2f1a2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page