Back to Typesense

Authentication

docs-site/content/0.12.0/api/authentication.md

latest1.3 KB
Original Source

Authentication

<Tabs :tabs="['JavaScript','Python','Ruby','Shell']"> <template v-slot:JavaScript>
js
/*
 *  Our JavaScript client library works on both the server and the browser.
 *  When using the library on the browser, please be sure to use the
 *  search-only API Key rather than the master API key since the latter
 *  has write access to Typesense and you don't want to expose that.
 */

const Typesense = require('typesense')

let client = new Typesense.Client({
  'nodes': [{
    'host': 'localhost',
    'port': '8108',
    'protocol': 'http'
  }],
  'apiKey': '<API_KEY>',
  'connectionTimeoutSeconds': 2
})
</template> <template v-slot:Python>
py
import typesense

client = typesense.Client({
  'nodes': [{
    'host': 'localhost',
    'port': '8108',
    'protocol': 'http'
  }],
  'api_key': '<API_KEY>',
  'connection_timeout_seconds': 2
})
</template> <template v-slot:Ruby>
rb
require 'typesense'

client = Typesense::Client.new(
  nodes: [{
    host:     'localhost',
    port:     8108,
    protocol: 'http'
  }],
  api_key:  '<API_KEY>',
  connection_timeout_seconds: 2
)
</template> <template v-slot:Shell>
bash
export TYPESENSE_API_KEY='<API_KEY>'
export TYPESENSE_HOST='http://localhost:8108'
</template> </Tabs>