API v1.0

Events API

To get access to published events with filtering options by date, category and city, please use this section of the documentation.

If you are interested in other functionality or need pagination, authentication or webhooks, please contact the development team.

How to make an API call

API call

https://esercitazioni.online/api/?date=YYYY-MM-DD&city=NomeCittà

Parameters

Parameter Required Description
date optional Filter events that start or end on this date. Format: YYYY-MM-DD (e.g. 2024-12-25). Must match regex ^\\d{4}-\\d{2}-\\d{2}$
category optional Filter by event category/ambito name (e.g. Musica, Teatro). Max length: 80 characters
city optional Filter by venue city name (e.g. Roma, Milano). Max length: 80 characters
All parameters are optional. If no parameters are provided, the API returns all events ordered by start date (ascending). Parameters can be combined. Order in query string does not matter.

Example of API call

If you want to filter events by date and city only:

https://esercitazioni.online/api/?date=YYYY-MM-DD&city=NomeCittà

If you want to filter by all three parameters:

https://esercitazioni.online/api/?date=YYYY-MM-DD&category=NomeCategoria&city=NomeCittà

If you do not need to filter and want to retrieve all events:

https://esercitazioni.online/api/

Example of API response

To view the API response, expand the example by clicking the triangle.

{
  "events": [
    {
      "id": 123,
      "name": "Concerto di Estate",
      "description": "Una serata di musica dal vivo con artisti emergenti...",
      "category": "Musica",
      "startDateTime": "2024-08-10T20:00:00",
      "endDateTime": "2024-08-10T23:30:00",
      "issueDateTime": "2024-07-01T10:00:00",
      "media": [
        {
          "id": 45,
          "name": "locandina.jpg",
          "type": "image/jpeg",
          "url": "https://cdn.esercitazioni.online/media/locandina.jpg"
        }
      ],
      "venue": {
        "id": 78,
        "name": "Arena Comunale",
        "address": {
          "street": "Via Roma 10",
          "city": "Milano",
          "province": "MI"
        }
      },
      "contact": {
        "email": "info@arena.it",
        "phone": "+39 02 1234567"
      }
    }
  ]
}

Fields in API response

If you do not see some of the parameters in your API response it means that these data are not available for the chosen event. Only really stored or calculated data is displayed in API response.
  • events — Array of event objects matching the applied filters
  • events[].id — Integer. Unique event identifier
  • events[].name — String. Event title
  • events[].description — String or null. Event description text
  • events[].category — String or null. Category/ambito name
  • events[].startDateTime — String (ISO 8601). Event start: YYYY-MM-DDTHH:mm:ss
  • events[].endDateTime — String (ISO 8601). Event end: YYYY-MM-DDTHH:mm:ss
  • events[].issueDateTime — String (ISO 8601). Publication time: YYYY-MM-DDTHH:mm:ss
  • events[].media — Array. List of multimedia assets
    • media[].id — Integer. Unique media identifier
    • media[].name — String. Original filename
    • media[].type — String. MIME type (e.g. image/jpeg)
    • media[].url — String. Public URL to access the file
  • events[].venue — Object. Venue information
    • venue.id — Integer or null. Unique venue identifier
    • venue.name — String or null. Venue name
    • venue.address — Object. Address details
      • address.street — String or null
      • address.city — String or null
      • address.province — String or null (e.g. MI, RM)
  • events[].contact — Object. Contact for inquiries
    • contact.email — String or null
    • contact.phone — String or null
Fields with null value indicate that the data is not available in the database for that specific event.

HTTP Methods & Status Codes

Supported methods

Method Description
GET Retrieve events list. This is the only supported method for data retrieval
OPTIONS CORS preflight request. Returns 204 No Content with appropriate CORS headers

Status Codes

Code Meaning When it occurs
200 OK Request processed successfully, events returned
405 Method Not Allowed Attempt to use POST, PUT, DELETE, PATCH, etc.
422 Unprocessable Entity date format incorrect, or category/city exceeds 80 characters

Example of error responses

Invalid date format

GET /api/?date=25-12-2024
{
  "error": "Invalid date format. Use YYYY-MM-DD"
}

Parameter too long

{
  "error": "Category too long"
}

Unsupported HTTP method

{
  "error": "Method not allowed"
}

CORS & Security Headers

Access-Control-Allow-Origin is dynamically set based on server configuration ($cfg['api']['allowed_origin']). If the request Origin header matches the configured value, CORS is enabled for that domain.

Response headers

Content-Type: application/json; charset=UTF-8
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: no-referrer
Access-Control-Allow-Methods: GET, OPTIONS
Access-Control-Allow-Headers: Authorization, Content-Type

Quick Start Examples

cURL

# Tutti gli eventi
curl "https://esercitazioni.online/api/"

# Esempio reale: ricerca evento "Porte aperte all'ITSOS Marie Curie (Open Day)" per data, categoria e città
curl -G "https://esercitazioni.online/api/" \
    --data-urlencode "date=2023-11-25" \
    --data-urlencode "category=open day" \
    --data-urlencode "city=Cernusco sul Naviglio" \
    -H "Accept: application/json"

JavaScript (Fetch API)

const params = new URLSearchParams({
    date: '2023-11-25',
    category: 'open day',
    city: 'Cernusco sul Naviglio'
});

const response = await fetch(
    `https://esercitazioni.online/api/?${params.toString()}`,
    { headers: { 'Accept': 'application/json' } }
);

const data = await response.json();
console.log(data.events);

Python (requests)

import requests

url = "https://esercitazioni.online/api/"
params = {
    "date": "2023-11-25",
    "category": "open day",
    "city": "Cernusco sul Naviglio"
}

response = requests.get(
    url,
    params=params,
    headers={"Accept": "application/json"}
)
data = response.json()

for event in data.get("events", []):
    print(f"{event['name']} - {event['venue']['address']['city']}")

Technical Notes & FAQ

Ordering: Events are always returned in ascending order by startDateTime.
Encoding: All text fields use UTF-8. Date/time fields follow ISO 8601: YYYY-MM-DDTHH:mm:ss. Special characters in query parameters must be URL-encoded.
Empty results: If no events match the filters, the API returns {"events": []} with HTTP 200 (not an error).
Media handling: The media field is always an array. If no media is associated, it returns [] (never null).

FAQ

  • Q: Is authentication required?
    A: No. The API is publicly accessible. Rate limiting and authentication can be added on request.
  • Q: Can I filter by date range?
    A: Not currently. The date parameter accepts a single date and matches events that start OR end on that date. For range filtering, please contact the development team.
  • Q: How are events without a category handled?
    A: The category field will be null in the response.
  • Q: Is the data real-time?
    A: Yes. The API queries the database directly. Newly published events may take a few seconds to appear depending on database replication or caching layers.