HomeGuidesRecipesAPI EndpointsRelease NotesCommunity
Log In
Guides

Adding Connectors to Layar

Using the LiveSource URL

In order to create and manage your connectors, we'll be using the /layar/liveSourceURL. Ensure you've followed the setup instructions in the Getting Started Guide to ensure your API calls are authenticated.

Creating a New Connector Body

Before creating a new connector we will need to create an object to pass the connector type's required parameters. Create a body object and then find the required parameters for the connector type you would like to add below.

👍

Finding Parameters

Remember, you can go to https://YOUR_ENVIRONMENT/layar/swagger-ui.html in order to look up required parameters.

Website Connector

Website connectors are the simplest ones to set up. They require only a name and a URL, both as strings. You can also add an optional description. Add them to your body object as shown below.

body = {
        'liveSourceType' : 'WEBSITE',
        'name' : 'Website Name',
        'description' : 'Description of the website', #Optional
        'url' : 'https://www.website.com'
        }

RSS Connector

RSS Connectors also require a name and a URL with an option to add a description. You will also need to be provided a runMode which will tell Layar if you would like to scan the RSS feed once at the time of creation or continuously check for updates. runMode accepts a string of either "SCAN_ONCE" or "CONTINUOUS". Add the parameters to your body as shown below.

body = {
        'liveSourceType' : 'WEBSITE',
        'name' : 'Website Name',
        'description' : 'Description of the website', #Optional
        'url' : 'https://www.website.com',
  			'runMode' : 'continous'
        }

Google BigQuery Connector

In order to add a Google BigQuery connector, you will need your BigQuery project ID and GCP Service Account Key. To find this information please follow Google's Support Documentation. Once you have these parameters, add them to your body as shown below.

body = {
        'liveSourceType' : 'GBQ_PROJECT',
        'name' : 'bigquery-project-id',
        'description' : 'Description of your BigQuery project', #Optional
        'credentials' : [{
                         'type' : 'service_account',
                         'project_id' : 'projectID',
                         'private_key_id' : 'keyID',
                         'private_key' : '--BEGIN PRIVATE KEY--\nprivate-key\n--END PRIVATE KEY--\n',
                         'client_email' : 'serviceAccountEmail',
                         'client_id' : 'clientID',
                         'auth_uri' : 'https://accounts.google.com/o/oauth2/auth',
                         'token_uri' : 'https://accounts.google.com/o/oauth2/token',
                         'auth_provider_x509_cert_url' : 'https://www.googleapis.com/oauth2/v1/certs',
                         'client_x509_cert_url' : 'https://www.googleapis.com/robot/v1/metadata/x509/service-account-email'
                         }]
        }

Adding The Connector

Once you have built out your bodyobject, you'll want to pass it to the requests.post method in order to create your new connector as shown below. The method will return a response object containing a connectorId which you will need to make sure you store in a variable for when it's time for Managing Connectors.

Response = requests.post(connectorUrl,
                        headers = header,
                        json = body)
connectorId = Response.json().get('id') #This adds the connectorId to a variable which we can use later
pprint(response) #Optional

Up Next

Now that we know how to create a Connector, we can manage that connector.