When you call Public endpoints such as the Search endpoint, it will return results from a random unauthenticated session.
If you want to get more uniform results and tailored for a specific user, it is possible to call the endpoint from an user scope by including the X-Account-Key.
Example in Python:
- from tikapi import TikAPI
- api = TikAPI("yourAPIKey")
- api.set(
- __options__={
- 'params':{
- 'accountKey':{
- 'name': 'X-Account-Key',
- 'help': "The Account Key is invalid.",
- 'location': "headers",
- 'validate': "^[a-zA-Z0-9]{10,}$"
- }
- }
- }
- )
- # Just add the accountKey parameter
- api.public.search("autocomplete", "query", accountKey="myOptionalAccountKeyHere")
Example in Javascript:
- import TikAPI from 'tikapi';
- api = TikAPI("yourAPIKey")
- api.set(
- $options: {
- params:{
- accountKey:{
- name: 'X-Account-Key',
- help: "The Account Key is invalid.",
- location: "headers",
- validate: "^[a-zA-Z0-9]{10,}$"
- }
- }
- }
- )
- api.public.search({
- category: "autocomplete",
- query: "query",
- accountKey: "myOptionalAccountKeyHere"
- })