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 Predicto 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.
Check this out
Check our Useful Links section for additional resources (Jupyter Notebook, API Specifications) to help you get started with the Predico platform.
Retrieving Current Open Sessions¶
Here's how you can retrieve the current open market sessions using Python:
import requests
access_token = "your_access_token_here"
headers = {
'Authorization': f'Bearer {access_token}',
'Accept': 'application/json'
}
response = requests.get(
url='https://predico-elia.inesctec.pt/api/v1/market/session',
params={"status": "open"},
headers=headers
)
# 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. Market sessions run periodically once a day, so if the response is empty, you may need to try again later.
JSON Example Response¶
Click to view Example Response
{
"code": 200,
"data": [
{
"id": 1,
"open_ts": "2024-06-24T09:19:23.251536Z",
"close_ts": null,
"launch_ts": null,
"finish_ts": null,
"status": "open"
}
]
}
What's next?¶
Learn how to list session challenges information on the Predico platform in the Listing Challenges section.