# Events

## Overview

This document is designed to provide developers with the necessary information to effectively use the Lemonade GraphQL API for creating full-suite web applications for IRL and virtual events . The API allows for querying, creating and manipulating event data, ensuring a seamless integration with the Lemonade backend.

This guide explains the GraphQL Query API that is used for the event flow.

### API Endpoints

* **Production**: <https://backend.lemonade.social/graphql>
* **Staging**: <https://backend.staging.lemonade.social/graphql>

Developers can also explore our API using the Apollo server at the same endpoints.

### Authentication

To authenticate with the Lemonade GraphQL API, use an OAuth2 access token. Include this token in the `authorization` the header of your requests:

```http
httpCopy codeheaders['authorization'] = 'Bearer [Your_OAuth2_Access_Token]';
```

### Making Requests

Requests to query or mutate data can be made to our GraphQL endpoints. Below are some common operations and their respective queries/mutations.

### Event Queries

* **getHostingEvents**: Retrieve a list of events hosted by a specific user.
* **getHomeEvents**: Fetch events based on location.
* **getMyEvents**: List events associated with the logged-in user.
* **getEvents**: List non-private events using advanced filters.

### Querying Hosting Events

Here is an example `curl` command to query hosting events:

```
bashCopy codecurl 'https://backend.lemonade.social/graphql' \
  -H 'authority: backend.lemonade.social' \
  -H 'authorization: Bearer [Your_OAuth2_Access_Token]' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'origin: https://app.popex.net' \
  -H 'pragma: no-cache' \
  -H 'referer: https://app.popex.net/' \
  -H 'sec-ch-ua: "Brave";v="107", "Chromium";v="107", "Not=A?Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Linux"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'sec-gpc: 1' \
  -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36' \
  -H 'x-client: popexlp' \
  --data-raw '{"variables":{"limit":100,"skip":0,"id":"644b77f31414b0db1303536a","state":{"eq":"ended"},"sort":{"start":-1},"site":"64a664b51bc8bac6d1a6c697"},"query":"query ($id: MongoID\u0021, $state: FilterEventInput, $limit: Int = 100, $skip: Int = 0, $site: MongoID, $sort: JSON) {...}"}' \
  --compressed
```

*Replace `[Your_OAuth2_Access_Token]` with the actual OAuth2 access token.*

## Create Event

The `createEvent` mutation allows for creating new events with extensive customizable details. This mutation includes numerous arguments for specifying various aspects of an event.

### Data Model

