### IFTTT Connect URL Example Source: https://ifttt.com/docs/getting_started_connect Example of a Connect URL used to initiate the authentication flow for a new user connecting their account to an IFTTT service. ```plaintext https://ifttt.com/connect/{connection_id}?email={your-email@address.com} ``` -------------------------------- ### Setup and Middleware Source: https://ifttt.com/docs/example_services Configuration for the FastAPI app, including installing dependencies, setting up the FastAPI instance, and implementing middleware for service key validation. ```APIDOC ## FastAPI Setup and IFTTT Service Key Validation ### Description This section covers the initial setup of a FastAPI application for IFTTT integration, including dependency installation, defining data models for requests, and implementing middleware to authenticate incoming requests using an IFTTT Service Key. ### Installation ```bash pip install fastapi uvicorn ``` ### FastAPI App Initialization ```python from fastapi import FastAPI, status, Request from fastapi.responses import JSONResponse from pydantic import BaseModel from typing import Optional from datetime import datetime, timezone import uuid app = FastAPI() IFTTT_SERVICE_KEY = 'Paste your service key here (find yours at https://ift.tt/your-service-key)' @app.middleware("http") async def check_service_key(request: Request, call_next): headers = request.headers if 'IFTTT-Service-Key' not in headers or headers['IFTTT-Service-Key'] != IFTTT_SERVICE_KEY : content = {"errors": [{"message": "Unauthorized"}]} return JSONResponse(content = content, status_code = status.HTTP_401_UNAUTHORIZED) response = await call_next(request) return response ``` ### Data Models #### TriggerCheck Model ```python class TriggerCheck(BaseModel): limit: Optional[int] ``` #### QueryRun Model ```python class QueryRun(BaseModel): limit: Optional[int] ``` ### Mock Event Generation ```python def generate_event(): event = { 'created_at': datetime.now(timezone.utc).isoformat(timespec='seconds'), 'meta': { 'id': str(uuid.uuid4()), 'timestamp': int(datetime.now(timezone.utc).timestamp()) } } return event ``` ``` -------------------------------- ### Test Any Event Starts Trigger Source: https://ifttt.com/docs/getting_started_connect Simulates an event to test the 'Any event starts' trigger. This sends a request to your webhook endpoint. ```APIDOC ## POST /v2/connections/{{YourConnectionID}}/triggers/google_calendar.any_event_starts/test ### Description Simulates an event that would trigger the 'Any event starts' trigger, sending a request to your configured webhook endpoint. ### Method POST ### Endpoint /v2/connections/{{YourConnectionID}}/triggers/google_calendar.any_event_starts/test ### Parameters #### Query Parameters - **user_id** (string) - Required - The ID of the user for whom the event is being simulated. #### Headers - **Host**: connect.ifttt.com - **IFTTT-Service-Key** (string) - Required - Your IFTTT service key. ### Request Body An empty JSON object `{}` is expected. ### Request Example ``` POST /v2/connections/{{YourConnectionID}}/triggers/google_calendar.any_event_starts/test?user_id={{YourUserID}} HTTP/1.1 Host: connect.ifttt.com IFTTT-Service-Key: {{YourServiceKey}} {} ``` ### Response #### Success Response (204) - Status: 204 No Content #### Response Example ``` HTTP/1.1 204 No Content Status: 204 No Content ``` ``` -------------------------------- ### IFTTT Connection Enabled Webhook Log Source: https://ifttt.com/docs/getting_started_connect Example log entry for the 'connection enabled' webhook, indicating a POST request to the specified endpoint. A 404 response is expected if the webhook is not set up. ```log POST /ifttt_developers/ifttt/v1/webhooks/connection/enabled ``` -------------------------------- ### IFTTT Test Setup Source: https://ifttt.com/docs/example_services Provides setup information for testing IFTTT actions. ```APIDOC ## POST /ifttt/v1/test/setup ### Description This endpoint is used to provide sample data for testing IFTTT actions, particularly for action record skipping scenarios. ### Method POST ### Endpoint /ifttt/v1/test/setup ### Parameters None ### Request Example None ### Response #### Success Response (200) - **data** (object) - Contains sample data for action record skipping. - **samples** (object) - **actionRecordSkipping** (object) - **create_new_thing** (object) - **invalid** (string) - Indicates an invalid state for the create_new_thing action. #### Response Example ```json { "data": { "samples": { "actionRecordSkipping": { "create_new_thing": { "invalid": "true" } } } } } ``` ``` -------------------------------- ### Install Bundler and Run Rails App Source: https://ifttt.com/docs/example_services Installs the bundler Ruby gem, which is required to manage dependencies for Ruby on Rails applications. After installation, this command runs the 'hello_world.rb' Rails application. ```ruby gem install bundler ``` ```ruby ruby hello_world.rb ``` -------------------------------- ### Install FastAPI Dependency Source: https://ifttt.com/docs/example_services Installs the FastAPI framework and its necessary dependencies using pip. Ensure you are running Python 3.6 or later. ```bash pip install fastapi ``` -------------------------------- ### Test IFTTT Trigger: Any Event Starts Source: https://ifttt.com/docs/getting_started_connect Simulates an event to test the 'Any event starts' trigger for a Google Calendar connection. It sends a POST request to the IFTTT connect API. ```http POST /v2/connections/{{YourConnectionID}}/triggers/google_calendar.any_event_starts/test?user_id={{YourUserID}} Host: connect.ifttt.com IFTTT-Service-Key: {{YourServiceKey}} {} ``` -------------------------------- ### Run Quick Add Event Action Source: https://ifttt.com/docs/getting_started_connect Creates a new Google Calendar event. ```APIDOC ## POST /v2/connections/{{YourConnectionID}}/actions/google_calendar.quick_add_event/run ### Description Creates a new Google Calendar event on the calendar selected by the user when enabling the connection. ### Method POST ### Endpoint /v2/connections/{{YourConnectionID}}/actions/google_calendar.quick_add_event/run ### Parameters #### Query Parameters - **user_id** (string) - Required - The ID of the user for whom the event is being created. #### Headers - **Host**: connect.ifttt.com - **IFTTT-Service-Key** (string) - Required - Your IFTTT service key. ### Request Body An empty JSON object `{}` is expected. The event details (like title, time) are typically configured within the IFTTT Applet that triggers this action. ### Request Example ``` POST /v2/connections/{{YourConnectionID}}/actions/google_calendar.quick_add_event/run?user_id={{YourUserID}} HTTP/1.1 Host: connect.ifttt.com IFTTT-Service-Key: {{YourServiceKey}} {} ``` ### Response #### Success Response (204) - Status: 204 No Content #### Response Example ``` HTTP/1.1 204 No Content Status: 204 No Content ``` ``` -------------------------------- ### IFTTT Service Setup with FastAPI (Python) Source: https://ifttt.com/docs/example_services A Python script using FastAPI to create an IFTTT-compatible service. It includes middleware for service key authentication, endpoints for status checks, test setup, triggers, queries, and actions. Requires Python 3.6+ and FastAPI. ```python from fastapi import FastAPI, status, Request from fastapi.responses import JSONResponse from pydantic import BaseModel from typing import Optional from datetime import datetime, timezone import uuid app = FastAPI() class TriggerCheck(BaseModel): limit: Optional[int] class QueryRun(BaseModel): limit: Optional[int] IFTTT_SERVICE_KEY = 'Paste your service key here (find yours at https://ift.tt/your-service-key)' # Check the validity of the IFTTT-Service-Key on each incoming request before passing it to the path operation @app.middleware("http") async def check_service_key(request: Request, call_next): headers = request.headers if 'IFTTT-Service-Key' not in headers or headers['IFTTT-Service-Key'] != IFTTT_SERVICE_KEY : content = {"errors": [{"message": "Unauthorized"}]} return JSONResponse(content = content, status_code = status.HTTP_401_UNAUTHORIZED) response = await call_next(request) return response # Generate a mock event used in trigger and query responses def generate_event(): event = { 'created_at': datetime.now(timezone.utc).isoformat(timespec='seconds'), 'meta': { 'id': str(uuid.uuid4()), 'timestamp': int(datetime.now(timezone.utc).timestamp()) } } return event # Service health check @app.get('/ifttt/v1/status', status_code=status.HTTP_200_OK) def check(): return # Test data to run subsequent tests with @app.post('/ifttt/v1/test/setup', status_code=status.HTTP_200_OK) def test_setup(): data = { 'samples': { 'actionRecordSkipping': { 'create_new_thing': { 'invalid': 'true' } } } } return {'data': data} # Trigger endpoint @app.post('/ifttt/v1/triggers/new_thing_created', status_code=status.HTTP_200_OK) def new_thing_created(trigger_check: TriggerCheck): data = [] numOfItems = trigger_check.limit if numOfItems is None: numOfItems = 3 if numOfItems >= 1: i = 0 while i < numOfItems: i += 1 data.append(generate_event()) return {'data': data} # Query endpoint @app.post('/ifttt/v1/queries/list_all_things', status_code=status.HTTP_200_OK) def list_all_things(query_run: QueryRun): data = [] numOfItems = query_run.limit if numOfItems is None: numOfItems = 3 if numOfItems >= 1: i = 0 while i < numOfItems: i += 1 data.append(generate_event()) cursor = None if query_run.limit == 1: cursor = str(uuid.uuid4()) return { 'data': data, 'cursor': cursor } # Action endpoint @app.post('/ifttt/v1/actions/create_new_thing', status_code=status.HTTP_200_OK) def create_new_thing(): id = str(uuid.uuid4()) return {'data': [{'id': id}]} ``` -------------------------------- ### Run FastAPI App Locally with Uvicorn Source: https://ifttt.com/docs/example_services Starts the FastAPI application locally using the Uvicorn server. This command assumes your FastAPI app instance is named 'app' within a file named 'hello_world.py'. ```bash uvicorn hello_world:app ``` -------------------------------- ### Connection Enabled Webhook Source: https://ifttt.com/docs/getting_started_connect This endpoint is fired when a user enables your connection. It's used to log connection enablement events. ```APIDOC ## POST /ifttt_developers/ifttt/v1/webhooks/connection/enabled ### Description This webhook is fired anytime a user enables your connection. It's useful for tracking connection enablement events. ### Method POST ### Endpoint /ifttt_developers/ifttt/v1/webhooks/connection/enabled ### Request Body This endpoint typically expects an empty request body, but the specific payload might vary based on IFTTT's internal event structure. ### Response #### Success Response (200) Typically returns a 200 OK or 204 No Content if successful. #### Error Response - 404 Not Found: Expected if the connection enabled webhook is not set up. ``` -------------------------------- ### Run IFTTT Action: Quick Add Event Source: https://ifttt.com/docs/getting_started_connect Executes the 'Quick add event' action for a Google Calendar connection, creating a new event on the user's calendar. It sends a POST request to the IFTTT connect API. ```http POST /v2/connections/{{YourConnectionID}}/actions/google_calendar.quick_add_event/run?user_id={{YourUserID}} Host: connect.ifttt.com IFTTT-Service-Key: {{YourServiceKey}} {} ``` -------------------------------- ### Perform List Events For a Date Range Query Source: https://ifttt.com/docs/getting_started_connect Retrieves Google Calendar events within a specified date range. ```APIDOC ## POST /v2/connections/{{YourConnectionID}}/queries/google_calendar.list_events_for_date_range/perform ### Description Retrieves a list of Google Calendar events within a specified date range from the user's selected calendar. ### Method POST ### Endpoint /v2/connections/{{YourConnectionID}}/queries/google_calendar.list_events_for_date_range/perform ### Parameters #### Query Parameters - **user_id** (string) - Required - The ID of the user whose calendar events are to be retrieved. #### Headers - **Host**: connect.ifttt.com - **IFTTT-Service-Key** (string) - Required - Your IFTTT service key. #### Request Body - **fields** (object) - Required - Contains the date range for the query. - **start_date** (string) - Required - The start date in 'YYYY-MM-DD' format. - **end_date** (string) - Required - The end date in 'YYYY-MM-DD' format. ### Request Example ``` POST /v2/connections/{{YourConnectionID}}/queries/google_calendar.list_events_for_date_range/perform?user_id={{YourUserID}} HTTP/1.1 Host: connect.ifttt.com IFTTT-Service-Key: {{YourServiceKey}} { "fields": { "start_date": "2020-01-01", "end_date": "2020-01-05" } } ``` ### Response #### Success Response (200) - **type** (string) - Indicates the response type, typically 'list'. - **data** (array) - An array of event objects. - **event_id** (string) - The unique identifier for the event. - **title** (string) - The title of the event. - **description** (string) - The description of the event. - **location** (string) - The location of the event. - **event_start** (string) - The start date and time of the event (ISO 8601 format). - **event_end** (string) - The end date and time of the event (ISO 8601 format). - **event_url** (string) - A URL to the event. - **hangouts_url** (string|null) - A URL for Google Hangouts if applicable. - **created_at** (string) - The timestamp when the event was created (ISO 8601 format). - **attendees** (object) - Information about event attendees. - **type** (string) - Typically 'query'. - **query_id** (string) - The ID of the query used to fetch attendees. - **fields** (object) - Parameters used for the attendee query. - **calendar** (string) - The calendar ID. - **event** (string) - The event ID. #### Response Example ```json { "type": "list", "data": [{ "event_id": "2fkfq7gs2q7779sh4jfn0oqed8", "title": "Test!", "description": "", "location": "", "event_start": "2020-02-01T19:00:00.000Z", "event_end": "2020-02-01T19:30:00.000Z", "event_url": "https://www.google.com/calendar/event?eid=N3FzZnFuZGo3a3EwZjlzNDcyOGZnb2gyN2Uga2V2aW5AaWZ0dHQuY29t", "hangouts_url": null, "created_at": "2020-02-27T18:39:53.000Z", "attendees": { "type": "query", "query_id": "google_calendar.list_attendees", "fields": { "calendar": "GAwRPru0NDARdGQFAHAQsbslltHmdmLOQAlmA5gGvy", "event": "2fkfq7gs2q7779sh4jfn0oqed8" } } }] } ``` ``` -------------------------------- ### Run Ruby on Rails Hello World Service with Docker Source: https://ifttt.com/docs/example_services This command deploys the 'Hello World' Ruby on Rails application within a Docker container. It requires Docker to be installed and takes the IFTTT service key as an environment variable. The service will be accessible at http://localhost:3000. ```bash docker run -e IFTTT_SERVICE_KEY='XXXXXX' -p 3000:3000 ifttt/hello-world-ruby ``` -------------------------------- ### Check Ruby Version Source: https://ifttt.com/docs/example_services Command to check the currently installed Ruby programming language version. This is crucial for ensuring compatibility with the Rails application, which requires version 2.2.2 or greater. ```bash ruby -v ``` -------------------------------- ### IFTTT API Endpoints Source: https://ifttt.com/docs/example_services Defines the API endpoints required by IFTTT: status check, test setup, triggers, queries, and actions. ```APIDOC ## IFTTT API Endpoints ### Description This section details the specific API endpoints that a FastAPI application needs to expose to function correctly with IFTTT. It includes endpoints for service health checks, test data setup, handling triggers, processing queries, and executing actions. ### Service Health Check #### Method GET #### Endpoint `/ifttt/v1/status` #### Description Checks the health status of the IFTTT service. Returns a 200 OK response if the service is healthy. #### Response Example (200 OK) (No specific response body is required for this endpoint, only a successful status code.) --- ### Test Setup #### Method POST #### Endpoint `/ifttt/v1/test/setup` #### Description Provides test data that can be used for subsequent testing of IFTTT triggers and actions. This is typically used during the service development and testing phase. #### Request Body (No specific request body is defined for this endpoint, but it's a POST request.) #### Response Example (200 OK) ```json { "data": { "samples": { "actionRecordSkipping": { "create_new_thing": {"invalid": "true"} } } } } ``` --- ### Trigger: New Thing Created #### Method POST #### Endpoint `/ifttt/v1/triggers/new_thing_created` #### Description This endpoint is called by IFTTT to check for new 'things' that have been created. It returns a list of generated events based on the optional `limit` parameter. #### Request Body ```json { "limit": 3 // Optional: Maximum number of items to return } ``` #### Response Example (200 OK) ```json { "data": [ { "created_at": "2023-10-27T10:00:00Z", "meta": { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "timestamp": 1698393600 } }, // ... more events ] } ``` --- ### Query: List All Things #### Method POST #### Endpoint `/ifttt/v1/queries/list_all_things` #### Description This endpoint is used by IFTTT to query for a list of all available 'things'. It supports pagination using a `cursor` for subsequent requests if `limit` is set to 1. #### Request Body ```json { "limit": 3 // Optional: Maximum number of items to return } ``` #### Response Example (200 OK) ```json { "data": [ { "created_at": "2023-10-27T10:00:00Z", "meta": { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "timestamp": 1698393600 } } // ... more events ], "cursor": "some_unique_cursor_string" // Included if limit is 1 } ``` --- ### Action: Create New Thing #### Method POST #### Endpoint `/ifttt/v1/actions/create_new_thing` #### Description This endpoint is called by IFTTT to create a new 'thing' within the service. It returns the ID of the newly created 'thing'. #### Request Body (No specific request body is defined for this endpoint, but it's a POST request.) #### Response Example (200 OK) ```json { "data": [ { "id": "newly_created_thing_id_12345" } ] } ``` ``` -------------------------------- ### IFTTT test/setup Endpoint Request Example Source: https://ifttt.com/docs/testing An example of a complete HTTP POST request to the `test/setup` endpoint, including the host and service key. ```http POST /ifttt/v1/test/setup HTTP/1.1 Host: api.example-service.com IFTTT-Service-Key: vFRqPGZBmZjB8JPp3mBFqOdt Accept: application/json Accept-Charset: utf-8 Accept-Encoding: gzip, deflate ``` -------------------------------- ### IFTTT Rails Application Example Source: https://ifttt.com/docs/example_services A complete Ruby on Rails application example designed for IFTTT integration. It includes defining triggers, actions, routes, controllers, and models. The application requires a service key for authentication and uses Rails' caching mechanisms. This code should be saved as `hello_world.rb`. ```ruby IFTTT_SERVICE_KEY = "REPLACE_ME" require "bundler/inline" bundler do source "https://rubygems.org" gem "rails", "~> 5.0" end require "action_controller/railtie" require "active_model/railtie" class HelloWorld < Rails::Application routes.append do root to: "hello#world" get "/ifttt/v1/status", to: "ifttt#status" post "/ifttt/v1/test/setup", to: "ifttt#setup" post "/ifttt/v1/triggers/new_thing_created", to: "ifttt#new_thing_created" post "/ifttt/v1/queries/list_all_things", to: "ifttt#list_all_things" post "/ifttt/v1/actions/create_new_thing", to: "ifttt#create_new_thing" end config.cache_store = :memory_store config.eager_load = false config.logger = Logger.new(STDOUT) config.secret_key_base = SecureRandom.hex(30) end class Thing include ActiveModel::Model attr_accessor :created_at def self.all Rails.cache.fetch("things") do [ Thing.new(created_at: Time.parse("Jan 1")), Thing.new(created_at: Time.parse("Jan 2")), Thing.new(created_at: Time.parse("Jan 3")), ] end end def self.create Thing.new.tap do |new_thing| new_thing.created_at = all.last.created_at + 1.day Rails.cache.write("things", all.push(new_thing)) end end def id created_at.to_i end def to_trigger_json { created_at: created_at.iso8601, meta: { id: id, timestamp: created_at.to_i } } end def to_json { id: id, created_at: created_at.iso8601 } end def to_limited_json { id: id } end end class HelloController < ActionController::Base def world render plain: "Hello, World!\n" + Thing.all.map(&:to_json).join("\n") end end class IftttController < ActionController::Base before_action :return_errors_unless_valid_service_key before_action :return_errors_unless_valid_action_fields, only: :create_new_thing def status head :ok end def setup data = { samples: { actionRecordSkipping: { create_new_thing: { invalid: "true" } } } } render plain: { data: data }.to_json end def new_thing_created data = Thing.all.sort_by(&:created_at).reverse.map(&:to_trigger_json).first(params[:limit] || 50) render plain: { data: data }.to_json end def list_all_things data = Thing.all.map(&:to_json).first(params[:limit] || 50) render plain: { data: data }.to_json end def create_new_thing data = [ Thing.create.to_limited_json ] render plain: { data: data }.to_json end private def return_errors_unless_valid_service_key unless request.headers["HTTP_IFTTT_SERVICE_KEY"] == IFTTT_SERVICE_KEY return render plain: { errors: [ { message: "401" } ] }.to_json, status: 401 end end def return_errors_unless_valid_action_fields if params[:actionFields] && params[:actionFields][:invalid] == "true" return render plain: { errors: [ { status: "SKIP", message: "400" } ] }.to_json, status: 400 end end end if IFTTT_SERVICE_KEY == "REPLACE_ME" raise "⚠️ Copy your service key (find yours at https://ift.tt/your-service-key) into the first line of this file, then try again." end HelloWorld.initialize! Rack::Server.start app: HelloWorld, Host: "0.0.0.0", Port: 3000 ``` -------------------------------- ### Test IFTTT Query: List Events For a Date Range Source: https://ifttt.com/docs/getting_started_connect Tests the 'List Events For a Date Range' query for a Google Calendar connection. It retrieves a list of events within a specified date range. ```http POST /v2/connections/{{YourConnectionID}}/queries/google_calendar.list_events_for_date_range/perform?user_id={{YourUserID}} Host: connect.ifttt.com IFTTT-Service-Key: {{YourServiceKey}} { "fields": { "start_date": "2020-01-01", "end_date": "2020-01-05" } } ``` -------------------------------- ### Connection Enabled Webhook Example Source: https://ifttt.com/docs/connect_api An example of a webhook request sent by IFTTT when a user enables a connection. This notification includes details about the connection and the user. ```HTTP POST /ifttt/v1/webhooks/connection/enabled HTTP/1.1 Host: api.example-service.com X-Request-ID: 9f99e73452cd40198cb6ce9c1cde83d6 { "sent_at": 1560285630699, "data": { "connection_id": "C8p3q9T6", "user_id": "16507466", "user_timezone": "Pacific Time (US & Canada)" }, "event_data": { "enabled_at": "1560285630711" } } ``` -------------------------------- ### Example Channel Authorization Redirect Source: https://ifttt.com/docs/api_reference An example of the redirect URL after a user authorizes the IFTTT connection. It includes the 'code' and 'state' parameters required by IFTTT. ```URL https://ifttt.com/channels/example_channel/authorize?code=67a8ad40341224c1&state=a00caec8dbd08e50 ``` -------------------------------- ### Action Field Examples (JSON) Source: https://ifttt.com/docs/testing Provides example valid values for action fields. This demonstrates the expected structure and data types for parameters when executing an action, such as posting a photo with album, URL, and description. ```json { "actions": { "post_a_photo": { "album": "Sports", "url": "http://example.com/foo/jpg", "description": "AT&T Park" } } } ``` ```json { actionFields: { "album": "Sports", "url": "http://example.com/foo/jpg", "description": "AT&T Park" } } ``` -------------------------------- ### IFTTT Query Options API Example Request Source: https://ifttt.com/docs/api_reference An example of an HTTP POST request to the IFTTT API for retrieving query field options. This demonstrates the actual format of the request, including host, headers, and the empty body. ```HTTP POST /ifttt/v1/queries/list_album_photos/fields/album_name/options HTTP/1.1 Host: api.example-service.com Authorization: Bearer b29a71b4c58c22af116578a6be6402d2 Accept: application/json Accept-Charset: utf-8 Accept-Encoding: gzip, deflate X-Request-ID: 9f99e73452cd40198cb6ce9c1cde83d6 {} ``` -------------------------------- ### IFTTT Service Status API Example Request Source: https://ifttt.com/docs/api_reference An example of an HTTP GET request to the IFTTT service status endpoint, demonstrating the Host header and the IFTTT-Service-Key. ```HTTP GET /ifttt/v1/status HTTP/1.1 Host api.example-service.com IFTTT-Service-Key: vFRqPGZBmZjB8JPp3mBFqOdt Accept: application/json Accept-Charset: utf-8 Accept-Encoding: gzip, deflate X-Request-ID: 0715f98e65f749aba2fc243eac1e3c09 ``` -------------------------------- ### IFTTT Queries: List All Things Source: https://ifttt.com/docs/example_services Retrieves a list of all available things. ```APIDOC ## POST /ifttt/v1/queries/list_all_things ### Description This endpoint retrieves a list of all available things. The results are paginated. ### Method POST ### Endpoint /ifttt/v1/queries/list_all_things ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of items to return. Defaults to 50. ### Request Example None ### Response #### Success Response (200) - **data** (array) - An array of thing objects. - **id** (integer) - The unique identifier for the thing. - **created_at** (string) - The ISO 8601 formatted timestamp when the thing was created. #### Response Example ```json { "data": [ { "id": 1, "created_at": "2023-01-01T00:00:00Z" }, { "id": 2, "created_at": "2023-01-02T00:00:00Z" } ] } ``` ``` -------------------------------- ### Expose Local Server with ngrok Source: https://ifttt.com/docs/example_services Uses ngrok to create a secure public URL that forwards traffic to a local web server. This command specifically forwards requests to a server listening on port 3000. ```bash ngrok http 3000 ``` -------------------------------- ### HTTP Request: Service-Authenticated with User ID Source: https://ifttt.com/docs/connect_api An example of a service-authenticated HTTP GET request that includes a 'user_id' parameter. This is often required for accessing user-specific resources when making calls from a backend server. ```http GET /v2/me?user_id=123 Host: connect.ifttt.com IFTTT-Service-Key: 6e7c8978c07a3b5918a237b9b5b1bb70 ``` -------------------------------- ### HTTP Request: Service-Authenticated Access Source: https://ifttt.com/docs/connect_api Shows an example of a service-authenticated HTTP GET request to the IFTTT Connect API. This requires an 'IFTTT-Service-Key' header, typically used for backend server calls to the API. ```http GET /v2/me Host: connect.ifttt.com IFTTT-Service-Key: 6e7c8978c07a3b5918a237b9b5b1bb70 ``` -------------------------------- ### IFTTT JavaScript API: Run a Query Source: https://ifttt.com/docs/connections This example illustrates how to execute an IFTTT query using the `performQuery` function. It demonstrates calling the `youtube.get_videos_from_search` query and includes a `.then()` block to handle the response from the Connect API. ```javascript performQuery("youtube.get_videos_from_search") .then((response) => { /* handle query response here */ }); ``` -------------------------------- ### IFTTT Actions: Create New Thing Source: https://ifttt.com/docs/example_services Creates a new thing within the IFTTT service. ```APIDOC ## POST /ifttt/v1/actions/create_new_thing ### Description This endpoint is responsible for creating a new 'thing' within the IFTTT service. It returns the details of the newly created thing. ### Method POST ### Endpoint /ifttt/v1/actions/create_new_thing ### Parameters #### Request Body - **actionFields** (object) - Optional - Fields related to the action execution. - **invalid** (string) - Optional - If set to 'true', this will cause the action to return an error. ### Request Example ```json { "actionFields": { "invalid": "false" } } ``` ### Response #### Success Response (200) - **data** (array) - An array containing the newly created thing object. - **id** (integer) - The unique identifier for the created thing. #### Response Example ```json { "data": [ { "id": 4 } ] } ``` #### Error Response (400) - **errors** (array) - **status** (string) - Indicates the error status (e.g., "SKIP"). - **message** (string) - A message describing the error (e.g., "400"). #### Error Response Example (400) ```json { "errors": [ { "status": "SKIP", "message": "400" } ] } ``` ``` -------------------------------- ### Example IFTTT Trigger Request (Explicit Limit) Source: https://ifttt.com/docs/api_reference An example HTTP POST request to the 'new_photo_in_album_with_hashtag' trigger with an explicit limit of 10 items. ```http POST /ifttt/v1/triggers/new_photo_in_album_with_hashtag HTTP/1.1 Host: api.example-service.com Authorization: Bearer b29a71b4c58c22af116578a6be6402d2 Accept: application/json Accept-Charset: utf-8 Accept-Encoding: gzip, deflate Content-Type: application/json X-Request-ID: 7f7cd9e0d8154531bbf36da8fe24b449 { "triggerFields": { "album_name": "Street Art", "hashtag": "banksy" }, "limit": 10, "ifttt_source": { "id": "2", "url": "https://ifttt.com/myrecipes/personal/2" }, "user": { "timezone": "America/Los_Angeles" } } ``` -------------------------------- ### IFTTT Triggers: New Thing Created Source: https://ifttt.com/docs/example_services Retrieves a list of newly created things as triggers. ```APIDOC ## POST /ifttt/v1/triggers/new_thing_created ### Description This endpoint serves as a trigger for new things being created. It returns a list of recently created things, sorted by creation time in descending order, and paginated. ### Method POST ### Endpoint /ifttt/v1/triggers/new_thing_created ### Parameters #### Query Parameters - **limit** (integer) - Optional - The maximum number of items to return. Defaults to 50. ### Request Example None ### Response #### Success Response (200) - **data** (array) - An array of trigger objects. - **created_at** (string) - The ISO 8601 formatted timestamp when the thing was created. - **meta** (object) - **id** (integer) - The unique identifier for the trigger. - **timestamp** (integer) - The Unix timestamp for the creation time. #### Response Example ```json { "data": [ { "created_at": "2023-01-03T00:00:00Z", "meta": { "id": 3, "timestamp": 1672652400 } }, { "created_at": "2023-01-02T00:00:00Z", "meta": { "id": 2, "timestamp": 1672566000 } } ] } ``` ``` -------------------------------- ### Node.js: Set IFTTT Service Key Source: https://ifttt.com/docs/example_services Sets the IFTTT service key in the .env file for a Node.js application. This key is crucial for IFTTT to authenticate and identify your service. ```env IFTTT_KEY="rG4_x0f26jSfY…" ``` -------------------------------- ### Example User Denies Access Redirect Source: https://ifttt.com/docs/api_reference An example of the redirect URL when a user denies IFTTT access. It includes the 'error' parameter indicating denial. ```URL https://ifttt.com/channels/example_channel/authorize?error=access_denied ``` -------------------------------- ### IFTTT test/setup Endpoint Response Body Example Source: https://ifttt.com/docs/testing A sample JSON response body for the `test/setup` endpoint. It includes an `accessToken` for OAuth services and a `samples` object containing data for triggers and actions. ```json { "data": { "accessToken": "taSvYgeXfM1HjVISJbUXVBIw1YUkKABm", "samples": { "triggers": { "any_new_photo_in_category": { "category": "Nature" }, "any_new_photo_in_album": { "album": "Italy" } }, "triggerFieldValidations": { "any_new_photo_in_album": { "album": { "valid": "Italy", "invalid": "AlbumDoesNotExist" } } }, "actions": { "post_a_photo": { "album": "Sports", "url": "http://example.com/foo/jpg", "description": "AT&T Park" } } } } } ``` -------------------------------- ### IFTTT JavaScript API: Run an Action Source: https://ifttt.com/docs/connections This example shows how to execute an IFTTT action using the `runAction` function. It demonstrates calling the `sms.send_me_text` action and includes a `.then()` block to handle the response from the Connect API. ```javascript runAction("sms.send_me_text") .then((response) => { /* handle action response here */ }); ``` -------------------------------- ### Connection Disabled Webhook Example Source: https://ifttt.com/docs/connect_api An example of a webhook request sent by IFTTT when a user disables a connection. This notification is sent to the service's webhook endpoint. ```HTTP POST /ifttt/v1/webhooks/connection/disabled HTTP/1.1 Host: api.example-service.com X-Request-ID: 9f99e73452cd40198cb6ce9c1cde83d6 { "sent_at": 1560285630699, "data": { "connection_id": "C8p3q9T6", "user_id": "16507466", "user_timezone": "Pacific Time (US & Canada)" }, "event_data": { "disabled_at": "1560285630711" } } ``` -------------------------------- ### Initialize Gradle Project for Spring Boot Source: https://ifttt.com/docs/api_reference Initializes a new Gradle project and sets up the necessary directory structure for a Spring Boot application. This includes creating the project directory, a Gradle wrapper, and resource/java directories. ```bash mkdir service-api-example cd service-api-example grade wrapper --gradle-version 6.7.1 mkdir -p src/main/resources mkdir -p src/main/java/com/example/service/ ``` -------------------------------- ### Example IFTTT Action Request Body Source: https://ifttt.com/docs/api_reference An example POST request body for an IFTTT action, including action fields, IFTTT source information, and user details. ```http POST /ifttt/v1/actions/new_status_update HTTP/1.1 Host: api.example-service.com Authorization: Bearer b29a71b4c58c22af116578a6be6402d2 Accept: application/json Accept-Charset: utf-8 Accept-Encoding: gzip, deflate Content-Type: application/json X-Request-ID: 1d21c3cd2ed8441ea269dd554d2c8e54 { "actionFields": { "title": "New Banksy photo!", "body": "Check out a new Bansky photo: http://example.com/images/125" }, "ifttt_source": { "id": "2", "url": "https://ifttt.com/myrecipes/personal/2" }, "user": { "timezone": "America/Los_Angeles" } } ``` -------------------------------- ### Example IFTTT Trigger Request (Default Limit) Source: https://ifttt.com/docs/api_reference An example HTTP POST request to the 'new_photo_in_album_with_hashtag' trigger without specifying a limit, implying the default limit of 50. ```http POST /ifttt/v1/triggers/new_photo_in_album_with_hashtag HTTP/1.1 Host: api.example-service.com Authorization: Bearer b29a71b4c58c22af116578a6be6402d2 Accept: application/json Accept-Charset: utf-8 Accept-Encoding: gzip, deflate Content-Type: application/json X-Request-ID: 7f7cd9e0d8154531bbf36da8fe24b449 { "trigger_identity": "92429d82a41e93048", "triggerFields": { "album_name": "Street Art", "hashtag": "banksy" }, "ifttt_source": { "id": "2", "url": "https://ifttt.com/myrecipes/personal/2" }, "user": { "timezone": "America/Los_Angeles" } } ```