The Sentometrics BV is a data-as-a-service B2B company. All our data products and functionalities are available via a REST API, compliant to the OpenAPI 3.0 specification. The backbone is a serverless computing platform that uses an event-driven model allowing us to scale up on demand. Contact us for more information about plugging in our API into your business analytics pipelines.
As examples, we provide two public APIs currently servicing this website. Explore our APIs and their documentation:
These APIs are still under active development and likely to significantly change.
We welcome the use of our indices by researchers. Integrating Sentometrics' indices in your application has never been so easy. See below two sample scripts to retrieve an index using R and Python.
The list of publicly available indices is stored behind the /index
endpoint. Each thematic index possesses several variations.
R
# Load required libraries library(httr) library(data.table) # Retrieve list of indices from the API list_indices <- httr::GET( "https://api.sentometrics.com/public/timo/index" ) list_indices <- httr::content(list_indices) list_indices <- data.table::rbindlist(list_indices, fill=TRUE) head(list_indices, 3) #> id name friendly_name #> <int> <char> <char> #> 1: 2909 Unemployment_D_BE_NL Unemployment Attention Indicator #> 2: 2907 R_M_BE Recession Attention Indicator #> 3: 2908 Unemployment_D_BE_FR Unemployment Attention Indicator #> friendly_frequency source #> <char> <char> #> 1: Daily Flemish Newspapers #> 2: Monthly Belgian Newspapers #> 3: Daily French Newspapers
Python
# Load required libraries import requests import pandas as pd # Retrieve list of indices from the API list_indices = requests.get( "https://api.sentometrics.com/public/timo/index" ) list_indices = pd.DataFrame(list_indices.json()) print(list_indices.head()) #> id name friendly_name \ #> 0 2909 Unemployment_D_BE_NL Unemployment Attention Indicator #> 1 2907 R_M_BE Recession Attention Indicator #> 2 2908 Unemployment_D_BE_FR Unemployment Attention Indicator #> 3 2901 Inflation_D_BE_NL Inflation Attention Indicator #> 4 2892 ECOS_D_BE_FR Economic Sentiment Indicator #> #> friendly_frequency source #> 0 Daily Flemish Newspapers #> 1 Monthly Belgian Newspapers #> 2 Daily French Newspapers #> 3 Daily Flemish Newspapers #> 4 Daily French Newspapers
Indices are characterized by three variables: name (theme), frequency, and source. A combination of those identifies a single index.
R
## Select the economic sentiment index idx <- list_indices[ list_indices$friendly_name == "Economic Sentiment Indicator" & list_indices$friendly_frequency == "Daily" & list_indices$source == "Belgian Newspapers" ] idx #> id name friendly_name friendly_frequency #> <int> <char> <char> <char> #> 1: 2894 ECOS_D_BE Economic Sentiment Indicator Daily #> source #> <char> #> 1: Belgian Newspapers
Python
## Select the economic sentiment index idx = list_indices[ (list_indices["friendly_name"] == "Economic Sentiment Indicator") & (list_indices["friendly_frequency"] == "Daily") & (list_indices["source"] == "Belgian Newspapers") ] print(idx) #> id name friendly_name friendly_frequency \ #> 17 2894 ECOS_D_BE Economic Sentiment Indicator Daily #> #> source #> 17 Belgian Newspapers
An index is also identified by a unique id. Use the id in other API endpoints to retrieve the index's details. The /index/{id}/values
endpoint enables retrieving historical data.
R
## Retrieve historical values idx_values <- httr::GET( sprintf( "https://api.sentometrics.com/public/timo/index/%i/values?from_date=%s", idx$id, # index's ID "2000-01-01" # starting date of the series ) ) idx_values <- httr::content(idx_values) idx_values <- data.table::rbindlist(idx_values) idx_values$timestamp <- as.POSIXct(idx_values$timestamp) idx_values #> timestamp value #> <POSc> <num> #> 1: 2000-08-19 0.18547417 #> 2: 2006-10-10 0.82494410 #> 3: 2007-10-16 0.05662025 #> 4: 2007-10-17 0.07810647 #> 5: 2007-12-14 0.01181173 #> --- #> 7198: 2021-09-16 -0.27827084 #> 7199: 2021-10-11 -0.31325492 #> 7200: 2021-11-19 -0.07702471 #> 7201: 2021-12-08 -0.28865127 #> 7202: 2021-12-09 -0.27934582
Python
## Retrieve historical values idx_values = requests.get( "https://api.sentometrics.com/public/timo/index/{id}/values?from_date={from_date}".format( id=idx["id"].item(), # index's ID from_date="2000-01-01" # starting date of the series ) ) idx_values = pd.DataFrame(idx_values.json()) idx_values["timestamp"] = pd.to_datetime(idx_values["timestamp"]) print(idx_values) #> timestamp value #> 0 2000-08-19 0.185474 #> 1 2006-10-10 0.824944 #> 2 2007-10-16 0.056620 #> 3 2007-10-17 0.078106 #> 4 2007-12-14 0.011812 #> ... ... ... #> 7197 2021-09-16 -0.278271 #> 7198 2021-10-11 -0.313255 #> 7199 2021-11-19 -0.077025 #> 7200 2021-12-08 -0.288651 #> 7201 2021-12-09 -0.279346 #> #> [7202 rows x 2 columns]
Our data is standardized and ready for use. Feel free to use it in your research! Here is a quick example of visualizing the index.
R
# Visualizing the index plot(idx_values[order(timestamp)], type = "l")
Python
# Visualizing the index import matplotlib.pyplot as plt idx_values.set_index("timestamp").plot() #> <AxesSubplot:xlabel='timestamp'> plt.show()