HomeGuidesRecipesAPI EndpointsRelease NotesCommunity
Log In

Configure Your Instance

Now that the Layar API is installed and imported into your project you’ll need to configure your instance.


You will need a client ID and secret in order to run any API calls. If you already have these keys, you can skip to the Configuration section.

Getting Your API Keys

In order to access your Layar instance, you’ll first need to set up your API tokens. On your Layar account page click “Generate New API Access Keys”


Layar will generate two keys for you: your Client ID and your Client Secret. KEEP THESE SAFE! Your Client Secret will only be shown once when you create it and is non-recoverable. Keep in mind anyone with access to your API keys will have access to your Layar instance.



Now that you have your API keys, you will need to build the API configuration object.

Setting Up The Configuration Object

Underneath your imported dependencies block, enter the following block of code. Use your Vyasa instance URL (i.e. demo.vyasa.com) as the baseURL and your API keys for the clientID and clientSecret.

base_host = 'baseURL'

configuration = layar_api.Configuration()
configuration.host = f"https://{base_host}"
configuration.access_token = configuration.fetch_access_token('clientID', 'clientSecret')


Pro Tip

Future calls will reference this configuration. You can shorten down your number of keystrokes by adding the following code snippet underneath your configuration object:

client = layar_api.ApiClient(configuration)


Protect Your Keys

Do not store your API Keys anywhere that can be accessed publicly. If this file will be hosted or stored in Github or another publicly available repository use an env file to hide your API Keys.

Creating a Reference to Your Instance

Once you have your configuration object, you can use that to establish a reference to your Layar instance. This reference is what you will use to call Layar methods and access your data.

You can add your data sources as a comma-delimited list (i.e. 'myinstance.yourcompany.com', 'master-arxiv.vyasa.com',...) You can find your available data sources in Cortex under “Layar Systems”.


Add your list of data providers as individual items in the x_vyasa_data_providers parameter.

api_instance = layar_api.SourceDocumentApi(layar_api.ApiClient(configuration))
body = layar_api.SourceDocumentSearchCommand()
x_vyasa_data_providers = 'master-arxiv.vyasa.com, master-biorxiv.vyasa.com, master-clinicaltrials.vyasa.com'

Making Your First Request

You’re ready to go! Try making your first API call by putting the following under your reference:

    api_response = api_instance.search(body, x_vyasa_data_providers)
except ApiException as e:
    print("Exception when calling SourceDocumentApi->search: %s\n" % e)