Getting Started
HAL Response Format
The Cineamo API uses HAL (Hypertext Application Language) for all responses.
What is HAL?
HAL provides a consistent way to hyperlink between resources. It makes APIs self-documenting and discoverable.
Key Principles:
- Resources have their own URLs (
_links.self) - Related data is embedded (
_embedded) - Navigation is built-in (next, prev, first, last pages)
- Hypermedia-driven discoverability
Official Spec: HAL Specification
🎯 Why HAL?
Benefits:
- Self-documenting - Links show what's possible
- Consistency - Same structure everywhere
- Built-in pagination
- Each resource has a canonical URL
- Easy API evolution without breaking clients
Comparison
Traditional JSON:
Code
HAL:
Code
🏗️ HAL Structure
Every HAL response has these elements:
1. Resource Properties
Direct properties (not prefixed with _):
Code
2. _links - Hypermedia Links
Links to related resources and navigation:
Code
3. _embedded - Related Resources
Embedded collections or related data:
Code
4. Pagination Metadata
Cineamo extends HAL with pagination fields:
Code
📦 Collection Response Example
Code
Key Points:
- Collection name matches resource type:
cinemas,showings - Each item has its own
_links.self - Pagination links at root level
- Metadata at root:
_total_items,_page,_page_count
🎬 Single Resource Example
Code
With Embedded Resources
When using embed[] parameters:
Code
🧭 Accessing HAL Data
Accessing Collections
Code
Following Links
Code
Accessing Embedded Resources
Code
⚠️ Common Pitfalls
❌ Accessing Data Directly
Code
❌ Assuming Flat Pagination
Code
❌ Ignoring Links
Code
🚀 Available Links
Common link relations in Cineamo API:
| Link | Description |
|---|---|
self | Current resource URL |
next | Next page in pagination |
prev | Previous page in pagination |
first | First page in pagination |
last | Last page in pagination |
📚 See Also
- PHP Array Parameters - Understanding array syntax in URLs
- Authentication - How to authenticate API requests
- Fetching Showtimes - Practical HAL usage examples
- API Reference - Complete endpoint documentation
Further Reading:
Last modified on

