Listing Open Sessions¶
The most basic type of interaction is to list existing market sessions. Specifically, to check if there is any open market session available at this moment.
API Endpoints¶
To interact with the Predico API and retrieve information about open market sessions, you can use the following endpoint:
- GET
/api/v1/market/session- Retrieve list of market sessions (you can filter by 'open' sessions with query parameters)
Access Token Required
An access token must be included in the Authorization header of your request. If you haven't obtained an access token yet, please refer to the Authentication section.
Retrieving Currently Open Sessions¶
Here's how you can retrieve the current open market sessions using Python:
Tip: How to preview previous sessions
- To preview every market session registered in this platform, simply remove all the query parameters in the request URL.
import requests
# Predico instance URL. Switch BASE_URL to the environment you want to use:
# - Playground: https://playground.predico.inesctec.pt
# - Production: https://predico.inesctec.pt
BASE_URL = "https://predico.inesctec.pt"
API_URL = f"{BASE_URL}/api/v1"
access_token = "your_access_token_here"
headers = {
'Authorization': f'Bearer {access_token}',
'Accept': 'application/json'
}
response = requests.get(
url=f"{API_URL}/market/session",
params={"status": "open"},
headers=headers,
timeout=30
)
# Check if the request was successful
if response.status_code == 200:
market_sessions = response.json()
print(market_sessions)
else:
print(f"Failed to retrieve market sessions.")
print(f"Status code: {response.status_code}")
Expected Response¶
After making the request, you will receive a response containing a list of open market sessions.
It's important to verify whether the response contains any data, as there may be times when no sessions are open.
A new market session opens every hour on the hour, with gate closure at the top of the next hour (HH:00 CET). If the response is empty, retry shortly — at most one hour later a new session will be open.
JSON Example Response¶
Click to view Example Response
gate_closure field
The gate_closure field indicates the deadline (in UTC) by which all forecasts must be submitted for this session. Submissions received after this timestamp will not be considered for evaluation.