```typescript
interface EventTicket {
  _id: MongoID;
  accepted: [MongoID!];
  accepted_expanded(…): [User];
  accepted_store_promotion: MongoID;
  accepted_user_fields_required: [String!];
  access_pass: AccessPass;
  active: Boolean!;
  address: Address;
  application_form_submission: DateTimeISO;
  application_form_url: String;
  application_profile_fields: [ApplicationProfileField!];
  application_questions: [EventApplicationQuestion!];
  application_required: Boolean;
  approval_required: Boolean;
  approved: Boolean;
  attending_count: Float;
  broadcast_rooms: [BroadcastRoom!];
  broadcasts: [Broadcast!];
  button_icon: String;
  button_text: String;
  button_url: String;
  checkedin: Boolean;
  checkin_count: Float;
  cohosts: [MongoID!];
  cohosts_expanded(…): [User];
  comments: String;
  cost: Float;
  cover: String;
  cta_button_text: String;
  cta_secondary_visible: Boolean;
  currency: String;
  data: JSON;
  declined: [MongoID!];
  declined_expanded(…): [User];
  description: String;
  end: DateTimeISO!;
  event_ticket_types: [EventTicketType!];
  eventbrite_enabled: Boolean;
  eventbrite_event_id: String;
  eventbrite_tickets_imported: Boolean;
  events: [MongoID!];
  events_expanded(…): [Event];
  frequent_questions: [FrequentQuestion!];
  guest_directory_enabled: Boolean;
  guest_limit: Float;
  guest_limit_per: Float;
  guests: Int;
  has_terms_accepted: Boolean;
  hide_attending: Boolean;
  hide_chat_action: Boolean;
  hide_cohosts: Boolean;
  hide_creators: Boolean;
  hide_invite_action: Boolean;
  hide_lounge: Boolean;
  hide_question_box: Boolean;
  hide_rooms_action: Boolean;
  hide_session_guests: Boolean;
  hide_speakers: Boolean;
  hide_stories_action: Boolean;
  highlight: Boolean;
  host: MongoID!;
  host_expanded: User;
  inherited_cohosts: [MongoID!];
  invited: [MongoID!];
  invited_count: Float;
  invited_expanded(…): [User];
  inviter_user_map: JSON;
  inviters: [MongoID!];
  latitude: Float;
  layout_sections: [LayoutSection!];
  location: Point;
  longitude: Float;
  matrix_event_room_id: String;
  new_new_photos: [MongoID!];
  new_new_photos_expanded(…): [File];
  new_photos: [FileInline!];
  offers: [EventOffer!];
  payment_accounts_expanded(…): [NewPaymentAccount];
  payment_accounts_new: [MongoID!];
  payment_donation: Boolean;
  payment_donation_amount_includes_tickets: Boolean;
  payment_donation_amount_increment: Float;
  payment_donation_message: String;
  payment_donation_target: Float;
  payment_enabled: Boolean;
  payment_fee: Float!;
  payment_optional: Boolean;
  payment_ticket_count: Float;
  payment_ticket_discounts: [EventPaymentTicketDiscount!];
  payment_ticket_external_message: String;
  payment_ticket_external_url: String;
  payment_ticket_purchase_title: String;
  payment_ticket_unassigned_count: Float;
  pending: [MongoID!];
  pending_expanded(…): [User];
  pending_request_count: Float;
  photos: [String!];
  private: Boolean;
  published: Boolean;
  registration_disabled: Boolean;
  reward_uses: JSON;
  rewards: [EventReward!];
  rsvp_wallet_platforms: [ApplicationBlokchainPlatform!];
  session_guests: JSON;
  sessions: [EventSession!];
  shortid: String!;
  slug: String!;
  speaker_users: [MongoID!];
  speaker_users_expanded(…): [User];
  stamp: DateTimeISO!;
  start: DateTimeISO!;
  state: EventState!;
  stores: [MongoID!];
  stores_expanded(…): [Store];
  stories: [MongoID!];
  stories_eponym: Boolean;
  subevent_enabled: Boolean;
  subevent_parent: MongoID;
  subevent_parent_expanded: Event;
  subevent_settings: SubeventSettings;
  tags: [String!];
  telegram_channels: [TelegramChannel!];
  terms_email_permission_text: Boolean;
  terms_text: String;
  ticket_count: Float;
  tickets: [TicketBase!];
  timezone: String;
  title: String!;
  unlisted: Boolean;
  url: String;
  url_go: String;
  videos: [Video!];
  virtual: Boolean;
  virtual_url: String;
  welcome_text: String;
  welcome_video: Video;
  zones_menu_text: String;
}
```

**Basic Event Information:**

* `title`: The name of the event (required)
* `start`: Event start time
* `end`: Event end time
* `timezone`: Timezone of the event
* `private`: boolean;
* `approval_required` : boolean;
* guest\_limit: Float;&#x20;
* guest\_limit\_per: Float;

### Query: getEvents

#### Description:

This query allows caller to get published non-private event using several filter options.

Popular filter options including:

* `skip (default = 0)` & `limit (default = 25)`: pagination params used to limit the size of returned result. Note that this API is always paginated and does not return total number of result. Thus, one should adopt the "load more" strategy if they want to show all the results.
* `host_filter (optional)`: filter param used to get the events created by an specified host user, or the sub-events (sessions) within those events, or both.
  * `host_filter.host`: id of the host user to filter
  * `host_filter.include_owned_events (boolean)`: return the main events that are created by host user.
  * `host_filter.include_subevents (boolean)`: return all the sub-events (sessions) of those above main events.
  * Note that you must supply at least `include_owned_events` or `include_subevents` or both.

#### Example:

```graphql
query {
  getEvents {
    _id
    title
  }
}
```

```json
{
  "hostFilter": {
    "host": "671ccaff89757b7f99b2b8ca",
    "include_owned_events":true,
    "include_subevents": true,
  },
  "limit": 100
}
```

### API Endpoints

```
# Get list of events
Query.getEvents

# Get event
Query.getEvent

# Create new event
Mutation.createEvent

# Update existing event
Mutation.updateEvent

# Cancel event
Mutation.cancelEvent
```
