This, is an Application Programming Interface (API). A system that can receive requests from your computer,
to carry out given tasks on given
resources, and return a response.
An API is programming-language-agnostic: it can be used with Python, JavaScript, PHP, R, Go, C#, Ruby, Rust,
Java, MATLAB, Julia, and any other programming language speaking http
. Therefore, it could be
easily integrated into an existing workflow. What are resources and
requests here?
resources are Statistical/Machine Learning (ML) models forecasts. One type of request could be: I'd like to obtain sales, weather or revenues forecast for the next 5 weeks. In general though, requests do not have such a long description. They are rather characterized by a verb for action ( GET, PUT, POST, DELETE) and a short URL Path -- more precisely, an "endpoint" -- which both lead to a JSON (a simple dictionary, with keys and values) response. Every request for forecasts in this tool will be a POST request to an enpoint, with the ML model's additional parameters when necessary.
An endpoint will typically be spelled as: /api/theta
. "theta" is the Theta method, a powerful univariate
forecasting model that won the M3 competition a few years ago. There are/will be other forecasting models too, as you'll see in
the docs.
An important point to mention is: your csv input data is not kept/stored. They are deleted as soon as your request is over.
Below, is an example of use of the API from the command line. If you want to
translate these commands into
your favorite programming language (Python, JavaScript, PHP, R, Go, C#, Ruby, Rust,
Elixir, Java, MATLAB, Dart, CFML, Ansible URI, Strest), you can simply use the following
website: https://curlconverter.com/. Very useful.
Register:
curl -X POST -H "Content-Type: application/json" -d '{"username":"user@email.com","password":"password"}' https://techtonique2.herokuapp.com/api/users
You can actually use a username or an email address for registering. But a valid email address is preferable; usernames
duplicates aren't authorized in the database. Plus, without a valid email address, you won't be notified
for changes and improvements in the API (e.g new forecasting models added...) ;)
Obtain a token for authentication
(see next step below):
curl -u user@email.com:password -X GET https://techtonique2.herokuapp.com/api/token
Use the token to obtain your forecasts (examples of input files can be found at Techtonique/datasets/time_series/univariate),
10 months-ahead, and a confidence level of 80% for prediction intervals :
curl -u eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpOCsOC8-I:x -F 'file=@/Users/t/Documents/datasets/time_series/univariate/AirPassengers.csv' "https://techtonique2.herokuapp.com/api/theta?h=10&level=80"