Download the PHP package goteborgco/open-api-php-client without Composer
On this page you can find all versions of the php package goteborgco/open-api-php-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download goteborgco/open-api-php-client
More information about goteborgco/open-api-php-client
Files in goteborgco/open-api-php-client
Package open-api-php-client
Short Description Official PHP client library for interacting with the Göteborg & Co GraphQL API
License MIT
Informations about the package open-api-php-client
Göteborg & Co API Client for PHP
Official PHP client library for interacting with the Göteborg & Co GraphQL API. This package provides a type-safe interface for accessing Göteborg & Co's API, offering both structured methods for common operations and flexible GraphQL query capabilities.
Features
- Type-safe methods for common operations (guides, events, places, search and taxonomies)
- Direct GraphQL query support for advanced use cases
- Built-in error handling and response parsing
- Comprehensive documentation and examples
Requirements
Installation
Install the package via composer:
Setup
Initialize the API Client with your API URL and subscription key:
Usage
Type-Specific Methods
While the general query method provides full flexibility, the API also includes type-specific methods for common operations. These methods provide:
- Type safety with proper PHP classes for each entity type
- Simpler parameter handling
- Structured field selection
- Default values for common use cases
- Full IDE support with autocompletion
Entity Types
The following entity types are available:
-
WpEntity
: Base entity for guides, events, and placesgetId(): int
- Get the WordPress post IDgetDate(): ?string
- Get the creation date in ISO 8601 formatgetModified(): ?string
- Get the last modification date in ISO 8601 formatgetType(): ?string
- Get the content type (e.g., 'event', 'place', 'guide')getLink(): ?string
- Get the public URL of the content itemgetTitle(): ?string
- Get the content titlegetContent(): ?string
- Get the main content (may contain HTML)getExcerpt(): ?string
- Get a brief summary of the contentgetCategories(): array
- Get array of category IDsgetAreas(): array
- Get array of area IDsgetTags(): array
- Get array of tag IDsgetInvisibleTags(): array
- Get array of invisible tag IDs (for internal use)getLang(): string
- Get the language code ('en'|'sv')getTranslations(): ?Translations
- Get available translationsgetFeaturedMedia(): Media[]
- Get array of featured media objectsgetCategoryHeading(): ?string
- Get optional category headinggetGallery(): Media[]
- Get array of gallery media objectsgetContact(): ?Contact
- Get contact informationgetLocation(): ?Location
- Get location informationisFree(): ?bool
- Check if admission is free (for events)getDates(): EventDate[]
- Get array of event datesgetPlaceId(): ?int
- Get associated place ID (for events)getClassification(): ?int
- Get classification valuegetCurrentInTime(): ?CurrentInTime
- Get temporal availability information
-
Location
: Location informationgetAddress(): ?string
- Get complete address stringgetLat(): ?float
- Get latitude coordinategetLng(): ?float
- Get longitude coordinategetZoom(): ?int
- Get default map zoom levelgetPlaceId(): ?string
- Get Google Places IDgetName(): ?string
- Get location/establishment namegetStreetNumber(): ?string
- Get street numbergetStreetName(): ?string
- Get street namegetState(): ?string
- Get state/regiongetPostCode(): ?string
- Get postal codegetCountry(): ?string
- Get full country namegetCountryShort(): ?string
- Get two-letter country code (ISO 3166-1 alpha-2)
-
Media
: Media assetsgetId(): int
- Get media item IDgetCredit(): ?string
- Get attribution informationgetCaption(): ?string
- Get media descriptiongetAltText(): ?string
- Get alternative text for accessibilitygetMediaType(): ?string
- Get type of media (e.g., 'image', 'video')getMimeType(): ?string
- Get MIME type of the media filegetSizes(): ?MediaSizes
- Get available size variations
-
MediaSizes
: Image size variantsgetMedium(): ?Image
- Get medium size versiongetThumbnail(): ?Image
- Get thumbnail versiongetLarge(): ?Image
- Get large size versiongetFull(): ?Image
- Get full/original size version
-
Image
: Individual image propertiesgetWidth(): int
- Get width in pixelsgetHeight(): int
- Get height in pixelsgetSourceUrl(): string
- Get URL where the image can be accessed
-
Contact
: Contact informationgetEmail(): ?string
- Get contact email addressgetPhone(): ?string
- Get contact phone numbergetWebsite(): ?string
- Get website URLgetFacebook(): ?string
- Get Facebook profile/page URLgetInstagram(): ?string
- Get Instagram profile URL
-
EventDate
: Date range for eventsgetStart(): ?string
- Get start date in ISO 8601 formatgetEnd(): ?string
- Get end date in ISO 8601 format
-
CurrentInTime
: Temporal availability informationgetMonths(): array
- Get array of month numbers (1-12) when item is activegetWeekdays(): array
- Get array of weekday numbers (0-6) when item is active
-
Features
: GeoJSON FeaturegetType(): string
- Get GeoJSON object typegetGeometry(): Geometry
- Get geometric datagetProperties(): Properties
- Get feature properties
-
Geometry
: GeoJSON geometrygetType(): string
- Get geometry type (e.g., 'Point', 'LineString', 'Polygon')getCoordinates(): array
- Get coordinates in GeoJSON formatgetLatitude(): ?float
- Get latitude (for Point geometries)getLongitude(): ?float
- Get longitude (for Point geometries)
-
Properties
: GeoJSON feature propertiesgetName(): string
- Get feature display namegetId(): int
- Get unique identifiergetIcon(): string
- Get icon URL/identifiergetThumbnail(): string
- Get thumbnail image URLgetType(): string
- Get feature classification typegetSlug(): string
- Get URL-friendly identifier
-
Markers
: GeoJSON FeatureCollectiongetType(): string
- Get GeoJSON object type (typically 'FeatureCollection')getFeatures(): Features[]
- Get array of Feature objects
-
Related
: Related content collectiongetPlaces(): WpEntity[]
- Get array of related place entitiesgetGuides(): WpEntity[]
- Get array of related guide entitiesgetEvents(): WpEntity[]
- Get array of related event entities
Translations
: Content translationsgetSv(): ?int
- Get ID of Swedish content versiongetEn(): ?int
- Get ID of English content version
Listing Guides
List guides using GraphQL field selection:
Getting a Single Guide
Retrieve a specific guide:
Error Handling
The API uses exception handling for errors. Wrap your API calls in try-catch blocks:
Places
The API provides methods to list places and retrieve individual places by ID. All responses are mapped to proper PHP classes for type safety.
Listing Places
List places with field selection:
Getting a Single Place
Events
The API provides methods to list events and retrieve individual events by ID. Events include support for date filtering and sorting.
Listing Events
Getting a Single Event
Search
Taxonomies
The API provides methods to list all available taxonomies. This is useful for getting an overview of all taxonomy types in the system.
Taxonomy
The API provides methods to list all terms within a specific taxonomy. Terms can be retrieved either as a flat list or as a hierarchical tree structure based on parent-child relationships.
Listing Taxonomy Terms (Flat)
Listing Taxonomy Terms (Hierarchical)
When working with hierarchical taxonomies like categories, you can retrieve terms in a tree structure:
Notes
- Empty fields are not allowed and will throw an
InvalidArgumentException
- Related content is only available when retrieving a single guide using
getById
- All dates are in ISO 8601 format
- All entity classes provide proper type hints for IDE support
- Nested objects are automatically mapped to their corresponding classes
Array Structure for Fields
As an alternative to GraphQL strings, you can also specify fields using an array structure. This can be useful when building queries dynamically:
General GraphQL Queries
The API provides a general-purpose query method for executing any GraphQL query. This method accepts raw GraphQL syntax and returns the unprocessed API response:
Query Structure
The query method expects a complete GraphQL query string. The query must:
- Start with the
query
keyword - Include any necessary filters in the GraphQL syntax
- Specify all required fields and nested structures
Examples of valid queries:
Error Handling
The query method will throw exceptions for:
- Empty queries
- Invalid GraphQL syntax
- API errors
Always wrap query calls in try-catch blocks:
This array structure will be automatically converted to the equivalent GraphQL fields string internally.